fixed a few recursion issues with party count computations

This commit is contained in:
Evan Kranzler 2020-09-03 20:44:24 -04:00
parent 2f809f10cc
commit d4ca4553d1

View file

@ -36,6 +36,16 @@ public enum PartyCount implements DynamicValue {
SubType.WIZARD SubType.WIZARD
); );
private static Set<SubType> makeSet(Permanent permanent, Game game) {
Set<SubType> 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<SubType> creatureTypes, Map<SubType, UUID> subTypeUUIDMap, Map<UUID, Set<SubType>> creatureTypesMap) { private static boolean attemptRearrange(SubType subType, UUID uuid, Set<SubType> creatureTypes, Map<SubType, UUID> subTypeUUIDMap, Map<UUID, Set<SubType>> creatureTypesMap) {
UUID uuid1 = subTypeUUIDMap.get(subType); UUID uuid1 = subTypeUUIDMap.get(subType);
if (uuid1 == null) { if (uuid1 == null) {
@ -51,19 +61,18 @@ public enum PartyCount implements DynamicValue {
subTypeUUIDMap.put(subType1, uuid1); subTypeUUIDMap.put(subType1, uuid1);
return true; return true;
} }
return attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap);
} }
return false; for (SubType subType1 : creatureTypes1) {
} if (subType == subType1) {
continue;
private static Set<SubType> makeSet(Permanent permanent, Game game) { }
Set<SubType> subTypeSet = new HashSet<>(); if (attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap)) {
for (SubType subType : partyTypes) { subTypeUUIDMap.put(subType, uuid);
if (permanent.hasSubtype(subType, game)) { subTypeUUIDMap.put(subType1, uuid1);
subTypeSet.add(subType); return true;
} }
} }
return subTypeSet; return false;
} }
@Override @Override