Search in sources :

Example 11 with CopyApplier

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

the class DimirDoppelgangerCopyApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent dimirDoppelganger = game.getPermanent(source.getSourceId());
    Permanent newBluePrint = null;
    if (controller != null && dimirDoppelganger != null) {
        Card copyFromCard = game.getCard(source.getFirstTarget());
        if (copyFromCard != null) {
            Cards cardsToExile = new CardsImpl();
            cardsToExile.add(copyFromCard);
            controller.moveCards(cardsToExile, Zone.EXILED, source, game);
            newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
            newBluePrint.assignNewId();
            CopyApplier applier = new DimirDoppelgangerCopyApplier();
            applier.apply(game, newBluePrint, source, dimirDoppelganger.getId());
            CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, dimirDoppelganger.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) 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) PermanentCard(mage.game.permanent.PermanentCard)

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