From 84609b74e07392a309ff303525f86640fddc23d6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Sep 2020 18:25:59 -0400 Subject: [PATCH] fixed some errors in party count computation, should be good now --- .../dynamicvalue/common/PartyCount.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java index a0607f9dd49..c6214dea56b 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java @@ -36,10 +36,10 @@ public enum PartyCount implements DynamicValue { SubType.WIZARD ); - private void attemptRearrange(SubType subType, UUID uuid, Set creatureTypes, Map subTypeUUIDMap, Map> creatureTypesMap) { + private static boolean attemptRearrange(SubType subType, UUID uuid, Set creatureTypes, Map subTypeUUIDMap, Map> creatureTypesMap) { UUID uuid1 = subTypeUUIDMap.get(subType); if (uuid1 == null) { - return; + return false; } Set creatureTypes1 = creatureTypesMap.get(uuid1); for (SubType subType1 : creatureTypes1) { @@ -49,13 +49,14 @@ public enum PartyCount implements DynamicValue { if (!subTypeUUIDMap.containsKey(subType1)) { subTypeUUIDMap.put(subType, uuid); subTypeUUIDMap.put(subType1, uuid1); - continue; + return true; } - attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap); + return attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap); } + return false; } - private Set makeSet(Permanent permanent, Game game) { + private static Set makeSet(Permanent permanent, Game game) { Set subTypeSet = new HashSet<>(); for (SubType subType : partyTypes) { if (permanent.hasSubtype(subType, game)) { @@ -94,9 +95,13 @@ public enum PartyCount implements DynamicValue { } if (subTypeUUIDMap.size() >= availableTypes.size()) { return subTypeUUIDMap.size(); + } else if (subTypeUUIDMap.containsValue(entry.getKey())) { + continue; } else { for (SubType subType : entry.getValue()) { - attemptRearrange(subType, entry.getKey(), entry.getValue(), subTypeUUIDMap, creatureTypesMap); + if (attemptRearrange(subType, entry.getKey(), entry.getValue(), subTypeUUIDMap, creatureTypesMap)) { + break; + } } } }