Oct-09-2018, 12:27 AM
Hello-
I'm making a text-based RPG with Python, but when I run my script, Python throws an exception. I've narrowed down the place of error to the following:
Thanks!
I'm making a text-based RPG with Python, but when I run my script, Python throws an exception. I've narrowed down the place of error to the following:
str = 1 spd = 1 #First combat print("Outside is a large spider. You engage it in combat.") enemyhp = 1 enemyspeed = 0 print("The enemy's HP is ",enemyhp1,", and its speed is ",enemyspeed,".") attack = input("Do you FLEE or FIGHT?") #Fight... if attack == "FIGHT": damagedealt = 2*str print("You slash it, dealing ",damagedealt," damage.") enemyhp1 = enemyhp1 - damagedealt print("The enemy's HP is now at ",enemyhp1,". It dies. You also gain 2 XP from killing it, putting you at 2.") xp = 2 #...or flight. if attack == "FLEE" and enemyspeed < speed: print("You succesfully fled the enemy. You can only flee when your speed is greater than the enemy's, and it gives you half as much XP. You are now at 1 XP.") xp = 1It's supposed to give a choice between fighting or fleeing. When one attacks it deals damage in accordance with the strength of the character, or if one flees and your speed is greater than the enemy's you escape it. There seem to be no errors, but if someone can look it over for me and point out one, I'd be very grateful.
Thanks!