use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.
the class ArcaneArtisanExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
player.drawCards(1, source, game);
TargetCard target = new TargetCardInHand(1, StaticFilters.FILTER_CARD);
if (!player.chooseTarget(Outcome.Exile, player.getHand(), target, source, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
if (!player.moveCards(card, Zone.EXILED, source, game)) {
return false;
}
if (card.isCreature(game)) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(player.getId());
effect.setTargetPointer(new FixedTarget(card.getId(), game));
effect.apply(game, source);
Object object = game.getState().getValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game));
Set<UUID> tokensCreated;
if (object != null) {
tokensCreated = (Set<UUID>) object;
} else {
tokensCreated = new HashSet<>();
}
for (Permanent perm : effect.getAddedPermanents()) {
if (perm != null) {
tokensCreated.add(perm.getId());
}
}
game.getState().setValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game), tokensCreated);
}
return true;
}
use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.
the class CloneLegionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && targetPlayer != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.
the class DelinaWildMageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, true, true);
effect.setIsntLegendary(true);
effect.addAdditionalAbilities(new EndOfCombatTriggeredAbility(new ExileSourceEffect(), false, "Exile this creature at end of combat."));
effect.setTargetPointer(getTargetPointer());
while (true) {
int result = player.rollDice(outcome, source, game, 20);
effect.apply(game, source);
if (result < 15 || 20 < result || !player.chooseUse(outcome, "Roll again?", source, game)) {
break;
}
}
return true;
}
use of mage.abilities.effects.common.CreateTokenCopyTargetEffect in project mage by magefree.
the class BattleForBretagardTarget method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new BattleForBretagardTarget();
player.choose(outcome, target, source.getSourceId(), game);
for (UUID targetId : target.getTargets()) {
new CreateTokenCopyTargetEffect().setTargetPointer(new FixedTarget(targetId, game)).apply(game, source);
}
return true;
}
Aggregations