Jul-01-2018, 07:53 PM
This is how i got it to work.
If anyone has a better way to achieve the same results please let me know.
thanks to @ljmetzger for pointing me in the right direction
If anyone has a better way to achieve the same results please let me know.
thanks to @ljmetzger for pointing me in the right direction
### shitty battle simulator ### import random import time playerHealth = 50 compHealth = 50 def battleIntro(): print ("You enter the arena to the cheers of the crowds. ") print ("Across fomr you stands your opponent. ") print ("Only one you will leave this place alive. ") print ("Prepare to fight!" ) print() def battlePlayer(): global compHealth global playerHealth missChance = 2 while playerHealth > 0 and compHealth > 0: print ("Do you wish to attack") #input ("enter") miss = random.randint (1, 4) if (missChance) == (miss): print ("You swing wildly and miss your opponent. ") print() else: print ("You strike your opponent doing damage. ") print() compHealth = compHealth - 5 break def battleComp(): global playerHealth global compHealth missChance = 2 while playerHealth > 0 and compHealth > 0: print ("Your opponent charges at you. ") #time.sleep(2) miss = random.randint (1, 4) if (missChance) == (miss): print ("You dodge his attack. ") print() else: print ("He manages to strike you doing damage. ") print() playerHealth = playerHealth - 5 break def battleResult(): global comphealth global playerHealth if compHealth == 0: print ("Your hands are slick with his blood. ") print ("You have slayen your opponent." ) print() elif playerHealth == 0: print ("Your opponent stands over you and drives his sword into your chest. ") print ("You have died! ") print() def battleLoop(): while playerHealth > 0 and compHealth > 0: battlePlayer() battleComp() #if playerHealth < 0 or compHealth < 0: #battleResult() playAgain = "yes" while playAgain == "yes" or playAgain == "y": playerHealth = playerHealth + 50 compHealth = compHealth + 50 battleIntro() #battlePlayer() #battleComp() battleLoop() battleResult() print ("Do you want to play again?") playAgain = input()