2) More Data Types Lesson

Python Project: Adventure Game

4 min to complete · By Martin Breuss

Contents

  1. Introduction

In the previous module of this course, you built a text-based adventure game that allowed you to interact with a few rooms through your command line.

If you haven't built the first version of this project yet, then make sure to head back to the instructions in the previous module and give it a go! If you're already done, then great work building it out!

Equipped with a new diamond sword and a couple of additional data types, you're about to venture back into your text-based RPG to extend its functionality and make it more immersive.

Game Mechanics Update

The game will continue in the fashion of a classic text-based Dungeons and Dragons game. But, with the help of the additional data types you've gotten to know, you'll start giving the player more choices:

An open and a closed door - Photo by https://unsplash.com/@madze Kiyota Sage on Unsplash

Here are the tasks that you'll code up for this project. You'll read them below in a list form, and as a first step, you can again copy that content over into a new Python file as pseudocode:

  • Save the user input options you allow, e.g., in a set that you can check against when your user makes a choice.
  • Create an inventory for your player, where they can add and remove items.
  • Players should be able to collect items they find in rooms and add them to their inventory.
  • If they lose a fight against the dragon, then they should lose their inventory items.
  • Add more rooms to your game and allow your player to explore.
  • Some rooms can be empty, others can contain items, and yet others can contain an opponent.
  • Implement some logic that decides whether or not your player can beat the opponent depending on what items they have in their inventory
  • Use the random module to add a multiplier to your battles, similar to a dice roll in a real game. This pseudo-random element can have an effect on whether your player wins or loses when battling an opponent.

Once you've got a working version done, show it again to your friends and family and let them give it another spin. Feel free to share a link to your game on Discord.