use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class NalathniDragonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ActivationInfo activationInfo = ActivationInfo.getInstance(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
activationInfo.addActivation(game);
if (activationInfo.getActivationCounter() >= 4) {
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeSourceEffect());
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class NahiriTheHarbingerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
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.getId(), permanent.getZoneChangeCounter(game)));
game.addEffect(effect, source);
Effect effect2 = new ReturnToHandTargetEffect();
effect2.setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class PlaneboundAccompliceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
if (!controller.chooseUse(Outcome.PutCardInPlay, "Put a planeswalker card from your hand onto the battlefield?", source, game)) {
return true;
}
TargetCardInHand target = new TargetCardInHand(filter);
if (!controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
return true;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
if (!controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return true;
}
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;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class SurpriseDeploymentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
TargetCardInHand target = new TargetCardInHand(filter);
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ReturnToHandTargetEffect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
}
return false;
}
}
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class TheLocustGodEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Create delayed triggered ability
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return {this} to its owner's hand");
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
Aggregations