From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/Data/Internal/SaveGame.cs | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 V3/Data/Internal/SaveGame.cs (limited to 'V3/Data/Internal/SaveGame.cs') 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. + + /// + /// A save game that has a timestamp and a title, and that can store + /// the game state. + /// + [Serializable] + public sealed class SaveGame : ISaveGame + { + /// + /// The creation time of this save game in local time. + /// + public DateTime Timestamp { get; set; } + + /// + /// The compability version of this save game. + /// + public int Version { get; set; } + + /// + /// The data stored in this save game. + /// + public GameState GameState { get; set; } + + /// + /// Empty constructor for serialization. + /// + private SaveGame() + { + } + + /// + /// Creates a new save game from the given data. + /// + /// the creation time of the save game + /// the compability version of the save game + /// the game state to store in the save game + internal SaveGame(DateTime timestamp, int version, GameState gameState) + { + Timestamp = timestamp; + Version = version; + GameState = gameState; + } + + /// + /// Compares this save game object to another save game object based + /// on the creation time. + /// + /// the save game to compare this save game + /// with + /// 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 + public int CompareTo(ISaveGame saveGame) + { + return Timestamp.CompareTo(saveGame.Timestamp); + } + } +} -- cgit v1.2.1