use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class TouchTheSpiritRealmEffect 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;
}
Card card = permanent.getMainCard();
player.moveCardsToExile(permanent, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
ReturnToBattlefieldUnderOwnerControlTargetEffect returnEffect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
returnEffect.setTargetPointer(new FixedTarget(card, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnEffect), source);
return true;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class VoidwalkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && permanent != null && sourceObject != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setText("Return that card to the battlefield under its owner's control at the beginning of the next end step");
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 KillerInstinctEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (player == null || sourceObject == null) {
return false;
}
Library library = player.getLibrary();
if (library == null || !library.hasCards()) {
return false;
}
Card card = library.getFromTop(game);
if (card == null) {
return false;
}
player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
FixedTarget ft = new FixedTarget(permanent, game);
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(ft);
game.addEffect(effect, source);
Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(ft);
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class KikiJikiMirrorBreakerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
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()) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(addedToken.getId()));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility in project mage by magefree.
the class MimicVatCreateTokenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
return false;
}
if (!permanent.getImprinted().isEmpty()) {
Card card = game.getCard(permanent.getImprinted().get(0));
if (card != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(card, 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;
}
Aggregations