Maps and saving


I have previously described the system of having the configuration in a separate location rather than baked into the game. All maps/battles are essentially json configuration files which contain all of the map details – terrain, units, win conditions etc. These are ready made structured files which contain the initial snapshot of the game.

When a player plays a map, obviously that state changes. However, the state at any given point will always be in the same structure as the initial game map mode as all options are available on the initial map config (it is possible for example to start a map and already have a unit that has been marked as having done an action so that it may have slightly less actions available on the first turn). Therefore, the save system for the current state is a trivial process as it effectively does the opposite of the loading system. The game state is serialised back into the json format. Easy!

However, that is not the end of the story. How does the base entity config work? How does the AI config work? It is feasible to just copy all of that into the map files but that would be a lot of duplicate data with multiple save files and just seems so inefficient. Therefore, an additional section for the ‘environment’ is also added to the safe file. This effectively points to all of the additional files which need to be loaded in. Now it is possible for the configuration of the other files to change if someone alters the base config on github. Therefore some features of the game map could technically change after a save/load – AI could change or parameters of how entities work etc. However, I feel that changes would mostly be related to ‘balancing’ once a game mode is in production that this is a reasonable trade off rather than having loads of duplicate nearly identical config.

An environment section which details the additional files that are required for the map to load looks something like this:

"Environment": {
    "ENTITY_TYPE_CONFIG_FOLDER": "config/hacktics/version1/entities/types",
    "ENTITY_TAG_CONFIG_FOLDER": "config/hacktics/version1/entities/tags",
    "ENTITY_DEFAULTS_FILE": "config/hacktics/version1/entities/entityDefaults.json",
    "AI_CONFIG_FILE": "config/hacktics/version1/ai/aiConfig.json",
    "AI_CONFIG_DEFAULTS_FILE": "config/hacktics/version1/ai/aiConfigDefaults.json",
    "GAME_CONFIG_FILE": "globals/gameConfig.json",
    "MAP_SET_KEY": "hacktics/version1"
}

Leave a Reply

Your email address will not be published. Required fields are marked *