示例#1
0
        public Piece MovementExecute(Position origin, Position destiny)
        {
            Piece p = Board.RemovePiece(origin);

            p.MovementIncrement();
            Piece CapturedPiece = Board.RemovePiece(destiny);

            Board.addPiece(p, destiny);
            if (CapturedPiece != null)
            {
                Capturated.Add(CapturedPiece);
            }

            //#EspecialPlay small-Rock
            if (p is King && destiny.Column == origin.Column + 2)
            {
                Position originT  = new Position(origin.Line, origin.Column + 3);
                Position destinyT = new Position(origin.Line, origin.Column + 1);
                Piece    T        = Board.RemovePiece(originT);
                T.MovementIncrement();
                Board.addPiece(T, destinyT);
            }

            //#EspecialPlay big-Rock
            if (p is King && destiny.Column == origin.Column - 2)
            {
                Position originT  = new Position(origin.Line, origin.Column - 4);
                Position destinyT = new Position(origin.Line, origin.Column - 1);
                Piece    T        = Board.RemovePiece(originT);
                T.MovementIncrement();
                Board.addPiece(T, destinyT);
            }

            //#EspecialPlay en passant
            if (p is Peasant)
            {
                if (origin.Column != destiny.Column && CapturedPiece == null)
                {
                    Position posP;
                    if (p.Color == Color.white)
                    {
                        posP = new Position(destiny.Line + 1, destiny.Column);
                    }
                    else
                    {
                        posP = new Position(destiny.Line - 1, destiny.Column);
                    }
                    CapturedPiece = Board.RemovePiece(posP);
                    Capturated.Add(CapturedPiece);
                }
            }
            return(CapturedPiece);
        }
示例#2
0
        private void UndoMovement(Position origin, Position destiny, Piece capturatedPiece)
        {
            Piece p = Board.RemovePiece(destiny);

            p.MovementDecrement();
            if (capturatedPiece != null)
            {
                Board.addPiece(capturatedPiece, destiny);
                Capturated.Remove(capturatedPiece);
            }
            Board.addPiece(p, origin);

            //#EspecialPlay small-Rock
            if (p is King && destiny.Column == origin.Column + 2)
            {
                Position originT  = new Position(origin.Line, origin.Column + 3);
                Position destinyT = new Position(origin.Line, origin.Column + 1);
                Piece    T        = Board.RemovePiece(destinyT);
                T.MovementDecrement();
                Board.addPiece(T, originT);
            }

            //#EspecialPlay big-Rock
            if (p is King && destiny.Column == origin.Column - 2)
            {
                Position originT  = new Position(origin.Line, origin.Column - 4);
                Position destinyT = new Position(origin.Line, origin.Column - 1);
                Piece    T        = Board.RemovePiece(destinyT);
                T.MovementDecrement();
                Board.addPiece(T, originT);
            }

            //#EspecialPlay en passant
            if (p is Peasant)
            {
                if (origin.Column != destiny.Column && capturatedPiece == VulnerableEnPassant)
                {
                    Piece    peasant = Board.RemovePiece(destiny);
                    Position posP;
                    if (p.Color == Color.white)
                    {
                        posP = new Position(3, destiny.Column);
                    }
                    else
                    {
                        posP = new Position(4, destiny.Column);
                    }
                    Board.addPiece(peasant, posP);
                }
            }
        }
示例#3
0
 public void PlaceNewPiece(char column, int line, Piece piece)
 {
     Board.addPiece(piece, new ChessPosition(column, line).ToPosition());
     Pieces.Add(piece);
 }