Search in sources :

Example 51 with CreateTokenCopyTargetEffect

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

the class SplinterTwinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            ExileTargetEffect exileEffect = new ExileTargetEffect();
            exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 52 with CreateTokenCopyTargetEffect

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

the class TemptWithReflectionsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent != null) {
        Effect effect = new CreateTokenCopyTargetEffect();
        effect.setTargetPointer(getTargetPointer());
        effect.apply(game, source);
        Set<UUID> playersSaidYes = new HashSet<>();
        PlayerList playerList = game.getPlayerList().copy();
        playerList.setCurrent(game.getActivePlayerId());
        Player player = game.getPlayer(game.getActivePlayerId());
        do {
            if (game.getOpponents(source.getControllerId()).contains(player.getId())) {
                String decision;
                if (player.chooseUse(outcome, "Create a copy of target creature for you?", source, game)) {
                    playersSaidYes.add(player.getId());
                    decision = " chooses to copy ";
                } else {
                    decision = " won't copy ";
                }
                game.informPlayers((player.getLogName() + decision + permanent.getName()));
            }
            player = playerList.getNext(game, false);
        } while (player != null && !player.getId().equals(game.getActivePlayerId()));
        for (UUID playerId : playersSaidYes) {
            effect = new CreateTokenCopyTargetEffect(playerId);
            effect.setTargetPointer(getTargetPointer());
            effect.apply(game, source);
            // create a token for the source controller as well
            effect = new CreateTokenCopyTargetEffect();
            effect.setTargetPointer(getTargetPointer());
            effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) PlayerList(mage.players.PlayerList) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) HashSet(java.util.HashSet)

Example 53 with CreateTokenCopyTargetEffect

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

the class SparkDoubleTest method test_CopyOfSparksCopy_ByAbility.

@Test
public void test_CopyOfSparksCopy_ByAbility() {
    Ability ability = new SimpleActivatedAbility(new CreateTokenCopyTargetEffect(), new ManaCostsImpl(""));
    ability.addTarget(new TargetPermanent());
    addCustomCardWithAbility("copy", playerA, ability);
    // {3}{U}
    addCard(Zone.HAND, playerA, "Spark Double");
    addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
    // 
    // legendary
    addCard(Zone.BATTLEFIELD, playerA, "Akroma, Angel of Wrath", 1);
    // 
    // Create a 1/1 white Bird creature token with flying, then populate. (Create a token that’s a copy of a creature token you control.)
    // {3}{W}
    addCard(Zone.HAND, playerA, "Eyes in the Skies");
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
    // make copy of legendary creature (it's not legendary now)
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spark Double");
    setChoice(playerA, true);
    setChoice(playerA, "Akroma, Angel of Wrath");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
    checkPermanentCount("must have copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma, Angel of Wrath", 2);
    // make copy of copy by CreateTokenCopyTargetEffect
    // showBattlefield("before last copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
    // showAvailableAbilities("before last copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "create a token that");
    addTarget(playerA, "Akroma, Angel of Wrath[only copy]");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
    checkPermanentCount("must have copy", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akroma, Angel of Wrath", 3);
    // showBattlefield("after all", 1, PhaseStep.BEGIN_COMBAT, playerA);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.END_COMBAT);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) Ability(mage.abilities.Ability) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetPermanent(mage.target.TargetPermanent) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 54 with CreateTokenCopyTargetEffect

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

the class EchoChamberCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent copiedPermanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (copiedPermanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, CardType.CREATURE, true);
        if (effect.apply(game, source)) {
            for (Permanent copyPermanent : effect.getAddedPermanents()) {
                ExileTargetEffect exileEffect = new ExileTargetEffect();
                exileEffect.setTargetPointer(new FixedTarget(copyPermanent, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) TargetOpponentsChoicePermanent(mage.target.common.TargetOpponentsChoicePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 55 with CreateTokenCopyTargetEffect

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

the class FracturedIdentityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player == null || permanent == null) {
        return false;
    }
    player.moveCards(permanent, Zone.EXILED, source, game);
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        if (permanent.isControlledBy(playerId)) {
            continue;
        }
        new CreateTokenCopyTargetEffect(playerId, null, false).setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) UUID(java.util.UUID) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Aggregations

CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)64 FixedTarget (mage.target.targetpointer.FixedTarget)50 Permanent (mage.game.permanent.Permanent)46 Player (mage.players.Player)31 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)20 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)17 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)14 Card (mage.cards.Card)12 TargetPermanent (mage.target.TargetPermanent)10 UUID (java.util.UUID)9 Effect (mage.abilities.effects.Effect)8 OneShotEffect (mage.abilities.effects.OneShotEffect)8 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)7 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)7 FixedTargets (mage.target.targetpointer.FixedTargets)6 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)5 FilterPermanent (mage.filter.FilterPermanent)5 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)5 FilterCard (mage.filter.FilterCard)4