jdmonin / JSettlers2

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 .
http://nand.net/jsettlers/
GNU General Public License v3.0
157 stars 63 forks source link

savegame for testing: overall design, implement framework #65

Closed jdmonin closed 4 years ago

jdmonin commented 4 years ago

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:

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:

jdmonin commented 4 years ago

Design validated, framework and basic load/save committed and tested (see #66).

jdmonin commented 4 years ago

Load/save/resume (#66) has been documented, implemented, tested, localized.