Search in sources :

Example 6 with CopyApplier

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

the class LazavDimirMastermindCopyApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent lazavDimirMastermind = game.getPermanent(source.getSourceId());
    Permanent newBluePrint = null;
    if (controller != null && lazavDimirMastermind != null) {
        Card copyFromCard = game.getCard(((FixedTarget) getTargetPointer()).getTarget());
        if (copyFromCard != null) {
            newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
            newBluePrint.assignNewId();
            CopyApplier applier = new LazavDimirMastermindCopyApplier();
            applier.apply(game, newBluePrint, source, lazavDimirMastermind.getId());
            CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, lazavDimirMastermind.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) PutCardIntoGraveFromAnywhereAllTriggeredAbility(mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility) HexproofAbility(mage.abilities.keyword.HexproofAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CopyApplier(mage.util.functions.CopyApplier) FilterCreatureCard(mage.filter.common.FilterCreatureCard) PermanentCard(mage.game.permanent.PermanentCard) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard)

Example 7 with CopyApplier

use of mage.util.functions.CopyApplier 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 8 with CopyApplier

use of mage.util.functions.CopyApplier 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 CopyApplier

use of mage.util.functions.CopyApplier 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 CopyApplier

use of mage.util.functions.CopyApplier 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

Permanent (mage.game.permanent.Permanent)11 CopyApplier (mage.util.functions.CopyApplier)11 Ability (mage.abilities.Ability)10 CopyEffect (mage.abilities.effects.common.CopyEffect)7 Player (mage.players.Player)7 PermanentCard (mage.game.permanent.PermanentCard)6 MageObject (mage.MageObject)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)5 UUID (java.util.UUID)4 Card (mage.cards.Card)4 TargetPermanent (mage.target.TargetPermanent)4 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 Game (mage.game.Game)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 FilterPermanent (mage.filter.FilterPermanent)2 EmptyToken (mage.game.permanent.token.EmptyToken)2 Target (mage.target.Target)2