Java Settlers project home, downloads, and GPLv3 source code. To download the latest version as a JAR, see https://github.com/jdmonin/JSettlers2/releases/latest .
Goal: To help with testing, the server can save a game and board's state to a file
and load it later, using debug commands.
This ticket covers the overall design, and the rough draft of a framework to be fully implemented by other tickets.
Feature branch: feat/savegame
Usage/UI might be something like:
Set value of a server property to point to the game-saves directory
Start a game, place pieces as needed, etc
Debug command to save a snapshot: *SAVEGAME* mygamename
Debug command to load a snapshot: *LOADGAME* mygamename
Server can parse the snapshot and create a game with its contents. Bots can be asked to join. (Maybe optionally require certain types of bots?) Temporarily set gamestate to a new hold/pause state, so current player won't take action until everyone has joined
Debug command to resume play of loaded game: Maybe *RESUMEGAME* or *CONTINUEGAME*
The saved-game snapshot file:
Snapshot content would include game options, gameState, board layout, minimum version, and each player's pieces, dev cards, resource counts, etc. Players' names should probably also be included. Might want to save bot classes and smarter/faster flag or other parameters, but optionally not enforce as constraints when resuming play.
A transparent format like JSON probably makes the most sense (future-proofing, hand-editing, possibly later adding to a repo as test cases). One commonly-used JSON library is GSON, which is already used by the v3 branch by protobuf-java-util.
A dedicated savegame model class probably makes more sense than trying to serialize SOCBoard or SOCGame. Might be able to extract some board data structures by leveraging SOCGameHandler.getBoardLayoutMessage or similar existing joingame/startgame code.
Misc notes:
To simplify things and prevent corner cases, don't allow save during initial placement
Server config prop must designate a directory
Optional json-library jar (GSON?) must be on classpath or same dir as server
If json jar can't be loaded, server should degrade gently and run normally, as if the prop isn't set; savegames won't be used
Use a default filename extension/suffix; should probably limit save-game filename's allowed characters for security
Currently, debug commands can be typed only into a game window, but *LOADGAME* creates and joins a new game. At some point later, might want a better place in the UI to do so
Goal: To help with testing, the server can save a game and board's state to a file and load it later, using debug commands.
This ticket covers the overall design, and the rough draft of a framework to be fully implemented by other tickets.
Feature branch: feat/savegame
Usage/UI might be something like:
Server can parse the snapshot and create a game with its contents. Bots can be asked to join. (Maybe optionally require certain types of bots?) Temporarily set gamestate to a new hold/pause state, so current player won't take action until everyone has joined
The saved-game snapshot file:
Snapshot content would include game options, gameState, board layout, minimum version, and each player's pieces, dev cards, resource counts, etc. Players' names should probably also be included. Might want to save bot classes and smarter/faster flag or other parameters, but optionally not enforce as constraints when resuming play.
A transparent format like JSON probably makes the most sense (future-proofing, hand-editing, possibly later adding to a repo as test cases). One commonly-used JSON library is GSON, which is already used by the v3 branch by protobuf-java-util.
A dedicated savegame model class probably makes more sense than trying to serialize SOCBoard or SOCGame. Might be able to extract some board data structures by leveraging SOCGameHandler.getBoardLayoutMessage or similar existing joingame/startgame code.
Misc notes: