forked from External/mage
[NCC] Implemented Gavel of the Righteous
This commit is contained in:
parent
6fd4b46ca8
commit
3e0f305e0b
5 changed files with 159 additions and 15 deletions
|
|
@ -3,6 +3,7 @@ package mage.abilities.dynamicvalue.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -15,14 +16,25 @@ public class CountersSourceCount implements DynamicValue {
|
|||
this.counterType = counterType;
|
||||
}
|
||||
|
||||
public CountersSourceCount(final CountersSourceCount countersCount) {
|
||||
protected CountersSourceCount(final CountersSourceCount countersCount) {
|
||||
this.counterType = countersCount.counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent permanent = sourceAbility.getSourcePermanentOrLKI(game);
|
||||
return permanent != null ? permanent.getCounters(game).getCount(counterType) : 0;
|
||||
if (permanent == null) {
|
||||
return 0;
|
||||
}
|
||||
return counterType != null
|
||||
? permanent
|
||||
.getCounters(game)
|
||||
.getCount(counterType)
|
||||
: permanent
|
||||
.getCounters(game)
|
||||
.values()
|
||||
.stream()
|
||||
.mapToInt(Counter::getCount).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -37,6 +49,6 @@ public class CountersSourceCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return counterType + " counter on {this}";
|
||||
return (counterType != null ? counterType.toString() + ' ' : "") + "counter on {this}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue