diff options
17 files changed, 342 insertions, 26 deletions
diff --git a/src/com/dabomstew/pkrandom/Settings.java b/src/com/dabomstew/pkrandom/Settings.java index e0df7f2..fc56d6a 100644 --- a/src/com/dabomstew/pkrandom/Settings.java +++ b/src/com/dabomstew/pkrandom/Settings.java @@ -174,6 +174,8 @@ public class Settings { private int trainersForceFullyEvolvedLevel = 30;
private boolean trainersLevelModified;
private int trainersLevelModifier = 0; // -50 ~ 50
+ private boolean eliteFourUniquePokemon;
+ private int eliteFourUniquePokemonNumber = 1; // 0 ~ 2
private boolean allowTrainerAlternateFormes;
private boolean swapTrainerMegaEvos;
private int additionalBossTrainerPokemon = 0;
@@ -1622,6 +1624,22 @@ public class Settings { this.trainersLevelModifier = trainersLevelModifier;
}
+ public boolean isEliteFourUniquePokemon() {
+ return eliteFourUniquePokemon;
+ }
+ public void setEliteFourUniquePokemon(boolean eliteFourUniquePokemon) {
+ this.eliteFourUniquePokemon = eliteFourUniquePokemon;
+ }
+
+ public int getEliteFourUniquePokemonModifier() {
+ return eliteFourUniquePokemonNumber;
+ }
+
+ public void setEliteFourUniquePokemonModifier(int eliteFourUniquePokemonModifier) {
+ this.eliteFourUniquePokemonNumber = eliteFourUniquePokemonModifier;
+ }
+
+
public boolean isAllowTrainerAlternateFormes() {
return allowTrainerAlternateFormes;
}
diff --git a/src/com/dabomstew/pkrandom/constants/Gen3Constants.java b/src/com/dabomstew/pkrandom/constants/Gen3Constants.java index c5f4b62..7aa15ec 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen3Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen3Constants.java @@ -454,6 +454,10 @@ public class Gen3Constants { public static ItemList allowedItems, nonBadItems; public static List<Integer> regularShopItems, opShopItems; + public static final List<Integer> emptyEliteFourTrainers = Arrays.asList(new Integer[] { }); + public static final List<Integer> rseEliteFourTrainers = Arrays.asList(261, 262, 263, 264, 335); + public static final List<Integer> frlgEliteFourTrainers = Arrays.asList(410, 411, 412, 413, 438, 439, 440); + public static String getRunningShoesCheckPrefix(int romType) { if (romType == Gen3Constants.RomType_Ruby || romType == Gen3Constants.RomType_Sapp) { return runningShoesCheckPrefixRS; diff --git a/src/com/dabomstew/pkrandom/constants/Gen4Constants.java b/src/com/dabomstew/pkrandom/constants/Gen4Constants.java index 47a4148..ab3d2bd 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen4Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen4Constants.java @@ -702,6 +702,10 @@ public class Gen4Constants { public static ItemList allowedItems, nonBadItems; public static List<Integer> regularShopItems, opShopItems; + public static final List<Integer> emptyEliteFourTrainers = Arrays.asList(new Integer[] { }); + public static final List<Integer> dppEliteFourTrainers = Arrays.asList(261, 262, 263, 264, 267); + public static final List<Integer> hgssEliteFourTrainers = Arrays.asList(244, 245, 246, 247, 418); + public static final String shedinjaSpeciesLocator = "492080000090281C0521"; public static final int ilexForestScriptFile = 92, ilexForestStringsFile = 115; diff --git a/src/com/dabomstew/pkrandom/constants/Gen5Constants.java b/src/com/dabomstew/pkrandom/constants/Gen5Constants.java index aa1d920..49eae12 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen5Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen5Constants.java @@ -816,6 +816,10 @@ public class Gen5Constants { public static ItemList allowedItems, nonBadItems;
public static List<Integer> regularShopItems, opShopItems;
+ public static final List<Integer> emptyEliteFourTrainers = Arrays.asList(new Integer[] { });
+ public static final List<Integer> bw1EliteFourTrainers = Arrays.asList(228, 229, 230, 231, 232, 586, 587);
+ public static final List<Integer> bw2EliteFourTrainers = Arrays.asList(38, 39, 40, 41, 341);
+
public static String blackBoxLegendaryCheckPrefix1 = "79F6BAEF07B0F0BDC046", blackBoxLegendaryCheckPrefix2 = "DEDB0020C04302B0F8BDC046",
whiteBoxLegendaryCheckPrefix1 = "00F0FEF8002070BD", whiteBoxLegendaryCheckPrefix2 = "64F62EF970BD0000";
diff --git a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java index a679d0a..d78a012 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java @@ -893,6 +893,10 @@ public class Gen6Constants { public static ItemList allowedItemsXY, allowedItemsORAS, nonBadItemsXY, nonBadItemsORAS; public static List<Integer> regularShopItems, opShopItems; + public static final List<Integer> emptyEliteFourTrainers = Arrays.asList(new Integer[] { }); + public static final List<Integer> xyEliteFourTrainers = Arrays.asList(187, 269, 270, 271, 276); + public static final List<Integer> orasEliteFourTrainers = Arrays.asList(553, 554, 555, 556, 557); + static { setupAllowedItems(); } diff --git a/src/com/dabomstew/pkrandom/constants/Gen7Constants.java b/src/com/dabomstew/pkrandom/constants/Gen7Constants.java index b526631..d9f9a03 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen7Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen7Constants.java @@ -929,6 +929,10 @@ public class Gen7Constants { public static ItemList allowedItemsSM, allowedItemsUSUM, nonBadItems; public static List<Integer> regularShopItemsSM, regularShopItemsUSUM, opShopItems; + public static final List<Integer> emptyEliteFourTrainers = Arrays.asList(new Integer[] { }); + public static final List<Integer> smEliteFourTrainers = Arrays.asList(149, 152, 153, 156, 129, 413, 414); + public static final List<Integer> usumEliteFourTrainers = Arrays.asList(149, 153, 156, 489, 494, 495, 496); + static { setupAllowedItems(); } diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form index f6bb3eb..661fa69 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form @@ -2,7 +2,7 @@ <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.dabomstew.pkrandom.newgui.NewRandomizerGUI"> <grid id="27dc6" binding="mainPanel" layout-manager="GridBagLayout"> <constraints> - <xy x="7" y="20" width="1084" height="929"/> + <xy x="7" y="20" width="1084" height="1103"/> </constraints> <properties/> <border type="none"> @@ -1819,7 +1819,7 @@ </component> <component id="181e" class="javax.swing.JSpinner" binding="tpBossTrainersSpinner"> <constraints> - <grid row="10" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="11" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag top="0" left="4" bottom="0" right="0" weightx="0.0" weighty="0.0" ipadx="10"/> </constraints> <properties> @@ -1828,7 +1828,7 @@ </component> <component id="e7a99" class="javax.swing.JSpinner" binding="tpImportantTrainersSpinner"> <constraints> - <grid row="10" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="11" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag top="0" left="4" bottom="0" right="0" weightx="0.0" weighty="0.0" ipadx="10"/> </constraints> <properties> @@ -1837,7 +1837,7 @@ </component> <component id="da8e4" class="javax.swing.JSpinner" binding="tpRegularTrainersSpinner"> <constraints> - <grid row="10" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="11" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag top="0" left="4" bottom="0" right="0" weightx="0.0" weighty="0.0" ipadx="10"/> </constraints> <properties> @@ -1857,7 +1857,7 @@ </component> <component id="2918f" class="javax.swing.JLabel" binding="tpHeldItemsLabel"> <constraints> - <grid row="11" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="12" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1866,7 +1866,7 @@ </component> <component id="dad16" class="javax.swing.JCheckBox" binding="tpBossTrainersItemsCheckBox"> <constraints> - <grid row="12" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="13" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1877,7 +1877,7 @@ </component> <component id="d7d93" class="javax.swing.JCheckBox" binding="tpImportantTrainersItemsCheckBox"> <constraints> - <grid row="12" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="13" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1888,7 +1888,7 @@ </component> <component id="7fddd" class="javax.swing.JCheckBox" binding="tpRegularTrainersItemsCheckBox"> <constraints> - <grid row="12" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="13" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1899,7 +1899,7 @@ </component> <component id="31e9a" class="javax.swing.JCheckBox" binding="tpConsumableItemsOnlyCheckBox"> <constraints> - <grid row="13" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="14" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1910,7 +1910,7 @@ </component> <component id="79d6a" class="javax.swing.JCheckBox" binding="tpSensibleItemsCheckBox"> <constraints> - <grid row="13" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="14" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1921,7 +1921,7 @@ </component> <component id="f3c52" class="javax.swing.JCheckBox" binding="tpHighestLevelGetsItemCheckBox"> <constraints> - <grid row="13" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="14" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> <properties> @@ -1932,10 +1932,29 @@ </component> <vspacer id="2342a"> <constraints> - <grid row="14" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + <grid row="15" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.0"/> </constraints> </vspacer> + <component id="28e4c" class="javax.swing.JCheckBox" binding="tpEliteFourUniquePokemonCheckBox"> + <constraints> + <grid row="10" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + <properties> + <enabled value="false"/> + <text value="Elite Four have unique Pokemon:"/> + </properties> + </component> + <component id="727d5" class="javax.swing.JSpinner" binding="tpEliteFourUniquePokemonSpinner"> + <constraints> + <grid row="11" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + <properties> + <enabled value="false"/> + </properties> + </component> </children> </grid> <hspacer id="66d2"> diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java index 0396d26..a65230d 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java @@ -143,6 +143,8 @@ public class NewRandomizerGUI { private JCheckBox tpForceFullyEvolvedAtCheckBox; private JSlider tpForceFullyEvolvedAtSlider; private JSlider tpPercentageLevelModifierSlider; + private JCheckBox tpEliteFourUniquePokemonCheckBox; + private JSpinner tpEliteFourUniquePokemonSpinner; private JCheckBox tpPercentageLevelModifierCheckBox; private JRadioButton wpUnchangedRadioButton; private JRadioButton wpRandomRadioButton; @@ -436,6 +438,7 @@ public class NewRandomizerGUI { tpRandomEvenDistributionMainRadioButton.addActionListener(e -> enableOrDisableSubControls()); tpForceFullyEvolvedAtCheckBox.addActionListener(e -> enableOrDisableSubControls()); tpPercentageLevelModifierCheckBox.addActionListener(e -> enableOrDisableSubControls()); + tpEliteFourUniquePokemonCheckBox.addActionListener(e -> enableOrDisableSubControls()); wpUnchangedRadioButton.addActionListener(e -> enableOrDisableSubControls()); wpRandomRadioButton.addActionListener(e -> enableOrDisableSubControls()); wpArea1To1RadioButton.addActionListener(e -> enableOrDisableSubControls()); @@ -663,9 +666,17 @@ public class NewRandomizerGUI { 1 ); + SpinnerModel eliteFourUniquePokemonModel = new SpinnerNumberModel( + 1, + 0, + 2, + 1 + ); + tpBossTrainersSpinner.setModel(bossTrainerModel); tpImportantTrainersSpinner.setModel(importantTrainerModel); tpRegularTrainersSpinner.setModel(regularTrainerModel); + tpEliteFourUniquePokemonSpinner.setModel(eliteFourUniquePokemonModel); customNamesEditorMenuItem = new JMenuItem(); customNamesEditorMenuItem.setText(bundle.getString("GUI.customNamesEditorMenuItem.text")); @@ -1081,6 +1092,7 @@ public class NewRandomizerGUI { } + private enum SaveType { FILE, DIRECTORY, INVALID } @@ -1413,6 +1425,8 @@ public class NewRandomizerGUI { tpForceFullyEvolvedAtSlider.setValue(settings.getTrainersForceFullyEvolvedLevel()); tpPercentageLevelModifierCheckBox.setSelected(settings.isTrainersLevelModified()); tpPercentageLevelModifierSlider.setValue(settings.getTrainersLevelModifier()); + tpEliteFourUniquePokemonCheckBox.setSelected(settings.isEliteFourUniquePokemon()); + tpEliteFourUniquePokemonSpinner.setValue(settings.getEliteFourUniquePokemonModifier() > 0 ? settings.getEliteFourUniquePokemonModifier() : 1); tpAllowAlternateFormesCheckBox.setSelected(settings.isAllowTrainerAlternateFormes()); tpSwapMegaEvosCheckBox.setSelected(settings.isSwapTrainerMegaEvos()); tpDoubleBattleModeCheckBox.setSelected(settings.isDoubleBattleMode()); @@ -1647,6 +1661,8 @@ public class NewRandomizerGUI { settings.setTrainersForceFullyEvolvedLevel(tpForceFullyEvolvedAtSlider.getValue()); settings.setTrainersLevelModified(tpPercentageLevelModifierCheckBox.isSelected()); settings.setTrainersLevelModifier(tpPercentageLevelModifierSlider.getValue()); + settings.setEliteFourUniquePokemon(tpEliteFourUniquePokemonCheckBox.isSelected()); + settings.setEliteFourUniquePokemonModifier(tpEliteFourUniquePokemonCheckBox.isVisible() && tpEliteFourUniquePokemonCheckBox.isSelected() ? (int)tpEliteFourUniquePokemonSpinner.getValue() : 0); settings.setAllowTrainerAlternateFormes(tpAllowAlternateFormesCheckBox.isSelected() && tpAllowAlternateFormesCheckBox.isVisible()); settings.setSwapTrainerMegaEvos(tpSwapMegaEvosCheckBox.isSelected() && tpSwapMegaEvosCheckBox.isVisible()); settings.setDoubleBattleMode(tpDoubleBattleModeCheckBox.isVisible() && tpDoubleBattleModeCheckBox.isSelected()); @@ -2189,6 +2205,14 @@ public class NewRandomizerGUI { tpPercentageLevelModifierCheckBox.setVisible(true); tpPercentageLevelModifierCheckBox.setEnabled(false); tpPercentageLevelModifierCheckBox.setSelected(false); + + tpEliteFourUniquePokemonCheckBox.setVisible(true); + tpEliteFourUniquePokemonCheckBox.setEnabled(false); + tpEliteFourUniquePokemonCheckBox.setSelected(false); + tpEliteFourUniquePokemonSpinner.setVisible(true); + tpEliteFourUniquePokemonSpinner.setEnabled(false); + tpEliteFourUniquePokemonSpinner.setValue(1); + tpAllowAlternateFormesCheckBox.setVisible(true); tpAllowAlternateFormesCheckBox.setEnabled(false); tpAllowAlternateFormesCheckBox.setSelected(false); diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java index ae9dc53..f52f0d3 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java @@ -1568,8 +1568,59 @@ public abstract class AbstractRomHandler implements RomHandler { // New: randomize the order trainers are randomized in. // Leads to less predictable results for various modifiers. // Need to keep the original ordering around for saving though. - List<Trainer> scrambledTrainers = new ArrayList<>(currentTrainers); - Collections.shuffle(scrambledTrainers, this.random); + + List<Trainer> scrambledTrainers = new ArrayList<>(); + + // If Elite 4 setting was checked, then created scrambledTrainers + // to have Elite 4 & Champion at the start of the list + // Start of the list is important, so that priority goes to placing + // pokemon on them first, then adding those pokemon to the banlist + + + boolean tempSettingsFlag = true; + int tempSettingsE4Num = 2; + + List<Trainer> eliteFourTrainers = new ArrayList<>(); + + if (tempSettingsFlag) { + // first find the + List<Integer> eliteFourIndices = getEliteFourTrainers(); + + for (int i : eliteFourIndices){ + // find matching trainer for Elite Four + Trainer t = currentTrainers.get(i - 1); + eliteFourTrainers.add(t); + System.out.println(t.fullDisplayName); + } + // commit eliteFourTrainers to scrambledTrainers first + scrambledTrainers.addAll(eliteFourTrainers); + + + // add all trainers not in eliteFourTrainers to scrambled remaining trainers (temp list) + + List<Trainer> scrambledRemainingTrainers = new ArrayList<>(); + for (Trainer t: currentTrainers) { + if (!eliteFourTrainers.contains(t)) { + scrambledRemainingTrainers.add(t); + } + } + // scramble the remaining trainers + Collections.shuffle(scrambledRemainingTrainers, this.random); + + // add the remaining trainers to the elite four list + scrambledTrainers.addAll(scrambledRemainingTrainers); + + } + + else { + // Otherwise, scramble all together + scrambledTrainers.addAll(currentTrainers); + Collections.shuffle(scrambledTrainers, this.random); + } + +// if (currentTrainers.size == scrambledTrainers.size) { +// throw new Exception("ERROR ON TRAINER LIST SIZE"); +// } cachedReplacementLists = new TreeMap<>(); cachedAllList = noLegendaries ? new ArrayList<>(noLegendaryList) : new ArrayList<>( @@ -1583,6 +1634,8 @@ public abstract class AbstractRomHandler implements RomHandler { .stream() .filter(pk -> !pk.actuallyCosmetic) .collect(Collectors.toList()); + + List<Integer> mainPlaythroughTrainers = getMainPlaythroughTrainers(); List<Pokemon> banned = this.getBannedFormesForTrainerPokemon(); @@ -1595,6 +1648,7 @@ public abstract class AbstractRomHandler implements RomHandler { } cachedAllList.removeAll(banned); + // Fully random is easy enough - randomize then worry about rival // carrying starter at the end for (Trainer t : scrambledTrainers) { @@ -1604,14 +1658,46 @@ public abstract class AbstractRomHandler implements RomHandler { // starter, so we can't change it here. Just skip it continue; } + + // in order for Elite Four to not have the same pokemon twice + // we must keep track of each pokemon placed and provide it + // as a parameter for pick replacement function + // however, not all of them are added to the global ban list + // so we keep track of the list per trainer, and discard once + // the trainer is finished. in this case, just E4 trainers + + boolean eliteFourTrackPokemon = false; + List<Pokemon> eliteFourPlacedPokemon = new ArrayList<>(); + if ( (tempSettingsFlag) && (eliteFourTrainers.contains(t)) ) { + eliteFourTrackPokemon = true; + } + for (TrainerPokemon tp : t.pokemon) { boolean swapThisMegaEvo = swapMegaEvos && tp.canMegaEvolve(); boolean wgAllowed = (!noEarlyWonderGuard) || tp.level >= 20; + Pokemon newPK; Pokemon oldPK = tp.pokemon; if (tp.forme > 0) { oldPK = getAltFormeOfPokemon(oldPK, tp.forme); } + + // this code checks to see if eliteFour setting is on + // if so, then check the size of the trainer's pokemon + // and apply the eliteFour settings when the pokemon + // are at the end of the list, up to the setting's + // number of pokemon to apply the setting to + + // e.g., setting is to apply 2 unique pokemon to an Elite 4 trainer + // with 5 pokemon. this will apply unique pokemon to #4 and #5 + boolean eliteFourSetUniquePokemon = false; + if (tempSettingsFlag) { + if (((t.pokemon.size() - t.pokemon.indexOf(tp)) <= Math.min(t.pokemon.size(), tempSettingsE4Num)) && (eliteFourTrainers.contains(t)) ) { + eliteFourSetUniquePokemon = true; + } + } + + // new code for distribution with mainplaythrough balancing // what we do is check each trainer if they're part of the main playthrough // if so, add to placement history, if not, pure random @@ -1630,13 +1716,20 @@ public abstract class AbstractRomHandler implements RomHandler { swapThisMegaEvo, abilitiesAreRandomized, includeFormes, - banIrregularAltFormes + banIrregularAltFormes, + eliteFourPlacedPokemon ); setPlacementHistory(newPK); tp.absolutePokeNumber = newPK.number; tp.pokemon = newPK; setFormeForTrainerPokemon(tp, newPK); tp.abilitySlot = getRandomAbilitySlot(newPK); + if (eliteFourSetUniquePokemon) { + removeEvolutionChainFromPool(newPK); + } + if (eliteFourTrackPokemon) { + eliteFourPlacedPokemon.add(newPK); + } } else { // pure random when trainer not in pool newPK = @@ -1650,12 +1743,19 @@ public abstract class AbstractRomHandler implements RomHandler { swapThisMegaEvo, abilitiesAreRandomized, includeFormes, - banIrregularAltFormes + banIrregularAltFormes, + eliteFourPlacedPokemon ); tp.absolutePokeNumber = newPK.number; tp.pokemon = newPK; setFormeForTrainerPokemon(tp, newPK); tp.abilitySlot = getRandomAbilitySlot(newPK); + if (eliteFourSetUniquePokemon) { + removeEvolutionChainFromPool(newPK); + } + if (eliteFourTrackPokemon) { + eliteFourPlacedPokemon.add(newPK); + } } } else { newPK = @@ -1669,7 +1769,8 @@ public abstract class AbstractRomHandler implements RomHandler { swapThisMegaEvo, abilitiesAreRandomized, includeFormes, - banIrregularAltFormes + banIrregularAltFormes, + eliteFourPlacedPokemon ); if (distributionSetting) { setPlacementHistory(newPK); @@ -1678,6 +1779,12 @@ public abstract class AbstractRomHandler implements RomHandler { tp.pokemon = newPK; setFormeForTrainerPokemon(tp, newPK); tp.abilitySlot = getRandomAbilitySlot(newPK); + if (eliteFourSetUniquePokemon) { + removeEvolutionChainFromPool(newPK); + } + if (eliteFourTrackPokemon) { + eliteFourPlacedPokemon.add(newPK); + } } if (swapThisMegaEvo) { @@ -1698,6 +1805,48 @@ public abstract class AbstractRomHandler implements RomHandler { // Save it all up this.setTrainers(currentTrainers, false); } + private void removeEvolutionChainFromPool(Pokemon newPK) { + + cachedAllList.remove(newPK); + permanentlyBannedList.add(newPK); + // System.out.println("Removed " + newPK.name); + + // first remove any evolutionFrom (aka, Pokemon that newPK will evolve into + if (newPK.evolutionsFrom.size() > 0) { + for (Evolution evo: newPK.evolutionsFrom) { + Pokemon pkToRemove = evo.to; + if (cachedAllList.contains(pkToRemove)) { + cachedAllList.remove(pkToRemove); + // System.out.println("Removed stage 1 evolution " + pkToRemove.name); + } + } + } + + // then remove any evolutionTo (preevolutions, 2 stages down) + if (newPK.evolutionsTo.size() > 0) { + for (Evolution evo: newPK.evolutionsTo) { + Pokemon pkToRemove = evo.from; + if (cachedAllList.contains(pkToRemove)) { + cachedAllList.remove(pkToRemove); + // System.out.println("Removed stage 1 pre-evo " + pkToRemove.name); + for (Evolution evo2 : pkToRemove.evolutionsTo) { + Pokemon pkToRemove2 = evo2.from; + if (cachedAllList.contains(pkToRemove2)) { + cachedAllList.remove(pkToRemove2); + // System.out.println("Removed stage 2 pre-evo " + pkToRemove2.name); + } + else { + // System.out.println("Stage 2 pre-evo " + pkToRemove2.name + " not in pool any more, not removing"); + } + } + } + else { + // System.out.println("Stage 1 pre-evo " + pkToRemove.name + " not in pool any more, not removing"); + } + } + } + } + private void setFormeForTrainerPokemon(TrainerPokemon tp, Pokemon pk) { boolean checkCosmetics = true; @@ -1846,7 +1995,9 @@ public abstract class AbstractRomHandler implements RomHandler { swapThisMegaEvo, abilitiesAreRandomized, includeFormes, - banIrregularAltFormes + banIrregularAltFormes, + new ArrayList<>() + ); tp.absolutePokeNumber = newPK.number; tp.pokemon = newPK; @@ -1909,7 +2060,8 @@ public abstract class AbstractRomHandler implements RomHandler { swapThisMegaEvo, abilitiesAreRandomized, includeFormes, - banIrregularAltFormes + banIrregularAltFormes, + new ArrayList<>() ); tp.absolutePokeNumber = newPK.number; tp.pokemon = newPK; @@ -6065,10 +6217,13 @@ public abstract class AbstractRomHandler implements RomHandler { private Map<Type, List<Pokemon>> cachedReplacementLists; private List<Pokemon> cachedAllList; + private List<Pokemon> permanentlyBannedList = new ArrayList<>(); + private Pokemon pickReplacement(Pokemon current, boolean usePowerLevels, Type type, boolean noLegendaries, boolean wonderGuardAllowed, boolean usePlacementHistory, boolean swapMegaEvos, - boolean abilitiesAreRandomized, boolean allowAltFormes, boolean banIrregularAltFormes) { + boolean abilitiesAreRandomized, boolean allowAltFormes, boolean banIrregularAltFormes, + List<Pokemon> eliteFourPlacedPokemon) { List<Pokemon> pickFrom; if (swapMegaEvos) { pickFrom = megaEvolutionsList @@ -6090,6 +6245,13 @@ public abstract class AbstractRomHandler implements RomHandler { pickFrom = cachedAllList; } } + // simply not allow Elite Four to place pokemon more than once + // this list is only ever non-empty under specific settings + // it tracks for 1 trainer, if they were elite four, + // all the pokemon that trainer has placed, to avoid duplicates + // in almost all cases, it will be empty (since most trainers are not e4) + pickFrom.removeAll(eliteFourPlacedPokemon); + if (type != null) { if (!cachedReplacementLists.containsKey(type)) { // System.out.println(current.name + " using cachedReplacementLists"); @@ -6486,7 +6648,6 @@ public abstract class AbstractRomHandler implements RomHandler { private void setPlacementHistory(Pokemon newPK) { Integer history = getPlacementHistory(newPK); -// System.out.println("Current history: " + newPK.name + " : " + history); placementHistory.put(newPK, history + 1); } @@ -6525,12 +6686,8 @@ public abstract class AbstractRomHandler implements RomHandler { for (Pokemon newPK : allPK) { if (placedPK.contains(newPK)) { // if it's in the list of previously placed, then check its viability if (placementHistory.get(newPK) <= placedAverage) { -// System.out.println(newPK.name + ": " + placementHistory.get(newPK)+" "+placedAverage+" ACCEPT"); toPlacePK.add(newPK); } - else { -// System.out.println(newPK.name + ": " + placementHistory.get(newPK)+" "+placedAverage+" REJECT"); - } } else { toPlacePK.add(newPK); // if not placed at all, automatically flag true for placing @@ -6538,7 +6695,6 @@ public abstract class AbstractRomHandler implements RomHandler { } } - // System.out.println("Size: " + toPlacePK.size()); return toPlacePK; } diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java index c6869d6..6f03e67 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java @@ -1097,6 +1097,11 @@ public class Gen1RomHandler extends AbstractGBCRomHandler { return new ArrayList<>(); // Not implemented
}
+ @Override
+ public List<Integer> getEliteFourTrainers() {
+ return new ArrayList<>();
+ }
+
public void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode) {
int traineroffset = romEntry.getValue("TrainerDataTableOffset");
int traineramount = Gen1Constants.trainerClassCount;
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java index a3810cb..1fd707d 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java @@ -922,6 +922,11 @@ public class Gen2RomHandler extends AbstractGBCRomHandler { }
@Override
+ public List<Integer> getEliteFourTrainers() {
+ return new ArrayList<>();
+ }
+
+ @Override
public void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode) {
int traineroffset = romEntry.getValue("TrainerDataTableOffset");
int traineramount = romEntry.getValue("TrainerClassAmount");
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java index ae1a3c8..b8c54fc 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java @@ -1513,6 +1513,20 @@ public class Gen3RomHandler extends AbstractGBRomHandler { } @Override + public List<Integer> getEliteFourTrainers() { + if (romEntry.romType == Gen3Constants.RomType_Ruby | romEntry.romType == Gen3Constants.RomType_Sapp | romEntry.romType == Gen3Constants.RomType_Em) { + return Gen3Constants.rseEliteFourTrainers; + } + else if (romEntry.romType == Gen3Constants.RomType_FRLG) { + return Gen3Constants.frlgEliteFourTrainers; + } + else { + return Gen3Constants.emptyEliteFourTrainers; + } + } + + + @Override public void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode) { int baseOffset = romEntry.getValue("TrainerData"); int amount = romEntry.getValue("TrainerCount"); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index 1f6bd1b..7fc5b14 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -2489,6 +2489,19 @@ public class Gen4RomHandler extends AbstractDSRomHandler { }
@Override
+ public List<Integer> getEliteFourTrainers() {
+ if (romEntry.romType == Gen4Constants.Type_DP | romEntry.romType == Gen4Constants.Type_Plat) {
+ return Gen4Constants.dppEliteFourTrainers;
+ }
+ else if (romEntry.romType == Gen4Constants.Type_HGSS) {
+ return Gen4Constants.hgssEliteFourTrainers;
+ }
+ else {
+ return Gen4Constants.emptyEliteFourTrainers;
+ }
+ }
+
+ @Override
public List<Integer> getEvolutionItems() {
return Gen4Constants.evolutionItems;
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java index 0822a19..3d756a6 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java @@ -1445,6 +1445,20 @@ public class Gen5RomHandler extends AbstractDSRomHandler { }
@Override
+ public List<Integer> getEliteFourTrainers() {
+ if (romEntry.romType == Gen5Constants.Type_BW) {
+ return Gen5Constants.bw1EliteFourTrainers;
+ }
+ else if (romEntry.romType == Gen5Constants.Type_BW2) {
+ return Gen5Constants.bw2EliteFourTrainers;
+ }
+ else {
+ return Gen5Constants.emptyEliteFourTrainers;
+ }
+ }
+
+
+ @Override
public List<Integer> getEvolutionItems() {
return Gen5Constants.evolutionItems;
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java index 5fa2140..7db767f 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java @@ -1879,6 +1879,19 @@ public class Gen6RomHandler extends Abstract3DSRomHandler { } @Override + public List<Integer> getEliteFourTrainers() { + if (romEntry.romType == Gen6Constants.Type_XY) { + return Gen6Constants.xyEliteFourTrainers; + } + else if (romEntry.romType == Gen6Constants.Type_ORAS) { + return Gen6Constants.orasEliteFourTrainers; + } + else { + return Gen6Constants.emptyEliteFourTrainers; + } + } + + @Override public List<Integer> getEvolutionItems() { return Gen6Constants.evolutionItems; } diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java index 6cdd19f..166f68b 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java @@ -1593,6 +1593,19 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { } @Override + public List<Integer> getEliteFourTrainers() { + if (romEntry.romType == Gen7Constants.Type_SM) { + return Gen7Constants.smEliteFourTrainers; + } + else if (romEntry.romType == Gen3Constants.RomType_FRLG) { + return Gen7Constants.usumEliteFourTrainers; + } + else { + return Gen7Constants.emptyEliteFourTrainers; + } + } + + @Override public void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode) { Iterator<Trainer> allTrainers = trainerData.iterator(); try { diff --git a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java index a0f5dd6..bbccb54 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java @@ -243,6 +243,8 @@ public interface RomHandler { List<Integer> getMainPlaythroughTrainers();
+ List<Integer> getEliteFourTrainers();
+
void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode);
void randomizeTrainerPokes(Settings settings);
|