From fb31bd97bb1b16f27ae15cdc9f0d77aab321aff8 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:28:08 -0400 Subject: [PATCH] Fixed Investigator's Journal not respecting range of influence. --- .../mage/cards/i/InvestigatorsJournal.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java b/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java index 3f1f730870e..3b1e5cdba2d 100644 --- a/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java +++ b/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java @@ -19,8 +19,10 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.counters.CounterType; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; /** * @@ -66,25 +68,19 @@ enum InvestigatorsJournalValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - HashMap 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; - for (Integer count : creatureCounts.values()) { - if (count > greatestCreatureCount) { - greatestCreatureCount = count; + + for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; } + + greatestCreatureCount = Math.max( + greatestCreatureCount, + game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game)); } + return greatestCreatureCount; }