foul-magics/Mage/src/main/java/mage/abilities/effects/common/RemoveAllCountersSourceEffect.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

44 lines
1.3 KiB
Java

package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author LoneFox
*/
public class RemoveAllCountersSourceEffect extends OneShotEffect {
private final CounterType counterType;
public RemoveAllCountersSourceEffect(CounterType counterType) {
super(Outcome.Neutral);
this.counterType = counterType;
staticText = "remove all " + counterType.getName() + " counters from it.";
}
protected RemoveAllCountersSourceEffect(final RemoveAllCountersSourceEffect effect) {
super(effect);
this.counterType = effect.counterType;
}
@Override
public RemoveAllCountersSourceEffect copy() {
return new RemoveAllCountersSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
int count = sourcePermanent.getCounters(game).getCount(counterType);
sourcePermanent.removeCounters(counterType.getName(), count, source, game);
return true;
}
return false;
}
}