Пример #1
0
        private void checkCaptureOptionsOfaGivenPawn(GameBoard i_Matrix, Point i_Start, char i_PlayerColor, ref List <Point> o_ResDestanation)// returns start,end,start,end..
        {
            Square checkSquare1 = null;
            Square checkSquare2 = null;
            int    x            = i_Start.GetX();
            int    y            = i_Start.GetY();
            int    matrixSize   = i_Matrix.GetSize;

            checkSquare1 = i_Matrix.GetSquare(x, y);
            if (checkSquare1.GetChecker() != null)
            {
                if ((i_PlayerColor == (char)eCheckerGame.WhitePlayer) || (checkSquare1.GetChecker().IsKing))
                {
                    if ((x + 2 < matrixSize) && (y - 2 >= 0))
                    {
                        checkSquare1 = i_Matrix.GetSquare(x + 1, y - 1);
                        checkSquare2 = i_Matrix.GetSquare(x + 2, y - 2);
                        if (checkSquare1.GetChecker() != null && checkSquare2.GetChecker() == null && (checkSquare1.GetChecker().Color != i_PlayerColor))
                        {
                            o_ResDestanation.Add(new Point(x, y));
                            o_ResDestanation.Add(new Point(x + 2, y - 2));
                        }
                    }

                    if ((x + 2 < matrixSize) && (y + 2 < matrixSize))
                    {
                        checkSquare1 = i_Matrix.GetSquare(x + 1, y + 1);
                        checkSquare2 = i_Matrix.GetSquare(x + 2, y + 2);

                        if (checkSquare1.GetChecker() != null && checkSquare2.GetChecker() == null && (checkSquare1.GetChecker().Color != i_PlayerColor))
                        {
                            o_ResDestanation.Add(new Point(x, y));
                            o_ResDestanation.Add(new Point(x + 2, y + 2));
                        }
                    }
                }

                checkSquare1 = i_Matrix.GetSquare(x, y);

                if ((i_PlayerColor == (char)eCheckerGame.BlackPlayer) || (checkSquare1.GetChecker().IsKing))
                {
                    if ((y + 2 < matrixSize) && (x - 2 >= 0))
                    {
                        checkSquare1 = i_Matrix.GetSquare(x - 1, y + 1);
                        checkSquare2 = i_Matrix.GetSquare(x - 2, y + 2);
                        if (checkSquare1.GetChecker() != null && checkSquare2.GetChecker() == null && (checkSquare1.GetChecker().Color != i_PlayerColor))
                        {
                            o_ResDestanation.Add(new Point(x, y));
                            o_ResDestanation.Add(new Point(x - 2, y + 2));
                        }
                    }

                    if ((x - 2 >= 0) && (y - 2 >= 0))
                    {
                        checkSquare1 = i_Matrix.GetSquare(x - 1, y - 1);
                        checkSquare2 = i_Matrix.GetSquare(x - 2, y - 2);
                        if (checkSquare1.GetChecker() != null && checkSquare2.GetChecker() == null && (checkSquare1.GetChecker().Color != i_PlayerColor))
                        {
                            o_ResDestanation.Add(new Point(x, y));
                            o_ResDestanation.Add(new Point(x - 2, y - 2));
                        }
                    }
                }
            }
        }