Let the Monster Attack
00:00 Okay, we’ve got a working game, but so far, it’s very unfair because the monster can’t even attack yet. So let’s tackle this next task that after the player, the monster also gets a chance to attack.
This ends the player’s turn. They either select
"R", and now after their turn, if the monster is still alive, it deals between
20 damage to the player. So this is, again, I’m going to use the
random module to calculate the damage, and it’s going to be damaged to the player.
So you need to indent this to keep it inside of the
while loop. If the monster is still alive is basically my first check, so I’m going to say
if monster_health > 0: that means the monster is still alive, and then it gets a chance to attack. And then we need to calculate the damage, so let’s call this one
Similar to what we did up here when the player attacks, now we have also give the monster a chance to attack.
-= monster_damage. Then let’s also print out the
player_health to make sure that this is working as expected. Yeah, let’s give it a go.
Do you want to attack, heal, or run away? I want to attack, and you see, my option is attack. The monster’s health is at
135, and the monster attacked the player as well. So my health went down to
81. I can attack again.
02:25 And still this value shouldn’t be— Also, I’m a little confused now because I don’t really see what I’m printing out, right? You see, I’m. like. kind of struggling to correctly interpret what these things are, so I would say this is high time to make the output a little bit more understandable.
Become a Member to join the conversation.