use of mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect in project mage by magefree.
the class ConsulateCracksownExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
// If the permanent leaves the battlefield before the ability resolves, artifacts won't be exiled.
if (permanent == null || controller == null)
return false;
Set<Card> toExile = new LinkedHashSet<>();
for (Permanent artifact : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
toExile.add(artifact);
}
if (!toExile.isEmpty()) {
controller.moveCardsToExile(toExile, source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility()).apply(game, source);
}
return true;
}
Aggregations