Search in sources :

Example 1 with PutOnLibraryTargetEffect

use of mage.abilities.effects.common.PutOnLibraryTargetEffect in project mage by magefree.

the class SweepAwayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent != null && controller != null) {
        if (permanent.isAttacking()) {
            if (controller.chooseUse(Outcome.Neutral, "Put " + permanent.getIdName() + " on top of its owner's library (otherwise return to hand)?", source, game)) {
                new PutOnLibraryTargetEffect(true).apply(game, source);
            } else {
                new ReturnToHandTargetEffect().apply(game, source);
            }
        } else {
            new ReturnToHandTargetEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : PutOnLibraryTargetEffect(mage.abilities.effects.common.PutOnLibraryTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Aggregations

PutOnLibraryTargetEffect (mage.abilities.effects.common.PutOnLibraryTargetEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1