DEV Community

Jason
Jason

Posted on

My First Python Project was an RPG

My first actual project assignment in Python, or in any coding language for that matter, was to create a text-based RPG that could be played from the terminal. Exciting, right? What gamer doesn't love the thrill of reading dialog and exposition in lovely green on black? The exhilaration of single digit move choices? Seriously though, this was a lot of fun to work on. It gave me an opportunity to be a little creative while diving into some light game logic. Most importantly it showed me the reality of the trial and error (and error and error) process of coding. Overall, I'm satisfied with how it turned out and can't wait for the next one.

The concept of the game centers around a 'Mythical Hospital'. The player is a new doctor that is volunteering at a hospital for mythical creatures, in the hopes that they can earn enough money to pay off their student loan. The player creates their character and starts with a hefty debt. The doctor then begins to treat their 'patients'. Each mythical creature has an ailment and three options for treatment. The correct treatment is randomly assigned so it can be different every time they play it (assuming they would ever want to play it again). If the doctor guesses the correct treatment then the mythical creature gives them some money to pay off part of their student loan. If the doctor guesses the wrong treatment, they are given a second chance, and if they are wrong again the mythical creature gets upset and the doctor meets their demise and the game is over. If the doctor earns enough money to pay off their entire student loan then the player wins and the game is over.

The biggest challenge I had in creating this game was making sure that the game progressed from one function to the next and that all the variables carried over as they should. It was easy to get lost in loops or call a function out of order, especially when I was creating the replay option. I used a class to create all the creatures which gave each creature money, an ailment, treatment options, a dialog for the player winning, a dialog for the player losing, and later I added some ASCII art. I learned how to add all the class instances to a list to make it easier to display all the options and reference them from the player's input. This was also helpful in accomplishing my goal of not letting the player treat the same creature more than once. Once the player used that option, I simply removed it from the list. This created a challenge later because I had to figure out how to add these creatures back to the list if the player chose to play again.

I had a great time working on this project. It was satisfying to have an idea and then will it into existence with logic. The fact that it was a game also added an extra element of fun. Coming up with the creative content was a nice break from the logic stuff when my brain started hurting. I'd like to keep adding features and new content when I'm not working on other things.

You can check out the game at my github repository.

Top comments (0)