Pass 1

Step by step

I want to write this code step by step simulating a little the way I would write it if I were writing it from scratch. So not just copy it from top to bottom, instead I will start with a minimum working version and then make it grow from there.

What I'm thinking is: start with the first room and the character and the functions I might need to just make that work, like the main function and main loop; so I can run a bare-bones version of the game even if it doesn't do anything at first, then step by step add more rooms, more functionality and aesthetics.

I know it is still somewhat artificial because I'm only copying part by part, except I'm not doing it linearly.But helps me see more clearly not just what the "end product" looks like in the end, how it works and and the process of how it's built.

1

Initially I only need about 50 lines to run the bare bones program, including:

Obviously, when you run it like this not much happens, it just displays the room info. But that's the point.

2

I want to add now a basic game loop where it displays the player stats and waits for an input before printing it again, instead of just running the program and exiting. So all I need to do is:

Now I can run the game loop and press Enter and that's it.

3

For the next step I'll continue with next few lines in the while loop and see what else they connect to.

4

In step 4 I will add the movement and complete the map (the rooms dictionary)

5

In step 4 I'll add the fight functionality and the goblin battle

6

Finally, add the end-game functionality and final decorations.

Ideas

I have a few ideas that I might add to the game, I'll leave them here as a "challenge" for the near future:

  1. add more rooms
  2. add music - check if mpv is installed, if yes, then play on background some spooky sounding soundrack in a loop
  3. add more items
  4. add a graphical map that you can print with a command and see which rooms you have explored
  5. add some conditionals to the battle: if has sword, deals more damage than if has only torch; if has shield, recieves less damage.
  6. fix the fight sequence, make sure it warns first about "something guards them" and then the fight, otherwise the fight happens before you get the description. Makes no sense.
  7. Modify take_item() function so that it detects a subset of the name, so you can type take key instead of take rusty_key.