Open EmbeddedMan opened 3 years ago
This could get really interesting - you could remember if you have doors open or closed, if you've turned lights on, etc.
There's probably a better way to do this than what I'm about to suggest but here goes:
To avoid polluting global namespace with variables, we could have a single object (maybe a handful of objects?) each with key value pairs that can be updated as player makes choices.
For example we could have a global object called player:
player = { "tipsy" = False, "item" = "none", "wounded" = False }
I keep calling them objects but they are dictionaries in python. They are mutable and you can access the property values through dot notation or bracket notation.
e.g.,
player.tipsy = True player[item] = "needle-nosed pliers
Then maybe there could be a "house" dictionary as well to track things like lights, doors, occupants, etc.
For example, if you "do something" in a room (like use the soldering iron in Schmalz Haus) then remember that so that if you come back to that room your options are different.
So, how to create global game state and keep it around between rooms? That's for you to figure out!