Ejemplo n.º 1
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);
                }
            }
        }