Exemplo n.º 1
0
        public Game FromSavedGame(SavedGame savedGame)
        {
            if (savedGame == null)
            {
                throw new ArgumentException(nameof(savedGame));
            }

            _boardLength     = savedGame.Board.Length;
            _emptySymbolChar = FindEmptySymbolChar(savedGame);
            _symbolLookup    = CreateSymbolLookup(savedGame);

            if (!IsValidSaveGame(savedGame))
            {
                throw new ArgumentException("Invalid Save Game");
            }

            return(CreateGame(savedGame));
        }
Exemplo n.º 2
0
 private static char FindEmptySymbolChar(SavedGame savedGame)
 {
     return(savedGame.Board.SelectMany(r => r).FirstOrDefault(s => s != savedGame.Player1Symbol && s != savedGame.Player2Symbol));
 }