Пример #1
0
        private static bool isSimpleMovePossible(Player i_Player, Board i_Board, Move i_Move)
        {
            bool  isPossible  = false;
            Piece movingPiece = i_Board.GameBoard[i_Move.FromRow, i_Move.FromCol].CurrentPiece;

            if (movingPiece != null)
            {
                isPossible = isMoveSimpleDiagonalLine(i_Player.Side, i_Move);

                // if king- also check opposite direction
                if (movingPiece.IsKing)
                {
                    ePlayerSide oppositeSide = MoveValidator.GetOtherSide(i_Player.Side);
                    isPossible = isPossible || isMoveSimpleDiagonalLine(oppositeSide, i_Move);
                }
            }

            return(isPossible);
        }
Пример #2
0
        // Returns true if the given move is a capture move
        private bool checkCapture(Board i_Board, int i_Direction, Move i_Move)
        {
            // check if destinations is in board's borders
            if (MoveValidator.IsInBorders(i_Board, i_Move.ToRow, i_Move.ToCol))
            {
                Piece pieceToBeCaptured =
                    i_Board.GameBoard[(i_Move.FromRow + i_Move.ToRow) / 2, (i_Move.FromCol + i_Move.ToCol) / 2].CurrentPiece;
                // check destination is empty
                if (i_Board.GameBoard[i_Move.ToRow, i_Move.ToCol].CurrentPiece == null)
                {
                    if (pieceToBeCaptured != null)
                    {
                        if (pieceToBeCaptured.r_Side == MoveValidator.GetOtherSide(this.Side))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #3
0
        private bool checkKingCapture(Board i_Board, int i_Direction, Move i_Move)
        {
            bool captureMove = false;

            if (MoveValidator.IsInBorders(i_Board, i_Move.ToRow, i_Move.ToCol))
            {
                if (i_Board.GameBoard[i_Move.ToRow, i_Move.ToCol].CurrentPiece == null)
                {
                    if (i_Board.GameBoard[i_Move.FromRow + 1, i_Move.FromCol + i_Direction].CurrentPiece != null)
                    {
                        if (i_Board.GameBoard[i_Move.FromRow + 1, i_Move.FromCol + i_Direction].CurrentPiece.Side == MoveValidator.GetOtherSide(this.Side))
                        {
                            captureMove = true;
                        }
                    }
                }
            }

            return(captureMove);
        }