Search in sources :

Example 1 with DontUntapInControllersNextUntapStepTargetEffect

use of mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect in project mage by magefree.

the class SleepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player != null) {
        List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
        for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
            creature.tap(source, game);
            doNotUntapNextUntapStep.add(creature);
        }
        if (!doNotUntapNextUntapStep.isEmpty()) {
            ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("", player.getId());
            effect.setText("those creatures don't untap during that player's next untap step");
            effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 2 with DontUntapInControllersNextUntapStepTargetEffect

use of mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect in project mage by magefree.

the class SporeCloudEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            doNotUntapNextUntapStep.add(permanent);
        }
        if (!doNotUntapNextUntapStep.isEmpty()) {
            ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("This creature");
            effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) ArrayList(java.util.ArrayList) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 3 with DontUntapInControllersNextUntapStepTargetEffect

use of mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect in project mage by magefree.

the class EntanglingTrapTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!isControlledBy(event.getPlayerId())) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new TapTargetEffect());
    if (event.getFlag()) {
        this.addEffect(new DontUntapInControllersNextUntapStepTargetEffect());
    }
    return true;
}
Also used : DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) TapTargetEffect(mage.abilities.effects.common.TapTargetEffect)

Example 4 with DontUntapInControllersNextUntapStepTargetEffect

use of mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect in project mage by magefree.

the class GlacialGraspEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.tap(source, game);
    game.addEffect(new DontUntapInControllersNextUntapStepTargetEffect(), source);
    Player player = game.getPlayer(permanent.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(2, source, game);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect)

Example 5 with DontUntapInControllersNextUntapStepTargetEffect

use of mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect in project mage by magefree.

the class JovensFerretsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class);
        if (watcher != null) {
            List<Permanent> toTap = new ArrayList<>();
            for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
                if (!creature.getId().equals(source.getSourceId())) {
                    if (watcher.creatureHasBlockedAttacker(sourcePermanent, creature, game)) {
                        toTap.add(creature);
                    }
                }
            }
            for (Permanent creature : toTap) {
                creature.tap(source, game);
                DontUntapInControllersNextUntapStepTargetEffect effect = new DontUntapInControllersNextUntapStepTargetEffect();
                effect.setTargetPointer(new FixedTarget(creature.getId(), game));
                game.addEffect(effect, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DontUntapInControllersNextUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect) BlockedAttackerWatcher(mage.watchers.common.BlockedAttackerWatcher) ArrayList(java.util.ArrayList)

Aggregations

DontUntapInControllersNextUntapStepTargetEffect (mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect)15 Permanent (mage.game.permanent.Permanent)13 ContinuousEffect (mage.abilities.effects.ContinuousEffect)11 Player (mage.players.Player)9 ArrayList (java.util.ArrayList)8 FixedTargets (mage.target.targetpointer.FixedTargets)7 FixedTarget (mage.target.targetpointer.FixedTarget)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 TapTargetEffect (mage.abilities.effects.common.TapTargetEffect)2 TargetPlayer (mage.target.TargetPlayer)2 MageObjectReference (mage.MageObjectReference)1 TargetLandPermanent (mage.target.common.TargetLandPermanent)1 BlockedAttackerWatcher (mage.watchers.common.BlockedAttackerWatcher)1