diff options
Diffstat (limited to 'src/com')
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java index d139998..edf7b50 100755 --- a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java @@ -637,6 +637,37 @@ public abstract class AbstractRomHandler implements RomHandler { } } + private int pickRandomAbilityVariation(int selectedAbility, int... alreadySetAbilities) { + int newAbility = selectedAbility; + + while (true) { + Map<Integer, List<Integer>> abilityVariations = getAbilityVariations(); + for (int baseAbility: abilityVariations.keySet()) { + if (selectedAbility == baseAbility) { + List<Integer> variationsForThisAbility = abilityVariations.get(selectedAbility); + newAbility = variationsForThisAbility.get(this.random.nextInt(variationsForThisAbility.size())); + break; + } + } + + boolean repeat = false; + for (int alreadySetAbility : alreadySetAbilities) { + if (alreadySetAbility == newAbility) { + repeat = true; + break; + } + } + + if (!repeat) { + break; + } + + + } + + return newAbility; + } + private int pickRandomAbility(int maxAbility, List<Integer> bannedAbilities, boolean useVariations, int... alreadySetAbilities) { int newAbility; @@ -658,14 +689,7 @@ public abstract class AbstractRomHandler implements RomHandler { if (!repeat) { if (useVariations) { - Map<Integer,List<Integer>> abilityVariations = getAbilityVariations(); - for (int baseAbility: abilityVariations.keySet()) { - if (newAbility == baseAbility) { - List<Integer> variationsForThisAbility = abilityVariations.get(newAbility); - newAbility = variationsForThisAbility.get(this.random.nextInt(variationsForThisAbility.size())); - break; - } - } + newAbility = pickRandomAbilityVariation(newAbility, alreadySetAbilities); } break; } @@ -5268,6 +5292,14 @@ public abstract class AbstractRomHandler implements RomHandler { Collections.shuffle(newItems, this.random); Collections.shuffle(newTMs, this.random); + List<Integer> oldItems = this.getRegularFieldItems(); + String[] itemNames = this.getItemNames(); + for (int i = 0; i < oldItems.size(); i++) { + String oldName = itemNames[oldItems.get(i)]; + String newName = itemNames[newItems.get(i)]; + System.out.println(oldName + " => " + newName); + } + this.setRegularFieldItems(newItems); this.setFieldTMs(newTMs); } |