[BLB] Implement Byrke, Long Ear of the Law (#11860)

New common class DoubleCountersTargetEffect
This commit is contained in:
PurpleCrowbar 2024-02-26 05:12:14 +00:00 committed by GitHub
parent 0ba00620db
commit ddcd54c0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 128 additions and 191 deletions

View file

@ -0,0 +1,43 @@
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 PurpleCrowbar
*/
public class DoubleCountersTargetEffect extends OneShotEffect {
private final CounterType counterType;
public DoubleCountersTargetEffect(CounterType counterType) {
super(Outcome.Benefit);
this.counterType = counterType;
staticText = "double the number of " + counterType.getName() + " counters on it";
}
private DoubleCountersTargetEffect(final DoubleCountersTargetEffect effect) {
super(effect);
this.counterType = effect.counterType;
}
@Override
public DoubleCountersTargetEffect copy() {
return new DoubleCountersTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
return permanent.addCounters(counterType.createInstance(
permanent.getCounters(game).getCount(counterType)
), source.getControllerId(), source, game);
}
}