From d4ca4553d1e34de1af35a3d65a759f78c377a9da Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Sep 2020 20:44:24 -0400 Subject: [PATCH] fixed a few recursion issues with party count computations --- .../dynamicvalue/common/PartyCount.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 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 5b9c893577..4493d05f58 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/PartyCount.java @@ -36,6 +36,16 @@ public enum PartyCount implements DynamicValue { SubType.WIZARD ); + private static Set makeSet(Permanent permanent, Game game) { + Set subTypeSet = new HashSet<>(); + for (SubType subType : partyTypes) { + if (permanent.hasSubtype(subType, game)) { + subTypeSet.add(subType); + } + } + return subTypeSet; + } + private static boolean attemptRearrange(SubType subType, UUID uuid, Set creatureTypes, Map subTypeUUIDMap, Map> creatureTypesMap) { UUID uuid1 = subTypeUUIDMap.get(subType); if (uuid1 == null) { @@ -51,19 +61,18 @@ public enum PartyCount implements DynamicValue { subTypeUUIDMap.put(subType1, uuid1); return true; } - return attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap); } - return false; - } - - private static Set makeSet(Permanent permanent, Game game) { - Set subTypeSet = new HashSet<>(); - for (SubType subType : partyTypes) { - if (permanent.hasSubtype(subType, game)) { - subTypeSet.add(subType); + for (SubType subType1 : creatureTypes1) { + if (subType == subType1) { + continue; + } + if (attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap)) { + subTypeUUIDMap.put(subType, uuid); + subTypeUUIDMap.put(subType1, uuid1); + return true; } } - return subTypeSet; + return false; } @Override