use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility 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.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class MystifyingMazeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
MageObject sourceObject = source.getSourceObject(game);
if (permanent != null && sourceObject != null) {
if (permanent.moveToExile(source.getSourceId(), sourceObject.getIdName(), source, game)) {
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(true, false);
effect.setText("At the beginning of the next end step, return it to the battlefield tapped under its owner's control");
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
}
return false;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class PufferExtractEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX();
game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source);
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new DestroyTargetEffect().setTargetPointer(new FixedTarget(source.getFirstTarget(), game))), source);
return true;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class RoonOfTheHiddenRealmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
if (getTargetPointer().getFirst(game, source) != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
int zcc = permanent.getZoneChangeCounter(game);
if (controller.moveCards(permanent, Zone.EXILED, source, game)) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility 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;
}
Aggregations