Search in sources :

Example 1 with WaylayToken

use of mage.game.permanent.token.WaylayToken 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;
}
Also used : AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) WaylayToken(mage.game.permanent.token.WaylayToken) Token(mage.game.permanent.token.Token) WaylayToken(mage.game.permanent.token.WaylayToken) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 AtTheBeginOfNextCleanupDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 Token (mage.game.permanent.token.Token)1 WaylayToken (mage.game.permanent.token.WaylayToken)1 FixedTargets (mage.target.targetpointer.FixedTargets)1