The second conditional is going to be to give the player a chance to heal and regain
30 health when they choose to do so. That’ll be another action that I’m going to chain on here by saying
elif if the action is not an
"A", but instead it’s going to be uppercase
"H", then I want the player to regain
30 health, but it shouldn’t go over a maximum of
100. This is not a random value.
This is why I’m going to put it up here with the first initialization. I’m going to say that
30. Every time the player heals, it’s going to be
30 points, and we don’t need to redefine that variable every time the action gets called.
+= heal. Those are at the
30. The problem here is going to be, this can still exceed the maximum of
100 for now. Let’s give it a go actually. If I run this, you can see that if I now press
H for heal, well, I’ve also got to print out what the
player_health is to see anything.
is bigger than
100, then we’re just going to reset it to
100. I’m going to say
player_health = 100, so that means that it’s going to heal anything up to
100, and if it goes over
100, this small conditional here triggers the intended code block and resets the
Become a Member to join the conversation.