diff options
author | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
---|---|---|
committer | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
commit | ced3d03bdb3ce866d832e03fb212865140905a9a (patch) | |
tree | 2a16c2063a46d3c354ce1585029dda3124f6ad93 /V3/Data/Internal/SaveGame.cs | |
parent | 0394dccaf06e1009e591a6ff4d645895574724c1 (diff) | |
download | V3-release.tar.gz V3-release.tar.bz2 |
Diffstat (limited to 'V3/Data/Internal/SaveGame.cs')
-rw-r--r-- | V3/Data/Internal/SaveGame.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/V3/Data/Internal/SaveGame.cs b/V3/Data/Internal/SaveGame.cs new file mode 100644 index 0000000..9ff3586 --- /dev/null +++ b/V3/Data/Internal/SaveGame.cs @@ -0,0 +1,65 @@ +using System; + +namespace V3.Data.Internal +{ + // TODO: once the game state is getting larger, we have to separate the + // save game metadata from the game state. + + /// <summary> + /// A save game that has a timestamp and a title, and that can store + /// the game state. + /// </summary> + [Serializable] + public sealed class SaveGame : ISaveGame + { + /// <summary> + /// The creation time of this save game in local time. + /// </summary> + public DateTime Timestamp { get; set; } + + /// <summary> + /// The compability version of this save game. + /// </summary> + public int Version { get; set; } + + /// <summary> + /// The data stored in this save game. + /// </summary> + public GameState GameState { get; set; } + + /// <summary> + /// Empty constructor for serialization. + /// </summary> + private SaveGame() + { + } + + /// <summary> + /// Creates a new save game from the given data. + /// </summary> + /// <param name="timestamp">the creation time of the save game</param> + /// <param name="version">the compability version of the save game</param> + /// <param name="gameState">the game state to store in the save game</param> + internal SaveGame(DateTime timestamp, int version, GameState gameState) + { + Timestamp = timestamp; + Version = version; + GameState = gameState; + } + + /// <summary> + /// Compares this save game object to another save game object based + /// on the creation time. + /// </summary> + /// <param name="saveGame">the save game to compare this save game + /// with</param> + /// <returns>a value less than zero if this save game has been saved + /// before the given save game, zero if they have been saved at the + /// same time and a value greater than zero if the given save game has + /// been saved before the given one</returns> + public int CompareTo(ISaveGame saveGame) + { + return Timestamp.CompareTo(saveGame.Timestamp); + } + } +} |