When you add support for multiple players, multiple gamestates, multiple dungeons, multiple levels within a dungeon, and multiple start/stop models, things get tricky. I’m closing on the list of scenarios and the file structure necessary to support it; implementing it’s going to take a little longer…
Here’s the structure and set of data that we’ll store for saved/paused games:
|File and location||Contents|
|/Players.data||List of all valid player guids.
Current player guid
|/<playerguid>/playerinfo.data||Name, class, race, stats, level, current location (enum: worldmap or dungeonId+state (current level + turnnumber))|
|/<playerguid>/dungeon/level-1.data||cells, actors, etc|
|/<playerguid>/dungeon/level-2.data||cells, actors, etc|
|/<playerguid>/dungeon/level-3.data||cells, actors, etc|
Rationale/drivers for that model:
- Unlike some roguelikes, there can be multiple active players that the user can choose to play at any point in time. This necessitates the players.data file as well as the /playerguid/ subdirectories. I use guids here because I don’t want to worry about duplicate naming.
- There is a ‘last played’ player – this is necessary to support (a) tombstoning <when the user comes back, which player do you restore? A: the one they last played>, and (b) “continue” functionality on the mainmenu.
- Once a player enters a dungeon, they’re in it until they die, win, or exit (ascend to level 0). Given that, there’s no need to have multiple dungeon subfolders for a particular playerguid – one will suffice.
- Within a dungeon, we want to persist the contents of levels so that the player can ascend to a previous level and it’s the same as they left it. This necessitates the level-1.data, level-2.data, etc files.
There are a set of scenarios which drive the above model. I believe the following encapsulates all possible load/save scenarios on WP7 and Windows (And I’m assuming Xbox’ll map to one or the other):
- Enter dungeon for first time
- Exit (ascend to level 0) or win a dungeon
- Player dies
- Ascend or descend (to an existing) level within a dungeon (but not to the exit)
- Descend to a new (not yet visited) level within a dungeon (but not to the exit)
- WP7: Pause within a dungeon and resume (tombstone/detombstone)
- WP7: Pause within a dungeon and re-launch (tomstone/fresh-launch)
- WP7: Pause outside a dungeon (e.g. on worldmap or mainmenu) and resume
- WP7: Pause outside a dungeon (e.g. on worldmap or mainmenu) and re-launch
- Windows: Exit the game while inside a dungeon
- Windows: Exit the game while outside a dungeon (worldmap, mainmenu, …)
Next up: tying those scenarios to codepaths…