use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class IgnorantBlissEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards hand = new CardsImpl(controller.getHand());
controller.moveCardsToExile(hand.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
hand.getCards(game).stream().filter(Objects::nonNull).filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED).forEach(card -> card.setFaceDown(true, game));
DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.HAND));
ability.addEffect(new DrawCardSourceControllerEffect(1));
game.addDelayedTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class PlaneswalkersMischiefCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget());
if (opponent != null && opponent.getHand().size() > 0) {
Card revealedCard = opponent.getHand().getRandom(game);
if (revealedCard == null) {
return false;
}
Cards cards = new CardsImpl(revealedCard);
opponent.revealCards(source, cards, game);
if (revealedCard.isInstant(game) || revealedCard.isSorcery(game)) {
opponent.moveCardToExileWithInfo(revealedCard, source.getSourceId(), "Planeswalker's Mischief", source, game, Zone.HAND, true);
AsThoughEffect effect = new PlaneswalkersMischiefCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(revealedCard.getId()));
game.addEffect(effect, source);
OneShotEffect effect2 = new ReturnFromExileEffect(Zone.HAND);
Condition condition = new PlaneswalkersMischiefCondition(source.getSourceId(), revealedCard.getId());
ConditionalOneShotEffect effect3 = new ConditionalOneShotEffect(effect2, condition, "if you haven't cast it, return it to its owner's hand.");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect3);
delayedAbility.addWatcher(new SpellsCastWatcher());
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class SlaveOfBolasEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice this", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class TimeToFeedDiesTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
DelayedTriggeredAbility ability = new TimeToFeedDiesTriggeredAbility(creature.getId(), creature.getZoneChangeCounter(game));
new CreateDelayedTriggeredAbilityEffect(ability, false).apply(game, source);
}
return true;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class WingsOfHubrisEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
MageObject equipment = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (equipment instanceof Permanent && ((Permanent) equipment).getAttachedTo() != null) {
Permanent attachedToCreature = game.getPermanent(((Permanent) equipment).getAttachedTo());
if (attachedToCreature != null) {
ContinuousEffect effect = new CantBeBlockedTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(attachedToCreature, game));
game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice this", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(attachedToCreature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
Aggregations