Beispiel #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);
        }