mardi 3 novembre 2015

Bad Input on Line Without an Input

Good afternoon Stack Overflow community. I was working on a fighting sim as a side project and I was stopped short by an input error on line 11. The only problem seems to be that line 11 doesn't have an input statement. I'm unsure of what is causing this:

#Fighting Simulator

from random import *

def main():
    tutorial = input("Would you like a brief rundown of how to play? (Y/N): ")    
    if tutorial == "Y":
        print("Choose your stats and fight randomly generated characters")         
    else:
        chosen = False
        while chosen == False:
            maxstats = 25
            fightername = input("\rEnter your fighter's name: ")
            print("Choose your fighter's stats. Total stat points cannot exceed 25.")
            strength = eval(input("Enter a value between 1 and 10 for your fighter's strength: "))
            blocking = eval(input("Enter a value between 1 and 10 for your fighter's blocking: "))
            quickness = eval(input("Enter a value between 1 and 10 for your fighter's quickness: "))    
            luck = eval(input("Enter a value between 1 and 10 for your fighter's luck: "))
            deception = eval(input("Enter a value between 1 and 10 for your fighter's deceptiveness: "))              
            totalstats = strength+blocking+quickness+luck+deception
            if totalstats > maxstats:
                print("Invalid stats configuration.")
            else:    
                satisfaction = input("Are you satisfied with your character? (Y/N): ")
                if satisfaction == "Y":
                    chosen = True
        running = True
        cpuname = "The Hunter from Bambi", "Hades", "Hitler", "George W. Bush", "Justin Bieber"
        for x in range(0,4):
            print("\rRound",x+1,fightername,"vs.",cpuname[x])
            print("FIGHT!")
            validstats = False
            while validstats == False
                bstr = randint(1,10)
                bblk = randint(1,10)
                bquick = randint(1,10)
                bluck = randint(1,10)
                bdec = randint(1,10)
                totalcpu = bstr+bblk+bquick+bluck+bdec
                if totalcpu == maxstats:
                    validstats = True
            hpplayer = 100
            hpcpu = 100
            gameover = False
            while running == True and gameover == False :
                victory = False
                print("\rPlayer's HP:",hpplayer," "cpuname[x]"'s HP:",hpcpu)
                decision = input("Attack or block? (A/B): ")
                cpudecision = randint(0,1)
                blockmult = 2
                if decision == "A":
                    power = strength*10
                    if cpudecision == 0:
                        damage = power-(bblk*.10*power)
                        print(fightername,"attacks for", damage, "damage")
                        hpcpu = hpcpu-damage
                    if (hpcpu <= 0):
                        print(cpuname[x],"has been KO'd!")
                        victory = True
                        running = False
                    powercpu = bstr*10
                    damagecpu = powercpu-(blocking*.10*powercpu)
                    print(cpuname[x],"attacks for", damagecpu, "damage")
                    hpplayer = hpplayer - damagecpu
                    if (hpplayer <= 0):
                        print(fightername,"has been KO'd!")
                        running = False
                else:
                    blockboost = blockmult*bblk
                    bdamage = power-(blockboost*.10*power)
                    print(fightername,"attacks for", bdamage, "damage")
                    print(cpuname[x],"blocks and takes reduced damage")
                    hpcpu = hpcpu-bdamage
                    if (hpcpu <= 0):
                        print(cpuname[x],"has been KO'd!")
                        victory = True
                        running = False

            else:
                if cpudecision == 0:
                    bboost = blockmult*blocking
                    powercpu = bstr*10
                    damagecpu = powercpu-(bboost*.10*powercpu)
                    print(cpuname[x],"attacks for", damagecpu, "damage")
                    print(fightername,"blocks and takes reduced damage")
                    hpplayer = hpplayer - damagecpu
                    if (hpplayer <= 0):
                        print(fightername,"has been KO'd!")
                        running = False

                else:
                    print("Both fighters are blocking, no damage was dealt."
            if victory == True:
                print("You win round", x+1)
                if x == 4:
                    print("You beat the game! Congratulations!")
                    gameover = True
            else:
                print("You lose!")
                gameover = True




Aucun commentaire:

Enregistrer un commentaire