Search in sources :

Example 11 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class MirageMirrorCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (sourcePermanent != null && copyFromPermanent != null) {
        game.copyPermanent(Duration.EndOfTurn, copyFromPermanent, sourcePermanent.getId(), source, new EmptyCopyApplier());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 12 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class PolymorphousRushCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetCreaturePermanent(new FilterCreaturePermanent(""));
        target.setNotTarget(true);
        target.setTargetName("a creature on the battlefield (creature to copy)");
        if (target.canChoose(source.getId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
            Permanent copyFromCreature = game.getPermanent(target.getFirstTarget());
            if (copyFromCreature != null) {
                for (UUID copyToId : getTargetPointer().getTargets(game, source)) {
                    Permanent copyToCreature = game.getPermanent(copyToId);
                    if (copyToCreature != null) {
                        game.copyPermanent(Duration.EndOfTurn, copyFromCreature, copyToId, source, new EmptyCopyApplier());
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) UUID(java.util.UUID)

Example 13 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class TruePolymorphEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent copyTo = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (copyTo == null) {
        return false;
    }
    Permanent copyFrom = game.getPermanentOrLKIBattlefield(source.getTargets().get(1).getFirstTarget());
    if (copyFrom == null) {
        return false;
    }
    game.copyPermanent(Duration.Custom, copyFrom, copyTo.getId(), source, new EmptyCopyApplier());
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 14 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class EsixFractalBloomWatcher method copyPermanentToToken.

private static Token copyPermanentToToken(Permanent permanent, Game game, Ability source) {
    CopyApplier applier = new EmptyCopyApplier();
    // handle copies of copies
    Permanent copyFromPermanent = permanent;
    for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
        if (!(effect instanceof CopyEffect)) {
            continue;
        }
        CopyEffect copyEffect = (CopyEffect) effect;
        // there is another copy effect that our targetPermanent copies stats from
        if (!copyEffect.getSourceId().equals(permanent.getId())) {
            continue;
        }
        MageObject object = ((CopyEffect) effect).getTarget();
        if (!(object instanceof Permanent)) {
            continue;
        }
        copyFromPermanent = (Permanent) object;
        if (copyEffect.getApplier() != null) {
            applier = copyEffect.getApplier();
        }
    }
    // create token and modify all attributes permanently (without game usage)
    EmptyToken token = new EmptyToken();
    // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
    CardUtil.copyTo(token).from(copyFromPermanent, game);
    applier.apply(game, token, source, permanent.getId());
    return token;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) CopyApplier(mage.util.functions.CopyApplier) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) EmptyToken(mage.game.permanent.token.EmptyToken)

Example 15 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class NascentMetamorphEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    Cards toReveal = new CardsImpl();
    Card toCopy = null;
    for (Card card : player.getLibrary().getCards(game)) {
        toReveal.add(card);
        if (card == null || !card.isCreature(game)) {
            continue;
        }
        toCopy = card;
        break;
    }
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (toCopy != null && permanent != null) {
        game.copyPermanent(Duration.EndOfTurn, new PermanentCard(toCopy, source.getControllerId(), game), permanent.getId(), source, new EmptyCopyApplier());
    }
    player.revealCards(source, toReveal, game);
    player.putCardsOnBottomOfLibrary(toReveal, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Aggregations

Permanent (mage.game.permanent.Permanent)20 EmptyCopyApplier (mage.util.functions.EmptyCopyApplier)20 TargetPermanent (mage.target.TargetPermanent)9 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 Player (mage.players.Player)6 FilterPermanent (mage.filter.FilterPermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 MageObject (mage.MageObject)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Ability (mage.abilities.Ability)2 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)2 EmptyToken (mage.game.permanent.token.EmptyToken)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 UUID (java.util.UUID)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 DiesCreatureTriggeredAbility (mage.abilities.common.DiesCreatureTriggeredAbility)1 EntersBattlefieldAllTriggeredAbility (mage.abilities.common.EntersBattlefieldAllTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1