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