Beispiel #1
0
        private void checkUpLeft(Square currentSquare, Player cPlayer)
        {
            int i = currentSquare.getX();
            int j = currentSquare.getY();

            while (i >= 2 && j >= 2)
            {
                Square sq = squares[i - 1, j - 1];
                if (currentSquare.getY() - sq.getY() >= 2 && currentSquare.getX() - sq.getX() >= 2 &&
                    sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    if (LRDiagonalCheck(sq, currentSquare))
                    {
                        Moves.Add(new Move(cPlayer, currentSquare));
                    }

                    break;
                }
                else if (currentSquare.getY() - sq.getY() <= 1 && currentSquare.getX() - sq.getX() <= 1 &&
                         sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    break;
                }
                i -= 1; j -= 1;
            }
        }
Beispiel #2
0
        private void checkDownRight(Square currentSquare, Player cPlayer)
        {
            int i = currentSquare.getX();
            int j = currentSquare.getY();

            while (j <= 7 && i <= 7)
            {
                Square sq = squares[i + 1, j + 1];
                if (sq.getY() - currentSquare.getY() >= 2 && sq.getX() - currentSquare.getX() >= 2 &&
                    sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    if (LRDiagonalCheck(currentSquare, sq))
                    {
                        Moves.Add(new Move(cPlayer, currentSquare));
                    }

                    break;
                }
                else if (currentSquare.getY() - sq.getY() <= 1 && currentSquare.getX() - sq.getX() <= 1 &&
                         sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    break;
                }
                i += 1; j += 1;
            }
        }
Beispiel #3
0
        private void checkLeft(Square currentSquare, Player cPlayer)
        {
            int i = currentSquare.getX();
            int j = currentSquare.getY();

            while (i >= 2)
            {
                //Console.WriteLine(i + " " + j);
                Square sq = squares[i - 1, j];
                if (currentSquare.getX() - sq.getX() >= 2 &&
                    sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    //Console.WriteLine("Same square found " + sq.getX() + " " + sq.getY());

                    if (checkHorizontalBetween(sq, currentSquare))
                    {
                        Moves.Add(new Move(cPlayer, currentSquare));
                    }

                    break;
                }
                else if (currentSquare.getX() - sq.getX() <= 1 &&
                         sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    break;
                }
                i -= 1;
            }
        }
Beispiel #4
0
        private bool RLDiagonalCheck(Square s1, Square s2)
        {
            bool addition = false;

            int i = s1.getX();
            int j = s1.getY();

            if (s1.getX() - s2.getX() == 2 && s2.getY() - s1.getY() == 2)
            {
                if (squares[i - 1, j + 1].isOccupied() && s1.isOccupied() &&
                    squares[i - 1, j + 1].getPiece().getColor() != s1.getPiece().getColor())
                {
                    addition = true;
                }
            }
            else
            {
                Square required = squares[i - 1, j + 1];

                while (i > s2.getX() && j < s2.getY())
                {
                    if (squares[i, j].isOccupied() && required.isOccupied() &&
                        squares[i, j].getPiece().getColor() == required.getPiece().getColor())
                    {
                        addition = true;
                    }
                    else
                    {
                        addition = false;
                    }
                    i -= 1; j += 1;
                }
            }
            return(addition);
        }
Beispiel #5
0
        private void ChangeLeft(int x, int y)
        {
            int i = x - 1; int j = y;

            while (i >= 1)
            {
                Square sq = gameBoard.squares[i, j];
                if (sq.isOccupied() && Math.Abs(sq.getX() - x) == 1)
                {
                    if (sq.getPiece().getColor() == currPlayer.getPlayerColor())
                    {
                        break;
                    }
                    else
                    {
                        i--;
                    } continue;
                }
                else
                {
                    if (sq.isOccupied() && sq.getPiece().getColor() == currPlayer.getPlayerColor())
                    {
                        changeBetween(i, j, x, y);
                        break;
                    }
                    else
                    {
                        i--;
                    } continue;
                }
            }
        }
Beispiel #6
0
        private void ChangeDownRight(int x, int y)
        {
            int i = x + 1; int j = y + 1;

            while (j <= 7 && i <= 7)
            {
                Square sq = gameBoard.squares[i, j];
                if (Math.Abs(sq.getY() - y) == 1 && Math.Abs(sq.getX() - x) == 1)
                {
                    if (sq.isOccupied() && sq.getPiece().getColor() == currPlayer.getPlayerColor())
                    {
                        break;
                    }
                    else
                    {
                        i++;
                    } j++; continue;
                }
                else
                {
                    if (sq.isOccupied() && sq.getPiece().getColor() == currPlayer.getPlayerColor())
                    {
                        changeBetween(i, j, x, y);
                        break;
                    }
                    else
                    {
                        i++;
                    } j++; continue;
                }
            }
        }
Beispiel #7
0
        private void checkDown(Square currentSquare, Player cPlayer)
        {
            int i = currentSquare.getX();
            int j = currentSquare.getY();

            while (j <= 7)
            {
                //Console.WriteLine(i + " " + j);
                Square sq = squares[i, j + 1];
                if (sq.getY() - currentSquare.getY() >= 2 &&
                    sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    //Console.WriteLine("Same square found " + sq.getX() + " " + sq.getY());
                    Console.WriteLine("About to Check between " + currentSquare.getY() + " " + sq.getY());
                    if (CheckVerticalBetween(currentSquare, sq))
                    {
                        Moves.Add(new Move(cPlayer, currentSquare));
                    }

                    break;
                }
                else if (currentSquare.getY() - sq.getY() <= 1 &&
                         sq.isOccupied() && sq.getPiece().getColor() == cPlayer.getPlayerColor())
                {
                    break;
                }
                j += 1;
            }
        }
Beispiel #8
0
        private bool checkHorizontalBetween(Square s1, Square s2)
        {
            //Console.WriteLine("From " + s1.getX() + " To " + s2.getX());
            bool addition = false;

            int j = s1.getY();

            if (s2.getX() - s1.getX() == 2)
            {
                //Console.WriteLine("Checking " + (s1.getX() + 1) + " " + j);
                //Console.WriteLine(s1.getPiece().getColor().ToString());
                if (squares[s1.getX() + 1, j].isOccupied() && s1.isOccupied() &&
                    squares[s1.getX() + 1, j].getPiece().getColor() != s1.getPiece().getColor())
                {
                    //Console.WriteLine("Square Found");
                    addition = true;
                }
            }
            else
            {
                Square required = squares[s1.getX() + 1, j];
                Console.WriteLine("Checking from " + (s1.getX() + 1) + " to " + (s2.getX() - 1));
                for (int i = s1.getX() + 1; i < s2.getX(); i++)
                {
                    if (squares[i, j].isOccupied() && required.isOccupied() &&
                        squares[i, j].getPiece().getColor() == required.getPiece().getColor())
                    {
                        //Console.WriteLine("Same squares are " + i + " " + (i + 1));
                        addition = true;
                    }
                    else
                    {
                        addition = false;
                    }
                }

                /*                if (addition)
                 *                  Console.WriteLine("From " + (s1.getX()+1) + " to " + (s2.getX()-1) + " Are the Same");*/
            }
            return(addition);
        }
Beispiel #9
0
 public String toString()
 {
     return("[" + movingSquare.getX() + ", " + movingSquare.getY() + "]");
 }