use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class ArcaneDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = null;
boolean countered = false;
UUID targetId = this.getTargetPointer().getFirst(game, source);
if (targetId != null) {
controller = game.getPlayer(game.getControllerId(targetId));
}
if (targetId != null && game.getStack().counter(targetId, source, game)) {
countered = true;
}
if (controller != null) {
Effect effect = new DrawCardTargetEffect(StaticValue.get(2), false, true);
effect.setTargetPointer(new FixedTarget(controller.getId()));
effect.setText("Its controller may draw up to two cards");
DelayedTriggeredAbility ability = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
}
return countered;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class ChancellorOfTheAnnexDelayedTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
DelayedTriggeredAbility ability = new ChancellorOfTheAnnexDelayedTriggeredAbility(opponentId);
game.addDelayedTriggeredAbility(ability, source);
}
return true;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class GraveBetrayalReplacementEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
if (zoneChangeEvent.isDiesEvent()) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (permanent != null && !permanent.isControlledBy(this.getControllerId()) && permanent.isCreature(game)) {
Card card = (Card) game.getObject(permanent.getId());
if (card != null) {
Effect effect = new GraveBetrayalEffect();
effect.setTargetPointer(new FixedTarget(card, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, this);
return true;
}
}
}
return false;
}
use of mage.abilities.DelayedTriggeredAbility in project mage by magefree.
the class SeanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && card != null) {
// Also if the move to exile is replaced, the copy takes place
controller.moveCards(card, Zone.EXILED, source, game);
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false);
effect.setTargetPointer(new FixedTarget(card, game));
effect.setAdditionalSubType(SubType.SPIRIT);
effect.apply(game, source);
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTargets(effect.getAddedPermanents(), 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 WhipOfErebosReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(creature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
return true;
}
return false;
}
Aggregations