Search in sources :

Example 1 with AtTheBeginOfNextCleanupDelayedTriggeredAbility

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;
}
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)

Example 2 with AtTheBeginOfNextCleanupDelayedTriggeredAbility

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;
}
Also used : Target(mage.target.Target) AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) UUID(java.util.UUID)

Example 3 with AtTheBeginOfNextCleanupDelayedTriggeredAbility

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;
}
Also used : AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) AtTheBeginOfNextCleanupDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect)

Aggregations

AtTheBeginOfNextCleanupDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextCleanupDelayedTriggeredAbility)3 Permanent (mage.game.permanent.Permanent)3 UUID (java.util.UUID)2 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)2 ArrayList (java.util.ArrayList)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 SacrificeSourceEffect (mage.abilities.effects.common.SacrificeSourceEffect)1 Token (mage.game.permanent.token.Token)1 WaylayToken (mage.game.permanent.token.WaylayToken)1 Target (mage.target.Target)1 TargetPermanent (mage.target.TargetPermanent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 FixedTargets (mage.target.targetpointer.FixedTargets)1