Structuring Game Design

Better formatted:

savepoint_dialogue = {
  "Room_1": [
    ["Monster Name", "D" (Condition, if monster dead in this case), "Dialogue"],
    ["Monster Name", "A" (Condition, if monster alive in this case), "Dialogue"]

The structure looks good to me. You can easily check what to do for a specific room.
However, it is best to replace some of the things with custom classes. (Also, you may want to refer to rooms using their coordinate position, e.g. (0,1) instead of a string.)

Here’s how the implementation might look like:

class MonsterInteraction: ...

savepoint_dialogue = {
  "Room_1": MonsterInteraction('bob', True, Dialogue("..."))
room = "Room_1"
if savepoint_dialogue[room].matches(game_state): ...

If your interactions first “axis”, or thing that it is sorted by, is rooms, then there is no need to worry about performance since there are few interactions per room. Because of this, it is probably best to not worry about fancy sets and groups, and just check each interaction one by one until there is a match.
The main thing you have to decide is how each monster interaction will be parameterized, customized.

1 Like

That makes sense. It does make me wonder though. Since I’m controlling loading dialogue and such from the game controller, not the config file, it feels like it would be kinda weird to import/reference classes inside the parameters. I’m also not completely sure what the .matches(game_state) is supposed to do :sweat_smile: , as the game state keeps track of things such as whether you’re in battle or not. My current idea of calling upon (savepoint dialogue for example) is just checking it when saving…

def save():
    if check_condition(config.savepoint_dialogue[current_room][0]):
    elif check_condition(config.savepoint_dialogue[current_room][1]):

That’s not really a good system for right now, it’s just a demo I wrote in like 20 seconds. But you get the idea…

Oh yeah, I also started updating the dicts and stuff in the way you suggested (track_data dictionary only contains info that actually needs to be saved for example)

Yeah, basically:

def save():
  for interaction in config.savepoint_dialogue[current_room]:
    if self.check_condition(interaction):

Just follow Object Oriented Programming, each interaction instance has the conditions, and the behavior to be executed. Your game controller should ‘know about’ the interactions but the interactions should not know about the game controller. Looks great.

For your track_data, I forget where I suggested that. But I would highly recommend using the types.SimpleNamespace class for it.

Also, you seem to like using Literal strings for a lot of things. This is error prone and may become hard to remember, and the code intelligence won’t be able to help you. Alternatives include integers, tuples, and Enums (for a distinct, finite set of values). Or use an actual class.

I don’t have enough experience with types.SimpleNamespace to really utilize it well :slight_smile:
Thank you for all your help so far though! Time to start implementing basic outlines of features (Then spend the next 100 years planning storyline lol)

1 Like

It looks like you are making a lot of progress so far.

Remember, you should always be looking to learn more tools and things, so that development is easy.
A quick rundown of types.SimpleNamspace, it is like a dict but you assign attributes with names instead of assigning values with keys:

from types import SimpleNamespace
my_data = SimpleNamespace(deaths=2)  # my_data = {'deaths': 2}
my_data.deaths = 4  # my_data['deaths'] = 4
my_data.asdf = '...'
del my_data.deaths
print(my_data.asdf)  # print(my_data['asdf'])

This is kind of motivating me to work more on my own game.
Right now, I have a bunch of very convenient systems set up, but there’s nothing playable.

Glad this helps you out too then! I’ll work on implementing it when I have a spare 20 minutes!