コード例 #1
0
        public JsonResult StartGame(PraetorianGameState playerSideChoosen)
        {
            var jResult = new JsonResult();
            if(playerSideChoosen == PraetorianGameState.ASSASSINTURN)
            {
                //Human needs to make the first move, so set the game state and return out
                _Board.IsAssassinComputer = false;
                _Board.IsLegalMove = true;
                _Board.GameState = PraetorianGameState.ASSASSINTURN;
                PraetorianBoard.ComputerState = PraetorianGameState.PRAETORIANTURN;
            }
            else
            {
                _Board.IsAssassinComputer = true;
                PraetorianBoard.ComputerState = PraetorianGameState.ASSASSINTURN;
                PraetorianGameSetup pGame = new PraetorianGameSetup(_Board.Pieces.ToList(), new KeyValuePair<int, PraetorianPieceViewModel>(0, new PraetorianPieceViewModel() { }));
                var newBoard = pGame.ComputerMakeMove(GAMEDEPTH, true);
                _LastMove = new KeyValuePair<int, PraetorianPieceViewModel>(_iMoveNumber++, GetLastMovedPieceFromComputer(newBoard.BoardPieces, _Board.Pieces.ToList()));
                _MasterMoveList.Add(_LastMove);
                _Board.Pieces = newBoard.BoardPieces;
                _Board.GameState = PraetorianGameState.PRAETORIANTURN;
                _Board.IsLegalMove = true;
            }

            jResult = Json(_Board);
            return jResult;
        }
コード例 #2
0
        public JsonResult ComputerMove(PraetorianGameState playerSideChoosen)
        {
            var jResult = new JsonResult();

            PraetorianGameSetup pGame = new PraetorianGameSetup(_Board.Pieces.ToList(), _MasterMoveList[_MasterMoveList.Count - 1]);
            if (playerSideChoosen == PraetorianGameState.ASSASSINTURN)
            {
                var newBoard = pGame.ComputerMakeMove(GAMEDEPTH, false);
                _iMoveNumber++;
                var movePiece = GetLastMovedPieceFromComputer(newBoard.BoardPieces, _Board.Pieces.ToList());
                _LastMove = new KeyValuePair<int, PraetorianPieceViewModel>(_iMoveNumber, movePiece);
                _MasterMoveList.Add(_LastMove);
                _Board.Pieces = newBoard.BoardPieces.OrderBy(o => o.Index);
                _Board.GameState = PraetorianGameState.ASSASSINTURN;
                _Board.IsLegalMove = true;
            }
            else
            {
                var newBoard = pGame.ComputerMakeMove(GAMEDEPTH, true);
                _iMoveNumber++;
                var movePiece = GetLastMovedPieceFromComputer(newBoard.BoardPieces, _Board.Pieces.ToList());
                _LastMove = new KeyValuePair<int, PraetorianPieceViewModel>(_iMoveNumber, movePiece);
                _MasterMoveList.Add(_LastMove);
                _Board.Pieces = newBoard.BoardPieces.OrderBy(o => o.Index);
                _Board.GameState = PraetorianGameState.PRAETORIANTURN;
                _Board.IsLegalMove = true;
            }

             jResult = Json(_Board);
            return jResult;
        }