I want to make a program that will do some kind of battle logs. You strike with 50% chance of hitting the enemy and deal damage from 10 to 25.
from random import randint
hitChance = randint(0,1)
damage = 10 + randint(0, 15)
HP = 100
def atack():
global HP
if hitChance is 0:
print("Missed")
elif hitChance is 1:
HP -= damage
print(damage, " delt")
print(HP, " left")
while HP > 0:
atack()
print("You defeated the enemy!")
However when i run this code it either stuck in an infinite loop of "missed" or deals the same damage values.
Aucun commentaire:
Enregistrer un commentaire