I tried to make a simple combat system but it isn't working how I want it to. Eventually when I get near zero im stuck at number 4 usually. And what I want it to do is that if d_damage equals 0 to print out that the person won. Im mostly struggling on the damage for the opponent. I havent worked on the users health. But if someone could help I would dearly appreciate it.
Here is my code:
import random
import os
health = [ '100' ]
d_health = [ '100' ]
damage = random.randint(0, 7)
def clear():
os.system("cls")
def health_damage():
sum = int(d_health[0]) - damage
if sum > 0:
d_health.remove(d_health[0])
d_health.append(str(sum))
begin_game()
if int(d_health[0]) <= 0:
clear()
print( "You defeated the dragon!" )
def begin_game():
clear()
print( "Dragon Health: " + str(d_health[0]) + "")
print()
print( "Your Health: " + str(health[0]) )
x = input( "What do you wish to do?" )
if x.lower() == "1":
health_damage()
begin_game()
def before_game():
print( "Welcome to The Beginning: Fight to Survive" )
x = input( "Are you sure you want to fight?" )
if x.lower() == "yes":
clear()
begin_game()
before_game()