//Eat

        public static bool FirstMovementToEat(Input input, Board board)
        {
            if (ValidationInput.IsValidInput(input, board) == false)
            {
                return(false);
            }

            var move_Pawn_X = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Width, input.EndPoint.Width);
            var move_Pawn_Y = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Height, input.EndPoint.Height);

            //Represents The Tile Before The Pawn It Wants To Eat
            var movingInput = CreateMovingInput(input, move_Pawn_X, move_Pawn_Y);

            //Move King Until It Reaches To The Pawn It Wants To Eat
            if (CheckDiagonal(movingInput, board, move_Pawn_X, move_Pawn_Y) == false)
            {
                return(false);
            }

            //Position Of The Pawn That Will be Eaten
            movingInput.EndPoint.Width  += move_Pawn_X;
            movingInput.EndPoint.Height += move_Pawn_Y;

            //Is There A Pawn In This Tile?
            if (board.Tiles[movingInput.EndPoint.Height, movingInput.EndPoint.Width] == null)
            {
                return(false);
            }

            //Checking If the Pawn We Want To Eat isn't the same color!!
            return(board.Tiles[movingInput.EndPoint.Height, movingInput.EndPoint.Width].Color != board.CurrentTurn);
        }
        //Move
        public static bool CheckMove(Input input, Board board)
        {
            if (ValidationInput.IsValidInput(input, board) == false)
            {
                return(false);
            }

            var _move_Pawn_X = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Width, input.EndPoint.Width);
            var _move_Pawn_Y = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Height, input.EndPoint.Height);

            return(CheckDiagonal(input, board, _move_Pawn_X, _move_Pawn_Y));
        }
Esempio n. 3
0
        public static bool CheckMove(Input input, Board board)
        {
            if (ValidationInput.IsValidInput(input, board) == false)
            {
                return(false);
            }

            if (input.EndPoint.Width != input.StartingPoint.Width +
                PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Width, input.EndPoint.Width))
            {
                return(false);
            }

            if (input.EndPoint.Height != input.StartingPoint.Height +
                PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Height, input.EndPoint.Height))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public static bool FirstMovementToEat(Input input, Board board)
        {
            if (ValidationInput.IsValidInput(input, board) == false)
            {
                return(false);
            }

            var _moveX = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Width, input.EndPoint.Width);
            var _moveY = PawnActionUtillities.CreateDirectionToMove(input.StartingPoint.Height, input.EndPoint.Height);

            //It Can Only Move 2 Tiles if it Wants To Eat!!!!

            //Position of the Pawn that will be Eaten
            var _width  = input.StartingPoint.Width + _moveX;
            var _height = input.StartingPoint.Height + _moveY;

            //Checking If there is a Pawn in the Tile
            if (board.Tiles[_height, _width] == null)
            {
                return(false);
            }

            //Checking If the Pawn's color is different
            if (board.Tiles[_height, _width].Color == board.CurrentTurn)
            {
                return(false);
            }

            _width  += _moveX;
            _height += _moveY;

            if (board.Tiles[_height, _width] != null)
            {
                return(false);
            }

            return(_width == input.EndPoint.Width && _height == input.EndPoint.Height);
        }