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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations