mardi 3 juillet 2018

code not working as it seems it should? can't get elif statement to work

I'm having trouble getting my code to continue through to the elif statement. If I enter rogue as the class, it is still giving me the warriors damage. The worst part is I had it working fine before and changed something. I've tried everything i can think of can't get it to work again lol.

This is just a a little experiment for learning purposes. I'm a complete beginner and don't really understand that much yet.

import random


boss = 10000
attack = 0
chnc = random.randrange(1,11)
hero = input("CHoose your Class. Warrior or Rogue: ")
print("")



print("Geat Ready to Fight")
print("")
print("BOSS: ", boss)
print("")


while True:

    if hero == "warrior" or "Warrior":   
        user = int(input("Enter '1' to attack: "))
        print("")
        print("")
        if user == 1:
            attack = random.randrange(20,102,  2) 
            wattack = attack + attack * .10
            wattack = int(round(wattack))
            boss -= wattack
            print(attack)
            print(wattack)
            print(boss)
    elif hero == "rogue" or "Rogue":
        user = int(input("Enter '1' to attack: "))
        if user == 1: 
            attack = random.randrange(10,102, 2)
            rattack = attack + attack
            boss -= rattack
            print(attack)
            print(rattack)
            print(boss)

Aucun commentaire:

Enregistrer un commentaire