public GameSerializer(Game game)
 {
     Guid  = game.Guid;
     White = game.White.Guid;
     Black = game.Black.Guid;
     WhiteStartingScore = game.WhiteStartingScore;
     BlackStartingScore = game.BlackStartingScore;
     TimePlayed         = game.TimePlayed;
     Winner             = game.Winner;
 }
        public GameSerializer(SerializationInfo info, StreamingContext context)
        {
            Guid  = (Guid)info.GetValue("Guid", typeof(Guid));
            White = (Guid)info.GetValue("White", typeof(Guid));
            Black = (Guid)info.GetValue("Black", typeof(Guid));
            WhiteStartingScore = (int)info.GetValue("WhiteScore", typeof(int));
            BlackStartingScore = (int)info.GetValue("BlackScore", typeof(int));
            string timePlayed = (string)info.GetValue("TimePlayed", typeof(string));

            TimePlayed = Convert.ToDateTime(timePlayed);
            Winner     = (GameWinState)info.GetValue("Winner", typeof(GameWinState));
        }
Exemple #3
0
 private Game(Player white, Player black, GameWinState winner, Guid?guid = null, int?whiteStartScore = null, int?blackStartScore = null, DateTime?timePlayed = null)
 {
     this.White  = white;
     this.Black  = black;
     this.Winner = winner;
     if (guid.HasValue)
     {
         this.Guid = guid.Value;
     }
     else
     {
         this.Guid = Guid.NewGuid();
     }
     if (whiteStartScore.HasValue)
     {
         this.WhiteStartingScore = whiteStartScore.Value;
     }
     else
     {
         this.WhiteStartingScore = white.Score;
     }
     if (blackStartScore.HasValue)
     {
         this.BlackStartingScore = blackStartScore.Value;
     }
     else
     {
         this.BlackStartingScore = black.Score;
     }
     if (timePlayed.HasValue)
     {
         this.TimePlayed = timePlayed.Value;
     }
     else
     {
         this.TimePlayed = DateTime.Now;
     }
 }
Exemple #4
0
 public static Game CreateExistingGame(Player white, Player black, GameWinState winner, Guid guid, int whiteStartScore, int blackStartScore, DateTime timePlayed)
 {
     return(new Game(white, black, winner, guid, whiteStartScore, blackStartScore, timePlayed));
 }
Exemple #5
0
 public static Game CreateNewGame(Player white, Player black, GameWinState winner)
 {
     return(new Game(white, black, winner));
 }