refactor together experience counter DynamicValue

This commit is contained in:
Susucre 2024-05-01 21:54:19 +02:00
parent 8843bd387f
commit 74adbf222c
6 changed files with 129 additions and 145 deletions

View file

@ -0,0 +1,48 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
/**
* @author Susucr
*/
public enum SourceControllerCountersCount implements DynamicValue {
EXPERIENCE(CounterType.EXPERIENCE),
RAD(CounterType.RAD);
private final CounterType counterType;
SourceControllerCountersCount(CounterType counterType) {
this.counterType = counterType;
}
@Override
public SourceControllerCountersCount copy() {
return this;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int amount = 0;
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {
amount = player.getCounters().getCount(counterType);
}
return amount;
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return counterType.getName() + " you have";
}
}