Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python (retired) Hack-n-Slash Finishing The Game

elmira bonab
elmira bonab
3,471 Points

Is the player choice for attacking redundant in the player_turn method

I don't understand the functionality of self.player.attack() in the player_trun method in the game.py . It seems the user's choice does not affect the result of player's attack.

Thanks.

1 Answer

This is within the player choice function so that you can choose to attack, rest, or quit. I believe the attack function returns an attack score if the random integer is above 4, meaning that the attack is only successful if the "roll" of the random number is greater than 4. Otherwise it won't be a successful attack. Add to that that if you have a successful attack score, the monster can still dodge the attack.

Hopefully that helps!