private Game GetChessGame(long id)
        {
            var game = UnitOfWork.Find<Game>(id);

            if (game == null)
                throw new ArgumentException(String.Format("Game {0} does not exist.", id));

            var pieceCaster = new PieceCaster();

            foreach (var square in game.Squares.Where(s => s.ChessPiece != null))
            {
                square.ChessPiece = pieceCaster.MapPiece(square.ChessPiece);
            }

            return game;
        }
Esempio n. 2
0
        private static Square[][] GetMockSquares(IEnumerable<Square[]> board)
        {
            var mocks = new List<Square[]>();
            var pieceCaster = new PieceCaster();

            foreach (var row in board)
            {
                var mockRow = new List<Square>();
                foreach (var square in row)
                {
                    var newPiece = square.ChessPiece == null ? null : pieceCaster.MapPiece(square.ChessPiece);
                    mockRow.Add(new Square()
                    {
                        ChessPiece = newPiece,
                        Column = square.Column,
                        Row = square.Row,
                    });
                }
                mocks.Add(mockRow.ToArray());
            }

            return mocks.ToArray();
        }