import random def Orc(): global enName, enAtt, enHP, enDef, enMove, enExp enName = "Orc" enAtt = 0 enDef = 13 enMove = random.randint(0, 13) enExp = 100 enHP = 100 def goblin(): global enName2, enAtt2, enHP2, enDef2, enMove2, enExp2 enName2 = "Goblin" enAtt2 = 10 enDef2 = 13 enMove2 = random.randint(0, 13) enExp2 = 100 enHP2 = 100 def player(): global plName, plAtt, plDef, plHP, plXP,plXPuse plName = input("What is your name?") plAtt = 10 plDef = 13 plHP = 50 plXP = 0 plXPuse = plXP Orc() # Initialize enemy Orc player() # Initialize player willAttack = "y" attackOrc = "y" attackGob = "n" class attack_orc(): while attackOrc == "y": while enHP > 0: # Check enemy HP willAttack = input('Will [y]ou attack or [n]ot?') enMove = random.randint(0, 13) if willAttack == "y": enHP -= plAtt print(plName, "has attacked", enName, "for", plAtt) print("Orc has", enHP, "health left") plHP -= enMove print(enName, "has attacked", plName, "for", enMove) print(plName, "has,", plHP, "health left") else: print(enName, "has attacked", plName) if plDef >= enMove: enHP -= plDef - enMove print(enName, "has", enHP, "health left") elif plDef <= enMove: plHP -= enMove - plDef print(plName, "has,", plHP, "health left") if plHP <= 0: print("You died!") print("You gained 50 XP!") plXP += 50 plXPuse = plXP if plXPuse % 100 == 0: plHP += 10 if plXPuse % 50 == 0: plAtt += 2 print(plXP, plXPuse) enHP = 100 attackOrc = input("Will [y]ou attack agai[n]?") print("who to attack...") attackOrc = input("Will [y]ou attack the orc or [n]ot") while attackOrc == "y": Orc() # Initialize enemy Orc player() # Initialize player attack_orc()