示例#1
0
        public object Put()
        {
            var chessBoard = new ChessBoard();
            (new TraditionalBoardStager()).Stage(chessBoard);

            var chessGame = new ChessGame(
                chessBoard,
                PlayerTypeEnum.White,
                new Dictionary<PlayerTypeEnum, List<ChessPiece>>());

            var id = Guid.NewGuid();
            m_chessGameRepo.Put(id, chessGame);

            return new
            {
                _id = id,
                _turn = ((char)chessGame.PlayerTurn),
                _taken = new
                {
                    w = chessGame.GetTakenPiecesByPlayer(PlayerTypeEnum.White).Select(x => (char)x.Type),
                    b = chessGame.GetTakenPiecesByPlayer(PlayerTypeEnum.Black).Select(x => (char)x.Type),
                },
                _state = chessBoard.GetBoardAsListOfString(),
                _history = chessGame.GetMoves(),
                _moves = new PotentialMoveService().GetPotentialMoves(chessGame, chessGame.PlayerTurn),
            };
        }