use of mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility in project mage by magefree.
the class WaylayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new WaylayToken();
token.putOntoBattlefield(3, game, source, source.getControllerId());
List<Permanent> toExile = new ArrayList<>();
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
toExile.add(tokenPermanent);
}
}
Effect effect = new ExileTargetEffect();
effect.setTargetPointer(new FixedTargets(toExile, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(effect), source);
return true;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility in project mage by magefree.
the class RemoveCountersAtEndOfTurn method apply.
@Override
public boolean apply(Game game, Ability source) {
if (!source.getTargets().isEmpty()) {
Target multiTarget = source.getTargets().get(0);
for (UUID target : multiTarget.getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent != null) {
permanent.addCounters(counterType.createInstance(multiTarget.getTargetAmount(target)), source.getControllerId(), source, game);
}
}
if (removeAtEndOfTurn) {
DelayedTriggeredAbility ability = new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new RemoveCountersAtEndOfTurn(counterType));
ability.getTargets().addAll(source.getTargets());
game.addDelayedTriggeredAbility(ability, source);
}
return true;
}
return false;
}
use of mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility in project mage by magefree.
the class SacrificeSourceBeginningCleanupStepEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent cunning = game.getPermanent(source.getSourceId());
if (cunning != null) {
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new SacrificeSourceEffect());
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
Aggregations