[Tutor] Combat Error

Jack Little jacklittlemc at yahoo.com
Mon Jul 8 00:40:48 CEST 2013


When the player of my game fire his/her cannon, it is supposed to get rid of some of the enemy's health. It does not. I have no clue what the error is, so I need help. Here is the Python Shell output:

>>fire cannon 1
Fired!
Enemy health= 75
They fired at you!
Your health is now 55
>>fire cannon 2
Fired!
Enemy health= 75
They fired at you!
Your health is now 55
>>fire cannon 1
Fired!
Enemy health= 75
They fired at you!
Your health is now 55
>>




Here is the code:

def lvl4combat():
    print "The barracks are constructed of wood and cobblestone."
    print "A large, single cannon sits on the top, searching the sky for enemy airships."
    print "The cannon is manned by a single team of three men."
    print "The cannon is large and industrial."
    print "Remember your training."
    cannonhealth=75
    cannondamage=random.choice([10,17,13])
    currhealth=health
    while cannonhealth > 0:
        print "They fired at you!"
        currhealth-cannonhealth
        print "Your health is now",currhealth
        combat=raw_input(">>")
        if combat.lower()=="fire cannon 1":
            print "Fired!"
            cannonhealth-attack
            print "Enemy health=",cannonhealth
        elif combat.lower()=="fire cannon 2":
            print "Fired!"
            cannonhealth-attack
            print "Enemy health=",cannonhealth
        if currhealth <= 0:
            break
            defeat1()
        if cannonhealth <= 0:
            break
            victory1()
            if kboost==True:
                karma+25*.25
            elif kboost==False:
                karma+25
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130707/3807a280/attachment-0001.html>


More information about the Tutor mailing list