Search in sources :

Example 11 with CopyEffect

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

the class IdentityThiefEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && targetPermanent != null && sourcePermanent != null) {
        ContinuousEffect copyEffect = new CopyEffect(Duration.EndOfTurn, targetPermanent, source.getSourceId());
        copyEffect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
        game.addEffect(copyEffect, source);
        UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
        if (controller.moveCardsToExile(targetPermanent, source, game, true, exileZoneId, sourcePermanent.getName())) {
            Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
            effect.setText("Return the exiled card to the battlefield under its owner's control at the beginning of the next end step");
            effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CopyEffect(mage.abilities.effects.common.CopyEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 12 with CopyEffect

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

the class TheMimeoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller != null && permanent != null) {
        if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
            if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
                TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
                targetCopy.setNotTarget(true);
                if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
                    Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
                    if (cardToCopy != null) {
                        FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
                        filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
                        TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
                        targetCounters.setNotTarget(true);
                        if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
                            Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
                            if (cardForCounters != null) {
                                Cards cardsToExile = new CardsImpl();
                                cardsToExile.add(cardToCopy);
                                cardsToExile.add(cardForCounters);
                                controller.moveCards(cardsToExile, Zone.EXILED, source, game);
                                CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
                                game.addEffect(copyEffect, source);
                                permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
                            }
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) FilterCreatureCard(mage.filter.common.FilterCreatureCard) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 13 with CopyEffect

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

the class DermotaxiCopyApplier method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
    if (sourcePermanent == null) {
        return false;
    }
    Card card = game.getCard(sourcePermanent.getImprinted().get(0));
    if (card == null) {
        return false;
    }
    Permanent newBluePrint = new PermanentCard(card, source.getControllerId(), game);
    newBluePrint.assignNewId();
    DermotaxiCopyApplier applier = new DermotaxiCopyApplier();
    applier.apply(game, newBluePrint, source, sourcePermanent.getId());
    CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, newBluePrint, sourcePermanent.getId());
    copyEffect.newId();
    copyEffect.setApplier(applier);
    game.addEffect(copyEffect, source);
    return true;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) PermanentCard(mage.game.permanent.PermanentCard) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard)

Example 14 with CopyEffect

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

the class DeceiverOfFormEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Card copyFromCard = controller.getLibrary().getFromTop(game);
        if (copyFromCard != null) {
            Cards cards = new CardsImpl(copyFromCard);
            controller.revealCards(sourceObject.getIdName(), cards, game);
            if (copyFromCard.isCreature(game)) {
                if (controller.chooseUse(outcome, "Let creatures you control other than " + sourceObject.getLogName() + " becomes copies of " + copyFromCard.getLogName() + " until end of turn?", source, game)) {
                    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
                        if (!permanent.getId().equals(sourceObject.getId())) {
                            Permanent newBluePrint = null;
                            newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
                            newBluePrint.assignNewId();
                            CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, newBluePrint, permanent.getId());
                            copyEffect.newId();
                            Ability newAbility = source.copy();
                            copyEffect.init(newAbility, game);
                            game.addEffect(copyEffect, newAbility);
                        }
                    }
                }
            }
            if (controller.chooseUse(outcome, "Move " + copyFromCard.getLogName() + " to the bottom of your library?", source, game)) {
                controller.moveCardToLibraryWithInfo(copyFromCard, source, game, Zone.LIBRARY, false, true);
            }
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 15 with CopyEffect

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

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