Search in sources :

Example 6 with CopyEffect

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

the class LazavTheMultifariousCopyApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent lazavTheMultifarious = game.getPermanent(source.getSourceId());
    Permanent newBluePrint = null;
    if (controller != null && lazavTheMultifarious != null) {
        Card copyFromCard = game.getCard(source.getFirstTarget());
        if (copyFromCard != null) {
            newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
            newBluePrint.assignNewId();
            CopyApplier applier = new LazavTheMultifariousCopyApplier();
            applier.apply(game, newBluePrint, source, lazavTheMultifarious.getId());
            CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, lazavTheMultifarious.getId());
            copyEffect.newId();
            copyEffect.setApplier(applier);
            Ability newAbility = source.copy();
            copyEffect.init(newAbility, game);
            game.addEffect(copyEffect, newAbility);
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CopyApplier(mage.util.functions.CopyApplier) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 7 with CopyEffect

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

the class ScionOfTheUrDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player != null && sourcePermanent != null) {
        if (player.searchLibrary(target, source, game)) {
            for (UUID cardId : target.getTargets()) {
                Card card = player.getLibrary().getCard(cardId, game);
                if (card != null) {
                    player.moveCards(card, Zone.GRAVEYARD, source, game);
                    CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, card, source.getSourceId());
                    game.addEffect(copyEffect, source);
                }
            }
        }
        player.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) Card(mage.cards.Card)

Example 8 with CopyEffect

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

the class ShadowKinApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            cards.addAll(player.millCards(3, source, game));
        }
    }
    if (cards.isEmpty()) {
        return false;
    }
    TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE);
    target.setNotTarget(true);
    controller.choose(outcome, cards, target, game);
    Card card = game.getCard(target.getFirstTarget());
    Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
    if (card == null || sourcePermanent == null) {
        return true;
    }
    controller.moveCards(card, Zone.EXILED, source, game);
    Permanent blueprint = new PermanentCard(card, source.getControllerId(), game);
    blueprint.assignNewId();
    CopyApplier applier = new ShadowKinApplier();
    applier.apply(game, blueprint, source, sourcePermanent.getId());
    CopyEffect copyEffect = new CopyEffect(Duration.Custom, blueprint, sourcePermanent.getId());
    copyEffect.newId();
    copyEffect.setApplier(applier);
    Ability newAbility = source.copy();
    copyEffect.init(newAbility, game);
    game.addEffect(copyEffect, newAbility);
    return true;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) FlashAbility(mage.abilities.keyword.FlashAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) CopyApplier(mage.util.functions.CopyApplier) UUID(java.util.UUID) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 9 with CopyEffect

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

the class VolrathTheShapestealerCopyApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent volrathTheShapestealer = game.getPermanent(source.getSourceId());
    Permanent newBluePrint = null;
    if (controller == null || volrathTheShapestealer == null) {
        return false;
    }
    Card copyFromCard = game.getPermanent(source.getFirstTarget());
    if (copyFromCard == null) {
        return true;
    }
    newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
    newBluePrint.assignNewId();
    CopyApplier applier = new VolrathTheShapestealerCopyApplier();
    applier.apply(game, newBluePrint, source, volrathTheShapestealer.getId());
    CopyEffect copyEffect = new CopyEffect(Duration.UntilYourNextTurn, newBluePrint, volrathTheShapestealer.getId());
    copyEffect.newId();
    copyEffect.setApplier(applier);
    Ability newAbility = source.copy();
    copyEffect.init(newAbility, game);
    game.addEffect(copyEffect, newAbility);
    return true;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) CopyApplier(mage.util.functions.CopyApplier) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 10 with CopyEffect

use of mage.abilities.effects.common.CopyEffect 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)

Aggregations

CopyEffect (mage.abilities.effects.common.CopyEffect)15 Permanent (mage.game.permanent.Permanent)13 Player (mage.players.Player)11 PermanentCard (mage.game.permanent.PermanentCard)8 Ability (mage.abilities.Ability)7 Card (mage.cards.Card)7 CopyApplier (mage.util.functions.CopyApplier)7 FilterCreatureCard (mage.filter.common.FilterCreatureCard)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 UUID (java.util.UUID)3 MageObject (mage.MageObject)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 FilterPermanent (mage.filter.FilterPermanent)3 TargetPermanent (mage.target.TargetPermanent)3 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)3 BeginningOfCombatTriggeredAbility (mage.abilities.common.BeginningOfCombatTriggeredAbility)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 Effect (mage.abilities.effects.Effect)2 FilterCard (mage.filter.FilterCard)2