use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class HeatShimmerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (controller != null && permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanents().get(0), game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class MeriekeRiBeritDelayedTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent controlledCreature = game.getPermanent(source.getFirstTarget());
if (controlledCreature != null) {
DelayedTriggeredAbility delayedAbility = new MeriekeRiBeritDelayedTriggeredAbility();
delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(controlledCreature, game));
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class TreacherousUrgeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId());
if (opponent != null && sourceObject != null) {
opponent.revealCards(sourceObject.getName(), opponent.getHand(), game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int cardsHand = opponent.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game);
Card card = null;
if (cardsHand > 0) {
TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
card = opponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
}
return false;
}
}
}
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class CreateTokenCopyTargetEffect method removeTokensCreatedAtEndOf.
private void removeTokensCreatedAtEndOf(Game game, Ability source, PhaseStep phaseStepToExileCards, boolean exile) {
Effect effect;
if (exile) {
effect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD).setText("exile the token copies");
} else {
effect = new SacrificeTargetEffect("sacrifice the token copies");
}
effect.setTargetPointer(new FixedTargets(addedTokenPermanents, game));
DelayedTriggeredAbility exileAbility;
switch(phaseStepToExileCards) {
case END_TURN:
exileAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
break;
case END_COMBAT:
exileAbility = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
break;
default:
return;
}
game.addDelayedTriggeredAbility(exileAbility, source);
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class BroodOfCockroachesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
game.addDelayedTriggeredAbility(delayedLifeLost, source);
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return {this} to your hand.");
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
Aggregations