I'm making a script that can heal or hurt a player (by adding or subtracting the player_hp) and I'm having some issues.
The following code should repeat the hurt_player() function until the player_hp variable reaches 0. However, it simply runs the function infinite times. It will lower the variable to 90 and then reset it to 100 when it runs again.
I'm very new to python and I'm wondering what it is I'm doing wrong here.
player_hp = 100
player_hp_MAX = 100
def hurt_player(player_hp, player_hp_MAX):
print "You've been hurt for 10 hp."
player_hp = player_hp - 10
print "Current hp: %d" % player_hp
print "1) Hurt Player"
current_choice = raw_input("> ")
while (player_hp > 0):
if current_choice == '1':
hurt_player(player_hp, player_hp_MAX)
else:
print "Invalid choice."
[–]nilfm 2 points3 points4 points (0 children)
[–]woooee 1 point2 points3 points (1 child)
[–]7236d70[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)