Hey ya'll I'm brand new to python/programming and have been doing some online courses. I decided to take the day off of taking notes and such and try to challenge myself with some random while loops that simulate different things in dnd. I'm currently stuck on my simulated combat, and I know I'm on the right track but obviously it's not working. Some pointers would be much appreciated.
import random
monster_hp = 25
strength = 5
ac = 17
hp = 25
combat = True
current_hp = monster_hp
dmg = 0
hit = False
def roll_to_hit(hit, ac):
hit = random.randint(1, 20)
return hit
if hit >= ac:
return True
# print(roll_to_hit(hit))
def roll_4_dmg(dmg, strength):
dmg = random.randint(1, 10) + strength
return dmg
print(f"You hit and did {dmg} damage.")
# print(roll_4_dmg())
def damage(current_hp, monster_hp, dmg):
current_hp = monster_hp - dmg
return current_hp
# print(damage())
while combat:
if current_hp > 0:
inp = input(r"A monster has appeared what will you do? ").lower()
if inp == "attack":
roll_to_hit(hit, ac)
if True:
roll_4_dmg(dmg, strength)
damage(current_hp, monster_hp, dmg)
else:
print("You missed!")
inp = input(
r"A monster has appeared what will you do? ").lower()
else:
print("You have slain the beast!")
break
Aucun commentaire:
Enregistrer un commentaire