Search in sources :

Example 11 with CreateDelayedTriggeredAbilityEffect

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) OnLeaveReturnExiledToBattlefieldAbility(mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility) Card(mage.cards.Card)

Aggregations

CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)11 Player (mage.players.Player)8 Permanent (mage.game.permanent.Permanent)7 Card (mage.cards.Card)5 LinkedHashSet (java.util.LinkedHashSet)3 OnLeaveReturnExiledToBattlefieldAbility (mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility)3 SpecialAction (mage.abilities.SpecialAction)2 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)2 Effect (mage.abilities.effects.Effect)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 CreateSpecialActionEffect (mage.abilities.effects.common.CreateSpecialActionEffect)2 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)2 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 TargetPermanent (mage.target.TargetPermanent)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 AtTheBeginOfNextUpkeepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility)1