示例#1
0
        internal override Square[,] CanFigureMove(Square[,] avaibleSquares, Desk desk, Square ownSquare)
        {
            //пешки ходят на два хода только со своей начальной горизонтали(2-я для белыхых, 7-я для черных)
            CanJump = ((ownSquare.y == 1 && pieceKey == PiecesKeys.whitePawn) || (ownSquare.y == 6 && pieceKey == PiecesKeys.blackPawn));

            Piece pieceOnSquare;
            int   absDeltaX, deltaY;


            foreach (Square square in avaibleSquares)
            {
                pieceOnSquare = desk.deskSquares[square.x, square.y].ownedPiece;
                absDeltaX     = ownSquare.AbsDeltaX(square);
                deltaY        = ownSquare.DeltaY(square);


                if (CanJump && absDeltaX == 0 && deltaY == 2 * stepY)
                {
                    if (desk.deskSquares[square.x, square.y - stepY].ownedPiece != Piece.nullPiece)
                    {
                        avaibleSquares[square.x, square.y] = Square.none;
                        continue;
                    }

                    if (pieceOnSquare != Piece.nullPiece)
                    {
                        movesVector.occupiedSquares.Add(square.Name);
                        avaibleSquares[square.x, square.y] = Square.none;
                        continue;
                    }

                    continue;
                }


                if (deltaY == stepY && absDeltaX <= 1)
                {
                    if (absDeltaX == 0)
                    {
                        if (pieceOnSquare == Piece.nullPiece)
                        {
                            continue;
                        }

                        movesVector.occupiedSquares.Add(square.Name);
                        avaibleSquares[square.x, square.y] = Square.none;
                    }
                    else
                    {
                        if (desk.notation.EnPassant == square.Name && desk.notation.InGameColor == pieceColor)
                        {
                            movesVector.status = "recalculate";
                            continue;
                        }
                        if (pieceOnSquare.pieceColor != pieceColor.FlipColor())
                        {
                            movesVector.occupiedSquares.Add(square.Name);////////////////////
                            avaibleSquares[square.x, square.y] = Square.none;
                        }
                    }

                    continue;
                }
                else
                {
                    avaibleSquares[square.x, square.y] = Square.none;
                }
            }

            return(avaibleSquares);
        }
示例#2
0
        internal override Square[,] CanFigureMove(Square[,] avaibleSquares, Desk desk, Square ownSquare)
        {
            Square[,] avaibleSquaresS = new Square[8, 8];
            Square[,] avaibleSquaresD = new Square[8, 8];

            for (int y = 7; y >= 0; y--)
            {
                for (int x = 0; x < 8; x++)
                {
                    avaibleSquaresS[x, y] = new Square(x, y);
                    avaibleSquaresD[x, y] = new Square(x, y);
                }
            }

            CanMoveStraight(avaibleSquaresS, desk.deskSquares, ownSquare);
            CanMoveDiagonal(avaibleSquaresD, desk.deskSquares, ownSquare);

            for (int y = 7; y >= 0; y--)
            {
                for (int x = 0; x < 8; x++)
                {
                    if (avaibleSquaresS[x, y] == Square.none && avaibleSquaresD[x, y] == Square.none)
                    {
                        avaibleSquares[x, y] = Square.none;
                    }
                }
            }

            return(avaibleSquares);
        }
示例#3
0
        internal override Square[,] CanFigureMove(Square[,] avaibleSquares, Desk desk, Square ownSquare)
        {
            foreach (Square square in avaibleSquares)
            {
                if (square == ownSquare)
                {
                    avaibleSquares[square.x, square.y] = Square.none; continue;
                }

                if (!((ownSquare.AbsDeltaX(square) == 1 && ownSquare.AbsDeltaY(square) == 2) ||
                      (ownSquare.AbsDeltaX(square) == 2 && ownSquare.AbsDeltaY(square) == 1)))
                {
                    avaibleSquares[square.x, square.y] = Square.none;
                }
                else
                {
                    if (desk.deskSquares[square.x, square.y].ownedPiece.pieceColor == pieceColor)
                    {
                        avaibleSquares[square.x, square.y] = Square.none;
                        movesVector.occupiedSquares.Add(square.Name);
                    }
                }
            }

            return(avaibleSquares);
        }