Exemplo n.º 1
0
        private PieceMove findSpecificEatingMoves(GamePiece i_Piece, Player.eDirection i_VerticalDirection, Player.eDirection i_HorizontalDirection)
        {
            PieceMove eatingMove    = null;
            int       pieceToEatRow = i_Piece.Location.Y + (int)i_VerticalDirection;
            int       pieceToEatCol = i_Piece.Location.X + (int)i_HorizontalDirection;

            if (isCoordinateInBoard(pieceToEatRow, pieceToEatCol))
            {
                Player leftSquareOwner = getSquareOwnership(pieceToEatRow, pieceToEatCol);
                if (leftSquareOwner != null && leftSquareOwner != i_Piece.Owner)
                {
                    int squareToJumpToRow = pieceToEatRow + (int)i_VerticalDirection;
                    int squareToJumpToCol = pieceToEatCol + (int)i_HorizontalDirection;
                    if (isCoordinateInBoard(squareToJumpToRow, squareToJumpToCol))
                    {
                        if (getSquareOwnership(squareToJumpToRow, squareToJumpToCol) == null)
                        {
                            Point destination = new Point(squareToJumpToCol, squareToJumpToRow);
                            eatingMove = new PieceMove(i_Piece.Location, destination, true);
                        }
                    }
                }
            }

            return(eatingMove);
        }
Exemplo n.º 2
0
        public GamePiece FindEatenPiece(PieceMove i_EatingMove)
        {
            Point difference = new Point(i_EatingMove.Destination.X - i_EatingMove.Location.X, i_EatingMove.Destination.Y - i_EatingMove.Location.Y);

            difference.X = difference.X / 2;
            difference.Y = difference.Y / 2;
            Point eatenPieceLocation = new Point(i_EatingMove.Location.X + difference.X, i_EatingMove.Location.Y + difference.Y);

            return(r_Board[eatenPieceLocation.Y, eatenPieceLocation.X]);
        }
Exemplo n.º 3
0
        private PieceMove findSpecificSteppingMove(Point i_Location, Player.eDirection i_VerticalDirection, Player.eDirection i_HorizontalDirection)
        {
            PieceMove steppingMove = null;
            int       row          = i_Location.Y + (int)i_VerticalDirection;
            int       col          = i_Location.X + (int)i_HorizontalDirection;

            if (isCoordinateInBoard(row, col) && getSquareOwnership(row, col) == null)
            {
                Point destination = new Point(col, row);
                steppingMove = new PieceMove(i_Location, destination, false);
            }

            return(steppingMove);
        }
Exemplo n.º 4
0
        private List <PieceMove> findEatingMoves(GamePiece i_Piece, Player.eDirection i_VerticalDirection)
        {
            List <PieceMove> currentPieceEatingMoves = new List <PieceMove>(2);
            PieceMove        currentPieceEatingLeft  = findSpecificEatingMoves(i_Piece, i_VerticalDirection, Player.eDirection.Left);
            PieceMove        currentPieceEatingRight = findSpecificEatingMoves(i_Piece, i_VerticalDirection, Player.eDirection.Right);

            if (currentPieceEatingLeft != null)
            {
                currentPieceEatingMoves.Add(currentPieceEatingLeft);
            }

            if (currentPieceEatingRight != null)
            {
                currentPieceEatingMoves.Add(currentPieceEatingRight);
            }

            return(currentPieceEatingMoves);
        }
Exemplo n.º 5
0
        private List <PieceMove> findSteppingForwardMoves(GamePiece i_GamePiece, Player.eDirection i_VerticalDirection)
        {
            List <PieceMove> currentPieceSteppingForward = new List <PieceMove>(2);
            PieceMove        currentPieceSteppingLeft    = findSpecificSteppingMove(i_GamePiece.Location, i_VerticalDirection, Player.eDirection.Left);
            PieceMove        currentPieceSteppingRight   = findSpecificSteppingMove(i_GamePiece.Location, i_VerticalDirection, Player.eDirection.Right);

            if (currentPieceSteppingLeft != null)
            {
                currentPieceSteppingForward.Add(currentPieceSteppingLeft);
            }

            if (currentPieceSteppingRight != null)
            {
                currentPieceSteppingForward.Add(currentPieceSteppingRight);
            }

            return(currentPieceSteppingForward);
        }