use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class KheruLichLordReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, source.getSourceId(), source.getControllerId(), game));
Card card = cards.getRandom(game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
FixedTarget fixedTarget = new FixedTarget(permanent, game);
ContinuousEffect effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
KheruLichLordReplacementEffect replacementEffect = new KheruLichLordReplacementEffect();
replacementEffect.setTargetPointer(fixedTarget);
game.addEffect(replacementEffect, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class MoltenEchoesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true);
effect.setTargetPointer(getTargetPointer());
if (effect.apply(game, source)) {
for (Permanent tokenPermanent : effect.getAddedPermanents()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, 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 ShallowGraveEffect 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 returnedCreature = game.getPermanent(lastCreatureCard.getId());
if (returnedCreature != null) {
FixedTarget fixedTarget = new FixedTarget(returnedCreature, 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;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class SithMagicReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// gains lifelink
effect = new GainAbilityTargetEffect(LifelinkAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(creature, 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 TwinflameCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Permanent> toExile = new ArrayList<>();
for (UUID creatureId : this.getTargetPointer().getTargets(game, source)) {
Permanent creature = game.getPermanentOrLKIBattlefield(creatureId);
if (creature != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(creature, game));
effect.apply(game, source);
toExile.addAll(effect.getAddedPermanents());
}
}
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTargets(toExile, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
Aggregations