Build a Text-Based RPG (Exercise)
00:00 All right, at this point, I can see you’re all trained up and ready for a big challenge. So here it is, your final challenge for this course: Build a Text-Based Role-Playing Game. It has the following features.
00:12
The game involves one player and one monster. The player begins with 100
health, while the monster starts with 150
health. Seems like it’s a pretty big monster.
00:22
The player has the option to attack, heal, or run away. If the player attacks, they deal between 10
and 15
damage to the monster. If the player heals, they regain 30
health, but that can’t go over their maximum of 100
.
00:34
If the player runs away, then the game ends. And after the player’s turn—that is, if the monster is still alive—then it deals between 15
and 20
damage to the player, and the game keeps going.
00:45
So, it continues until the health of either the player or the monster reaches 0
or until the player decides to run away. So, this is your main challenge.
00:54
This is going to be a lot of conditional expressions, as you can already see with some of these bullet points start with if
, right? And you have to put some game logic into it to actually make this game work.
01:05 You’ll have to use loops, you’ll have to use loop keywords to maybe break out somewhere or continue in another place, et cetera, et cetera. This challenge is going to bring together all the things that you’ve trained in the course up to now. So if you get stuck somewhere, maybe just look back at the previous lesson and then refresh one of those concepts that you’ve trained there. Okay?
01:26 And then there’s going to be some stretch goals, right? Prevent the player from exiting the game when they press Ctrl + C. So there’s a specific error that Python raises if you press this keyboard combination, and you can do something with that error instead of making the program end.
01:41
Then you can introduce double-damage critical hits when an attack value either of the player or the monster is a multiple of 3
. And you can also, of course, make the game pretty by using emojis or some string formatting syntax to make the flow of the text that gets printed to the console a little bit nicer.
01:58 Those are your stretch goals. And before, you saw the main characteristics that the game should fulfill. This is a big challenge, and just as before, I’m going ask you now to wait before watching the next lessons because the best way to practice all the concepts that you’ve learned is to try it out yourself.
02:15 So, give it a go. Try to tackle this challenge and write this game. I hope you have fun while doing it. And then when you’re ready, you can move on to the next lessons, where I’ll show you an example of how you could solve this challenge and build this game.
Become a Member to join the conversation.