Fixed Investigator's Journal not respecting range of influence.

This commit is contained in:
Alex Vasile 2022-06-27 12:28:08 -04:00
parent d09b781673
commit fb31bd97bb

View file

@ -19,8 +19,10 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -66,25 +68,19 @@ enum InvestigatorsJournalValue implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
HashMap<UUID, Integer> creatureCounts = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) {
creatureCounts.put(playerId, 0);
}
for (Permanent permanent : game.getBattlefield().getAllPermanents()) {
if (permanent.isPhasedIn() && permanent.isCreature(game)) {
UUID controllerId = permanent.getControllerId();
Integer count = creatureCounts.get(controllerId);
if (count != null) {
creatureCounts.put(controllerId, count + 1);
}
}
}
int greatestCreatureCount = 0; int greatestCreatureCount = 0;
for (Integer count : creatureCounts.values()) {
if (count > greatestCreatureCount) { for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) {
greatestCreatureCount = count; Player player = game.getPlayer(playerId);
if (player == null) {
continue;
} }
greatestCreatureCount = Math.max(
greatestCreatureCount,
game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game));
} }
return greatestCreatureCount; return greatestCreatureCount;
} }