mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
fixed a few recursion issues with party count computations
This commit is contained in:
parent
2f809f10cc
commit
d4ca4553d1
1 changed files with 19 additions and 10 deletions
|
|
@ -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,21 +61,20 @@ public enum PartyCount implements DynamicValue {
|
||||||
subTypeUUIDMap.put(subType1, uuid1);
|
subTypeUUIDMap.put(subType1, uuid1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return attemptRearrange(subType1, uuid1, creatureTypes, subTypeUUIDMap, creatureTypesMap);
|
}
|
||||||
|
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||||
Map<UUID, Set<SubType>> creatureTypesMap = new HashMap<>();
|
Map<UUID, Set<SubType>> creatureTypesMap = new HashMap<>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue