Dec-16-2016, 10:22 PM
(This post was last modified: Dec-16-2016, 10:31 PM by ichabod801.)
Whenever i run the program it continually loops. Please help!
import random #Misc. variables y = 0 monNum = random.randint(1, 2) #Player variables player1HP = 10 gold = 0 #Enemy HP goombaHP = 10 slimeHP = 15 #Monster Number Generator def monNumCmd(): monNum = random.randint(1,1) #Attack command def attack(): if(monNum==1): global goombaHP attackValue = random.randint(1, 10) goombaHP = goombaHP - attackValue print("Goomba HP:") print(goombaHP) elif(monNum==2): global slimeHP attackValue = random.randint(1,10) slimeHP = slimeHP - attackValue print("Slime HP:") print(slimeHP) #Enemy attack def enemyAttack(): if(monNum==1): global player1HP enemyAttack = random.randint(1, 3) player1HP = player1HP - enemyAttack print("Player HP:") print(player1HP) #Inventory Screen def inventory(): print("Player HP:") print(player1HP) print() print("Gold:") print(gold) print() def move(): y=y-1 #Battle input chain def enemyBattleChain(): global y global gold global monNum if(monNum==1): if(player1HP<=0): print("You have been defeated!") y=y+1 elif(goombaHP<=0): print("You have slain the Goomba!") gold = gold + random.randint(1,3) inventory() else: print("A goomba has crossed your path!") print() command = input("What will you do?:") print() if(command == "help"): print("attack") print() elif(command == "attack"): attack() enemyAttack() else: print("Command not found") elif(monNum==2): if(player1HP<=0): print("You have been defeated!") if(slimeHP<=0): print("You have slain the Slime!") else: print("A slime has crossed your path!") print() command = input("What will you do?:") print() if(command=="help"): print("attack") print() elif(command == "attack"): attack() else: print("Command not found") while(y==0): enemyBattleChain()