use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class PhantomSteedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source));
if (exileZone == null || exileZone.isEmpty()) {
return false;
}
for (Card card : exileZone.getCards(game)) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(card, game);
token.addSubType(SubType.ILLUSION);
token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new ExileTargetEffect("Sacrifice that token at end of combat").setTargetPointer(new FixedTargets(permanents, game))), source);
}
return true;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class OutcomesTest method test_FromEffects_MultiCombine.
@Test
public void test_FromEffects_MultiCombine() {
Ability ability = new SimpleStaticAbility(new GainLifeEffect(10));
ability.addEffect(new BoostSourceEffect(10, 10, Duration.EndOfTurn));
ability.addEffect(new ExileTargetEffect());
Assert.assertEquals(1 + 1 + -1, ability.getEffects().getOutcomeScore(ability));
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class MyriadEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourceObject != null) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
if (defendingPlayerId == null) {
Logger.getLogger(MyriadEffect.class).error("defending player == null source: " + sourceObject.getName() + " attacking: " + (sourceObject.isAttacking() ? "Y" : "N"));
return false;
}
List<Permanent> tokens = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!playerId.equals(defendingPlayerId) && controller.hasOpponent(playerId, game)) {
Player opponent = game.getPlayer(playerId);
if (opponent != null && controller.chooseUse(Outcome.PutCreatureInPlay, "Put a copy of " + sourceObject.getIdName() + " onto battlefield attacking " + opponent.getName() + '?', source, game)) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(controller.getId(), null, false, 1, true, true, playerId);
effect.setTargetPointer(new FixedTarget(sourceObject, game));
effect.apply(game, source);
tokens.addAll(effect.getAddedPermanents());
}
}
}
if (!tokens.isEmpty()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTargets(tokens, game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class CogworkAssemblerCreateTokenEffect 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.ARTIFACT, 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.ExileTargetEffect in project mage by magefree.
the class CorpseDanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card lastCreatureCard = null;
for (Card card : controller.getGraveyard().getCards(game)) {
if (card.isCreature(game)) {
lastCreatureCard = card;
}
}
if (lastCreatureCard != null) {
if (controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(lastCreatureCard.getId());
if (creature != null) {
FixedTarget fixedTarget = new FixedTarget(creature, game);
// Gains Haste
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
hasteEffect.setTargetPointer(fixedTarget);
game.addEffect(hasteEffect, source);
// Exile it at end of turn
ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
return true;
}
return false;
}
Aggregations