I'm trying to make a game that has a "fight" loop that it runs when the user encounters a demon. I pretty much have a basic version done but was wondering how to format a while loop so that the user keeps attacking until they or the enemy runs out of health. When I run the program I don't get any errors, it successfully randomizes critical attacks, regular attacks, and other stuff. If someone could help me understand how to make a while loop that keeps the attacks going. Any help would be appreciated, thanks!
import random
DemonOne = 0
DemonTwo = 1
DemonThree = 2
#DemonOneStats
DemonOneHealth = 25
DemonOnePower = 25
DemonOneLuck = 250
DemonOneLuckDisplayed = DemonOneLuck/10
DemonOneArmour = 10
DemonOneAttack = DemonOnePower/4
DemonOneAttackCalc = (DemonOneLuck/25) - 1
#DemonTwoStats
DemonTwoHealth = 50
DemonTwoPower = 50
DemonTwoLuck = 100
DemonTwoLuckDisplayed = DemonTwoLuck/2
DemonTwoArmour = 25
#DemonThreeStats
DemonThreeHealth = 100
DemonThreePower = 100
DemonThreeLuck = 50
DemonThreeLuckDisplayed = DemonThreeLuck * 2
DemonThreeArmour = 100
#UserStats
BaseHealth = 100
BaseLuck = 100
BaseLuckDisplayed = BaseLuck/2
BasePower = 100
Armour = 0
BaseAttack = BasePower/4
#FirstAttack
FirstAttackCalc = (BaseLuck/25) - 1
def stats():
print("Health: " + str(BaseHealth), "Luck: " + str(BaseLuckDisplayed), "Power: " + str(BasePower), "Armour: " + str(Armour), "Weapon(s) equipped: " )
def DemonOneStats():
print("The demon's stats are: Health- "+str(DemonOneHealth),"Luck- "+str(DemonOneLuckDisplayed), "Power- "+str(DemonOnePower), "Armour- " +str(DemonOneArmour))
def DemonTwoStats():
print("The demon's stats are: Health- "+str(DemonTwoHealth),"Luck- "+str(DemonTwoLuckDisplayed), "Power- "+str(DemonTwoPower), "Armour- " +str(DemonTwoArmour))
def DemonThreeStats():
print("The demon's stats are: Health- "+str(DemonThreeHealth),"Luck- "+str(DemonThreeLuckDisplayed), "Power- "+str(DemonThreePower), "Armour- " +str(DemonThreeArmour))
DemonChooser = random.randint(0,2)
FirstAttack = random.randint(0,FirstAttackCalc)
DemonOneCritical = random.randint(0,DemonOneAttackCalc)
#DemonOneFightLoop
if DemonChooser == 0:
DemonOneStats()
#while DemonOneHealth <= 0 or BaseHealth <= 0 is True:
if FirstAttack != 0:
DemonOneHealth = DemonOneHealth - BaseAttack
print("You attack the demon first:")
DemonOneStats()
if FirstAttack == 2:
DemonOneHealth = DemonOneHealth - BaseAttack
print("You caught the enemy off guard! Critical hit!")
DemonOneStats()
elif FirstAttack == 0:
BaseHealth = BaseHealth - DemonOneAttack
print("You were unlucky and the demon attacked you first:")
stats()
if DemonOneCritical == 0:
BaseHealth = BaseHealth - DemonOneAttack
print("You were caught off guard by the demon! Critical hit!")
stats()
elif DemonChooser == 1:
DemonTwoStats()
elif DemonChooser == 2:
DemonThreeStats()
