Search in sources :

Example 1 with RemoveCounterTargetEffect

use of mage.abilities.effects.common.counter.RemoveCounterTargetEffect in project mage by magefree.

the class ClockspinningAddOrRemoveCounterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player != null && permanent != null) {
        if (player.chooseUse(Outcome.Neutral, "Remove a counter?", source, game)) {
            RemoveCounterTargetEffect effect = new RemoveCounterTargetEffect();
            effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
            effect.apply(game, source);
        } else {
            Counter counter = selectCounterType(game, source, permanent);
            if (counter != null) {
                AddCountersTargetEffect effect = new AddCountersTargetEffect(counter);
                effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
                effect.apply(game, source);
            }
        }
        return true;
    }
    Card card = game.getCard(source.getFirstTarget());
    if (player != null && card != null) {
        if (player.chooseUse(Outcome.Neutral, "Remove a counter?", source, game)) {
            Counter counter = selectCounterType(game, source, card);
            RemoveCounterTargetEffect effect = new RemoveCounterTargetEffect(counter);
            effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
            effect.apply(game, source);
        } else {
            Counter counter = selectCounterType(game, source, card);
            if (counter != null) {
                AddCountersTargetEffect effect = new AddCountersTargetEffect(counter);
                effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Counter(mage.counters.Counter) Permanent(mage.game.permanent.Permanent) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) TargetPermanentOrSuspendedCard(mage.target.common.TargetPermanentOrSuspendedCard) Card(mage.cards.Card)

Example 2 with RemoveCounterTargetEffect

use of mage.abilities.effects.common.counter.RemoveCounterTargetEffect in project mage by magefree.

the class ClockworkBeetleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
        Effect effect = new RemoveCounterTargetEffect(CounterType.P1P1.createInstance());
        effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
        game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)

Example 3 with RemoveCounterTargetEffect

use of mage.abilities.effects.common.counter.RemoveCounterTargetEffect in project mage by magefree.

the class MaintenanceDroidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose mode");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        String chosen = choice.getChoice();
        switch(chosen) {
            case "Remove a repair counter":
                new RemoveCounterTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
                break;
            default:
                // "Add another repair counter"
                new AddCountersTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
                break;
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) ChoiceImpl(mage.choices.ChoiceImpl) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 4 with RemoveCounterTargetEffect

use of mage.abilities.effects.common.counter.RemoveCounterTargetEffect in project mage by magefree.

the class MayRemoveM1M1CouterTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Permanent target = game.getPermanent(source.getTargets().getFirstTarget());
    if (target == null) {
        return false;
    }
    if (target.getCounters(game).getCount(CounterType.M1M1) > 0) {
        if (controller.chooseUse(outcome, "Remove a -1/-1 counter from " + target.getIdName() + "?", source, game)) {
            Effect effect = new RemoveCounterTargetEffect(CounterType.M1M1.createInstance());
            effect.setTargetPointer(new FixedTarget(target.getId(), game));
            effect.apply(game, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect)

Example 5 with RemoveCounterTargetEffect

use of mage.abilities.effects.common.counter.RemoveCounterTargetEffect in project mage by magefree.

the class DecimatorBeetleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null && targetCreature.getCounters(game).containsKey(CounterType.M1M1)) {
        Effect effect = new RemoveCounterTargetEffect(CounterType.M1M1.createInstance(1));
        effect.setTargetPointer(targetPointer);
        effect.apply(game, source);
    }
    targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (targetCreature != null) {
        Effect effect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
        effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Aggregations

RemoveCounterTargetEffect (mage.abilities.effects.common.counter.RemoveCounterTargetEffect)5 Permanent (mage.game.permanent.Permanent)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 Effect (mage.abilities.effects.Effect)3 OneShotEffect (mage.abilities.effects.OneShotEffect)3 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)3 Player (mage.players.Player)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 Card (mage.cards.Card)1 Choice (mage.choices.Choice)1 ChoiceImpl (mage.choices.ChoiceImpl)1 Counter (mage.counters.Counter)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)1 TargetPermanentOrSuspendedCard (mage.target.common.TargetPermanentOrSuspendedCard)1