diff options
Diffstat (limited to 'src/com/dabomstew/pkrandom')
21 files changed, 376 insertions, 398 deletions
diff --git a/src/com/dabomstew/pkrandom/Settings.java b/src/com/dabomstew/pkrandom/Settings.java index fc56d6a..b1adda0 100644 --- a/src/com/dabomstew/pkrandom/Settings.java +++ b/src/com/dabomstew/pkrandom/Settings.java @@ -49,7 +49,7 @@ public class Settings { public static final int VERSION = Version.VERSION;
- public static final int LENGTH_OF_SETTINGS_DATA = 50;
+ public static final int LENGTH_OF_SETTINGS_DATA = 51;
private CustomNamesSet customNames;
@@ -174,8 +174,7 @@ 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 int eliteFourUniquePokemonNumber = 0; // 0 ~ 2
private boolean allowTrainerAlternateFormes;
private boolean swapTrainerMegaEvos;
private int additionalBossTrainerPokemon = 0;
@@ -576,6 +575,9 @@ public class Settings { pickupItemsMod == PickupItemsMod.UNCHANGED, banBadRandomPickupItems,
banIrregularAltFormes));
+ // 50 elite four unique pokemon (3 bits)
+ out.write(eliteFourUniquePokemonNumber);
+
try {
byte[] romName = this.romName.getBytes("US-ASCII");
out.write(romName.length);
@@ -861,6 +863,8 @@ public class Settings { settings.setBanBadRandomPickupItems(restoreState(data[49], 2));
settings.setBanIrregularAltFormes(restoreState(data[49], 3));
+ settings.setEliteFourUniquePokemonNumber(data[50] & 0x7);
+
int romNameLength = data[LENGTH_OF_SETTINGS_DATA] & 0xFF;
String romName = new String(data, LENGTH_OF_SETTINGS_DATA + 1, romNameLength, "US-ASCII");
settings.setRomName(romName);
@@ -1624,19 +1628,12 @@ public class Settings { this.trainersLevelModifier = trainersLevelModifier;
}
- public boolean isEliteFourUniquePokemon() {
- return eliteFourUniquePokemon;
- }
- public void setEliteFourUniquePokemon(boolean eliteFourUniquePokemon) {
- this.eliteFourUniquePokemon = eliteFourUniquePokemon;
- }
-
- public int getEliteFourUniquePokemonModifier() {
+ public int getEliteFourUniquePokemonNumber() {
return eliteFourUniquePokemonNumber;
}
- public void setEliteFourUniquePokemonModifier(int eliteFourUniquePokemonModifier) {
- this.eliteFourUniquePokemonNumber = eliteFourUniquePokemonModifier;
+ public void setEliteFourUniquePokemonNumber(int eliteFourUniquePokemonNumber) {
+ this.eliteFourUniquePokemonNumber = eliteFourUniquePokemonNumber;
}
diff --git a/src/com/dabomstew/pkrandom/config/gen3_offsets.ini b/src/com/dabomstew/pkrandom/config/gen3_offsets.ini index e376248..a02efda 100755 --- a/src/com/dabomstew/pkrandom/config/gen3_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen3_offsets.ini @@ -21,6 +21,7 @@ TrainerClassCount=58 TrainerClassNameLength=13 TrainerNameLength=12 DoublesTrainerClasses=[27, 42, 55, 56, 57] +EliteFourIndices=[261, 262, 263, 264, 335] ItemData=0x3C5564 ItemCount=348 ItemEntrySize=44 @@ -304,6 +305,7 @@ TrainerClassCount=66 TrainerClassNameLength=13 TrainerNameLength=12 DoublesTrainerClasses=[34, 46, 55, 56, 57] +EliteFourIndices=[261, 262, 263, 264, 335] ItemEntrySize=44 ItemCount=376 MoveCount=354 @@ -432,6 +434,7 @@ TrainerClassCount=107 TrainerClassNameLength=13 TrainerNameLength=12 DoublesTrainerClasses=[26, 40, 52, 53, 54, 92, 93, 94, 95, 96] +EliteFourIndices=[410, 411, 412, 413, 438, 439, 440] ItemEntrySize=44 ItemCount=374 MoveCount=354 diff --git a/src/com/dabomstew/pkrandom/config/gen4_offsets.ini b/src/com/dabomstew/pkrandom/config/gen4_offsets.ini index b55522d..f225d43 100755 --- a/src/com/dabomstew/pkrandom/config/gen4_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen4_offsets.ini @@ -35,6 +35,7 @@ PokemonNamesTextOffset=362 TrainerNamesTextOffset=559 TrainerClassesTextOffset=560 DoublesTrainerClasses=[8, 23, 31, 47, 70, 82] +EliteFourIndices=[261, 262, 263, 264, 267] MoveDescriptionsTextOffset=587 MoveNamesTextOffset=588 AbilityNamesTextOffset=552 @@ -288,6 +289,7 @@ PokemonNamesTextOffset=237 TrainerNamesTextOffset=729 TrainerClassesTextOffset=730 DoublesTrainerClasses=[8, 121, 122] +EliteFourIndices=[244, 245, 246, 247, 418] MoveDescriptionsTextOffset=749 MoveNamesTextOffset=750 AbilityNamesTextOffset=720 diff --git a/src/com/dabomstew/pkrandom/config/gen5_offsets.ini b/src/com/dabomstew/pkrandom/config/gen5_offsets.ini index e346bee..5574c4b 100755 --- a/src/com/dabomstew/pkrandom/config/gen5_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen5_offsets.ini @@ -46,6 +46,7 @@ PokemonNamesTextOffset=70 TrainerNamesTextOffset=190
TrainerClassesTextOffset=191
DoublesTrainerClasses=[16, 63, 68, 69]
+EliteFourIndices=[228, 229, 230, 231, 232, 587]
TrainerMugshotsTextOffset=176
MoveDescriptionsTextOffset=202
MoveNamesTextOffset=203
@@ -148,6 +149,7 @@ NationalDexAtStartTweak=national_dex/bw1_national_dex TradesUnused=[0,2,7,8,9,10,11,12]
ShopItemOffsets=[0x51530,0x51534,0x5153E,0x51544,0x5155C,0x51588,0x515DC,0x515EA,0x515F8,0x51608,0x51618,0x51628,0x51638,0x51648,0x5165A,0x5166C,0x5167E,0x51694,0x516AA,0x516C0,0x516F0,0x5170C,0x5172C,0x5176C,0x5178E,0x517B2]
BoxLegendaryOffset=16
+EliteFourIndices=[228, 229, 230, 231, 232, 586]
IsBlack=0
SpecialMusicStatics=[494,571,637,638,639,640,642,644,645,646]
Arm9CRC32=A6BA89D8
@@ -216,6 +218,8 @@ PokemonNamesTextOffset=90 TrainerNamesTextOffset=382
TrainerClassesTextOffset=383
TrainerMugshotsTextOffset=368
+EliteFourIndices=[38, 39, 40, 41, 341]
+ChallengeModeEliteFourIndices=[772,773,774,775,776]
MoveDescriptionsTextOffset=402
MoveNamesTextOffset=403
AbilityNamesTextOffset=374
diff --git a/src/com/dabomstew/pkrandom/config/gen6_offsets.ini b/src/com/dabomstew/pkrandom/config/gen6_offsets.ini index c338251..3b96a9e 100644 --- a/src/com/dabomstew/pkrandom/config/gen6_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen6_offsets.ini @@ -57,6 +57,7 @@ TrainerNamesTextOffset=21 TrainerClassesTextOffset=20 TrainerMugshotsTextOffset=22 DoublesTrainerClasses=[8, 26, 46, 52, 71, 72, 97, 99, 106] +EliteFourIndices=[187, 269, 270, 271, 276] FieldItemsScriptNumber=17 FieldItemsOffset=0xB04 HiddenItemsScriptNumber=26 @@ -152,6 +153,7 @@ TrainerNamesTextOffset=22 TrainerClassesTextOffset=21 TrainerMugshotsTextOffset=23 DoublesTrainerClasses=[8, 26, 46, 52, 71, 72, 97, 99, 106, 133, 173, 188, 193, 206, 210, 211, 223, 226, 231] +EliteFourIndices=[553, 554, 555, 556, 557] FieldItemsScriptNumber=39 FieldItemsOffset=0xB64 ShopItemSizes=[3, 10, 14, 17, 18, 19, 19, 19, 19, 1, 9, 6, 4, 3, 8, 8, 3, 3, 4, 3, 6, 8, 7, 4] diff --git a/src/com/dabomstew/pkrandom/config/gen7_offsets.ini b/src/com/dabomstew/pkrandom/config/gen7_offsets.ini index 2b7b366..85f6a29 100644 --- a/src/com/dabomstew/pkrandom/config/gen7_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen7_offsets.ini @@ -54,6 +54,7 @@ ShopCount=24 TMShops=[12,13,16,18,19] RegularShops=[0,1,2,3,4,5,6,7] DoublesTrainerClasses=[172, 173, 174, 174, 175, 176, 177, 178, 179, 181, 182] +EliteFourIndices=[149, 152, 153, 156, 129, 413, 414] CosmoemEvolutionNumber=791 LinkedStaticEncounterOffsets=[112:113, 120:131, 124:130] // UBs probably need to be added to this too MainGameLegendaries=[791] @@ -128,6 +129,7 @@ ShopCount=28 TMShops=[12,13,16,18,19] RegularShops=[0,1,2,3,4,5,6,7] DoublesTrainerClasses=[172, 173, 174, 174, 175, 176, 177, 178, 179, 181, 182, 211, 212, 213, 214, 215] +EliteFourIndices=[149, 153, 156, 489, 494, 495, 496] CosmoemEvolutionNumber=791 LinkedStaticEncounterOffsets=[127:128, 135:146, 139:145] // Unused SM UBs need to be added to this, probably other stuff too MainGameLegendaries=[800] diff --git a/src/com/dabomstew/pkrandom/constants/Gen3Constants.java b/src/com/dabomstew/pkrandom/constants/Gen3Constants.java index 7aa15ec..c5f4b62 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen3Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen3Constants.java @@ -454,10 +454,6 @@ 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 ab3d2bd..47a4148 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen4Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen4Constants.java @@ -702,10 +702,6 @@ 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 49eae12..aa1d920 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen5Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen5Constants.java @@ -816,10 +816,6 @@ 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 d78a012..2706dc4 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java @@ -23,10 +23,7 @@ package com.dabomstew.pkrandom.constants; /*-- along with this program. If not, see <http://www.gnu.org/licenses/>. --*/ /*----------------------------------------------------------------------------*/ -import com.dabomstew.pkrandom.pokemon.ItemList; -import com.dabomstew.pkrandom.pokemon.MoveCategory; -import com.dabomstew.pkrandom.pokemon.Trainer; -import com.dabomstew.pkrandom.pokemon.Type; +import com.dabomstew.pkrandom.pokemon.*; import java.util.*; import java.util.stream.Collectors; @@ -893,10 +890,6 @@ 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 d9f9a03..b526631 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen7Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen7Constants.java @@ -929,10 +929,6 @@ 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.java b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java index a65230d..f6de4e6 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java @@ -668,7 +668,7 @@ public class NewRandomizerGUI { SpinnerModel eliteFourUniquePokemonModel = new SpinnerNumberModel( 1, - 0, + 1, 2, 1 ); @@ -1425,8 +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); + tpEliteFourUniquePokemonCheckBox.setSelected(settings.getEliteFourUniquePokemonNumber() > 0); + tpEliteFourUniquePokemonSpinner.setValue(settings.getEliteFourUniquePokemonNumber() > 0 ? settings.getEliteFourUniquePokemonNumber() : 1); tpAllowAlternateFormesCheckBox.setSelected(settings.isAllowTrainerAlternateFormes()); tpSwapMegaEvosCheckBox.setSelected(settings.isSwapTrainerMegaEvos()); tpDoubleBattleModeCheckBox.setSelected(settings.isDoubleBattleMode()); @@ -1661,8 +1661,7 @@ 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.setEliteFourUniquePokemonNumber(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()); @@ -3225,6 +3224,8 @@ public class NewRandomizerGUI { tpSensibleItemsCheckBox.setSelected(false); tpHighestLevelGetsItemCheckBox.setEnabled(false); tpHighestLevelGetsItemCheckBox.setSelected(false); + tpEliteFourUniquePokemonCheckBox.setEnabled(false); + tpEliteFourUniquePokemonCheckBox.setSelected(false); } else { tpSimilarStrengthCheckBox.setEnabled(true); tpDontUseLegendariesCheckBox.setEnabled(true); @@ -3245,6 +3246,7 @@ public class NewRandomizerGUI { tpBossTrainersItemsCheckBox.setEnabled(tpBossTrainersItemsCheckBox.isVisible()); tpImportantTrainersItemsCheckBox.setEnabled(tpImportantTrainersItemsCheckBox.isVisible()); tpRegularTrainersItemsCheckBox.setEnabled(tpRegularTrainersItemsCheckBox.isVisible()); + tpEliteFourUniquePokemonCheckBox.setEnabled(tpEliteFourUniquePokemonCheckBox.isVisible()); } if (tpForceFullyEvolvedAtCheckBox.isSelected()) { @@ -3307,6 +3309,13 @@ public class NewRandomizerGUI { tpWeightTypesCheckBox.setSelected(false); } + if (tpEliteFourUniquePokemonCheckBox.isSelected()) { + tpEliteFourUniquePokemonSpinner.setEnabled(true); + } else { + tpEliteFourUniquePokemonSpinner.setEnabled(false); + tpEliteFourUniquePokemonSpinner.setValue(1); + } + if (!totpUnchangedRadioButton.isSelected() || !totpAllyUnchangedRadioButton.isSelected()) { totpAllowAltFormesCheckBox.setEnabled(true); } else { diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java index f52f0d3..3a40648 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java @@ -1553,76 +1553,30 @@ public abstract class AbstractRomHandler implements RomHandler { boolean noLegendaries = settings.isTrainersBlockLegendaries(); boolean noEarlyWonderGuard = settings.isTrainersBlockEarlyWonderGuard(); int levelModifier = settings.isTrainersLevelModified() ? settings.getTrainersLevelModifier() : 0; - boolean distributionSetting = - settings.getTrainersMod() == Settings.TrainersMod.DISTRIBUTED || - settings.getTrainersMod() == Settings.TrainersMod.MAINPLAYTHROUGH; + boolean distributionSetting = settings.getTrainersMod() == Settings.TrainersMod.DISTRIBUTED; boolean mainPlaythroughSetting = settings.getTrainersMod() == Settings.TrainersMod.MAINPLAYTHROUGH; boolean includeFormes = settings.isAllowTrainerAlternateFormes(); boolean banIrregularAltFormes = settings.isBanIrregularAltFormes(); boolean swapMegaEvos = settings.isSwapTrainerMegaEvos(); boolean shinyChance = settings.isShinyChance(); boolean abilitiesAreRandomized = settings.getAbilitiesMod() == Settings.AbilitiesMod.RANDOMIZE; + int eliteFourUniquePokemonNumber = settings.getEliteFourUniquePokemonNumber(); + boolean forceFullyEvolved = settings.isTrainersForceFullyEvolved(); + int forceFullyEvolvedLevel = settings.getTrainersForceFullyEvolvedLevel(); + boolean forceChallengeMode = (settings.getCurrentMiscTweaks() & MiscTweak.FORCE_CHALLENGE_MODE.getValue()) > 0; + boolean rivalCarriesStarter = settings.isRivalCarriesStarterThroughout(); + List<Pokemon> starterList = getStarters().subList(0,3); checkPokemonRestrictions(); List<Trainer> currentTrainers = this.getTrainers(); - // New: randomize the order trainers are randomized in. + // 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<>(); - - // 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"); -// } + List<Trainer> scrambledTrainers = new ArrayList<>(currentTrainers); + Collections.shuffle(scrambledTrainers, this.random); - cachedReplacementLists = new TreeMap<>(); + // Set up Pokemon pool cachedAllList = noLegendaries ? new ArrayList<>(noLegendaryList) : new ArrayList<>( mainPokemonList); if (includeFormes) { @@ -1634,10 +1588,6 @@ public abstract class AbstractRomHandler implements RomHandler { .stream() .filter(pk -> !pk.actuallyCosmetic) .collect(Collectors.toList()); - - - List<Integer> mainPlaythroughTrainers = getMainPlaythroughTrainers(); - List<Pokemon> banned = this.getBannedFormesForTrainerPokemon(); if (!abilitiesAreRandomized) { List<Pokemon> abilityDependentFormes = getAbilityDependentFormes(); @@ -1648,9 +1598,40 @@ public abstract class AbstractRomHandler implements RomHandler { } cachedAllList.removeAll(banned); + // Elite Four Unique Pokemon related + boolean eliteFourUniquePokemon = eliteFourUniquePokemonNumber > 0; + List<Pokemon> illegalList = new ArrayList<>(); + List<Pokemon> bannedFromUniqueList = new ArrayList<>(); + boolean illegalEvoChains = false; + List<Integer> eliteFourIndices = getEliteFourTrainers(forceChallengeMode); + if (eliteFourUniquePokemon) { + // Sort Elite Four Trainers to the start of the list + scrambledTrainers.sort((t1, t2) -> + Boolean.compare(eliteFourIndices.contains(currentTrainers.indexOf(t2)+1),eliteFourIndices.contains(currentTrainers.indexOf(t1)+1))); + illegalEvoChains = forceFullyEvolved; + if (rivalCarriesStarter) { + for (Pokemon starter: starterList) { + // If rival/friend carries starter, the starters cannot be set as unique + bannedFromUniqueList.add(starter); + setEvoChainAsIllegal(starter, bannedFromUniqueList, true); + + // If the final boss is a rival/friend, the fully evolved starters will be unique + if (hasRivalFinalBattle()) { + cachedAllList.removeAll(getFinalEvos(starter)); + if (illegalEvoChains) { + illegalList.add(starter); + setEvoChainAsIllegal(starter, illegalList, true); + } + } + } + } + } + + List<Integer> mainPlaythroughTrainers = getMainPlaythroughTrainers(); - // Fully random is easy enough - randomize then worry about rival - // carrying starter at the end + // Randomize Trainer Pokemon + // The result after this is done will not be final if "Force Fully Evolved" or "Rival Carries Starter" + // are used, as they are applied later for (Trainer t : scrambledTrainers) { applyLevelModifierToTrainerPokemon(t, levelModifier); if (t.tag != null && t.tag.equals("IRIVAL")) { @@ -1659,132 +1640,90 @@ public abstract class AbstractRomHandler implements RomHandler { 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 + int trainerIndex = currentTrainers.indexOf(t) + 1; + List<TrainerPokemon> trainerPokemonList = new ArrayList<>(t.pokemon); + + // Elite Four Unique Pokemon related boolean eliteFourTrackPokemon = false; - List<Pokemon> eliteFourPlacedPokemon = new ArrayList<>(); - if ( (tempSettingsFlag) && (eliteFourTrainers.contains(t)) ) { + boolean eliteFourRival = false; + if (eliteFourUniquePokemon && eliteFourIndices.contains(trainerIndex)) { eliteFourTrackPokemon = true; + Collections.reverse(trainerPokemonList); + trainerPokemonList.sort((tp1, tp2) -> Integer.compare(tp2.level, tp1.level)); + if (rivalCarriesStarter && (t.tag.contains("RIVAL") || t.tag.contains("FRIEND"))) { + eliteFourRival = true; + } } - for (TrainerPokemon tp : t.pokemon) { + for (TrainerPokemon tp : trainerPokemonList) { boolean swapThisMegaEvo = swapMegaEvos && tp.canMegaEvolve(); boolean wgAllowed = (!noEarlyWonderGuard) || tp.level >= 20; + boolean eliteFourSetUniquePokemon = + eliteFourTrackPokemon && eliteFourUniquePokemonNumber > trainerPokemonList.indexOf(tp); + boolean willForceEvolve = forceFullyEvolved && tp.level >= forceFullyEvolvedLevel; - 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 - if (distributionSetting && mainPlaythroughSetting) { - // new code for main playthrough distribution - if (mainPlaythroughTrainers.contains(t.offset)) { // this determines if this trainer is in the pool of main playthrough - - newPK = - pickReplacement( - oldPK, - usePowerLevels, - null, - noLegendaries, - wgAllowed, - true, - swapThisMegaEvo, - abilitiesAreRandomized, - includeFormes, - banIrregularAltFormes, - eliteFourPlacedPokemon - ); - setPlacementHistory(newPK); - tp.absolutePokeNumber = newPK.number; - tp.pokemon = newPK; - setFormeForTrainerPokemon(tp, newPK); - tp.abilitySlot = getRandomAbilitySlot(newPK); - if (eliteFourSetUniquePokemon) { - removeEvolutionChainFromPool(newPK); + bannedList = new ArrayList<>(); + bannedList.addAll(usedAsUniqueList); + if (illegalEvoChains && willForceEvolve) { + bannedList.addAll(illegalList); + } + if (eliteFourSetUniquePokemon) { + bannedList.addAll(bannedFromUniqueList); + } + + Pokemon newPK = pickReplacement( + oldPK, + usePowerLevels, + null, + noLegendaries, + wgAllowed, + distributionSetting || (mainPlaythroughSetting && mainPlaythroughTrainers.contains(t.offset)), + swapThisMegaEvo, + abilitiesAreRandomized, + includeFormes, + banIrregularAltFormes + ); + + // Chosen Pokemon is locked in past here + if (distributionSetting || (mainPlaythroughSetting && mainPlaythroughTrainers.contains(t.offset))) { + setPlacementHistory(newPK); + } + tp.absolutePokeNumber = newPK.number; + tp.pokemon = newPK; + setFormeForTrainerPokemon(tp, newPK); + tp.abilitySlot = getRandomAbilitySlot(newPK); + tp.resetMoves = true; + + if (!eliteFourRival) { + if (eliteFourSetUniquePokemon) { + List<Pokemon> actualPKList; + if (willForceEvolve) { + actualPKList = getFinalEvos(newPK); + } else { + actualPKList = new ArrayList<>(); + actualPKList.add(newPK); } - if (eliteFourTrackPokemon) { - eliteFourPlacedPokemon.add(newPK); + for (Pokemon actualPK: actualPKList) { + usedAsUniqueList.add(actualPK); + if (illegalEvoChains) { + setEvoChainAsIllegal(actualPK, illegalList, willForceEvolve); + } } } - else { // pure random when trainer not in pool - newPK = - pickReplacement( - oldPK, - usePowerLevels, - null, - noLegendaries, - wgAllowed, - false, - swapThisMegaEvo, - abilitiesAreRandomized, - includeFormes, - 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); + if (eliteFourTrackPokemon) { + bannedFromUniqueList.add(newPK); + if (illegalEvoChains) { + setEvoChainAsIllegal(newPK, bannedFromUniqueList, willForceEvolve); } } } else { - newPK = - pickReplacement( - oldPK, - usePowerLevels, - null, - noLegendaries, - wgAllowed, - distributionSetting, - swapThisMegaEvo, - abilitiesAreRandomized, - includeFormes, - banIrregularAltFormes, - eliteFourPlacedPokemon - ); - if (distributionSetting) { - 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); - } + eliteFourRival = false; } if (swapThisMegaEvo) { @@ -1793,7 +1732,7 @@ public abstract class AbstractRomHandler implements RomHandler { .get(this.random.nextInt(newPK.megaEvolutionsFrom.size())) .argument; } - tp.resetMoves = true; + if (shinyChance) { if (this.random.nextInt(256) == 0) { tp.IVs |= (1 << 30); @@ -1805,48 +1744,49 @@ 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); + private void setEvoChainAsIllegal(Pokemon newPK, List<Pokemon> illegalList, boolean willForceEvolve) { + // set pre-evos as illegal + setIllegalPreEvos(newPK, illegalList); - // 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); - } - } + // if the placed Pokemon will be forced fully evolved, set its evolutions as illegal + if (willForceEvolve) { + setIllegalEvos(newPK, illegalList); } + } - // 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 setIllegalPreEvos(Pokemon pk, List<Pokemon> illegalList) { + for (Evolution evo: pk.evolutionsTo) { + pk = evo.from; + illegalList.add(pk); + setIllegalPreEvos(pk, illegalList); + } + } + + private void setIllegalEvos(Pokemon pk, List<Pokemon> illegalList) { + for (Evolution evo: pk.evolutionsFrom) { + pk = evo.to; + illegalList.add(pk); + setIllegalEvos(pk, illegalList); } } + private List<Pokemon> getFinalEvos(Pokemon pk) { + List<Pokemon> finalEvos = new ArrayList<>(); + traverseEvolutions(pk, finalEvos); + return finalEvos; + } + + private void traverseEvolutions(Pokemon pk, List<Pokemon> finalEvos) { + if (!pk.evolutionsFrom.isEmpty()) { + for (Evolution evo: pk.evolutionsFrom) { + pk = evo.to; + traverseEvolutions(pk, finalEvos); + } + } else { + finalEvos.add(pk); + } + } private void setFormeForTrainerPokemon(TrainerPokemon tp, Pokemon pk) { boolean checkCosmetics = true; @@ -1885,6 +1825,12 @@ public abstract class AbstractRomHandler implements RomHandler { boolean swapMegaEvos = settings.isSwapTrainerMegaEvos(); boolean shinyChance = settings.isShinyChance(); boolean abilitiesAreRandomized = settings.getAbilitiesMod() == Settings.AbilitiesMod.RANDOMIZE; + int eliteFourUniquePokemonNumber = settings.getEliteFourUniquePokemonNumber(); + boolean forceFullyEvolved = settings.isTrainersForceFullyEvolved(); + int forceFullyEvolvedLevel = settings.getTrainersForceFullyEvolvedLevel(); + boolean forceChallengeMode = (settings.getCurrentMiscTweaks() & MiscTweak.FORCE_CHALLENGE_MODE.getValue()) > 0; + boolean rivalCarriesStarter = settings.isRivalCarriesStarterThroughout(); + List<Pokemon> starterList = getStarters().subList(0,3); checkPokemonRestrictions(); List<Trainer> currentTrainers = this.getTrainers(); @@ -1918,10 +1864,9 @@ public abstract class AbstractRomHandler implements RomHandler { // Construct groupings for types // Anything starting with GYM or ELITE or CHAMPION is a group - Set<Trainer> assignedTrainers = new TreeSet<>(); Map<String, List<Trainer>> groups = new TreeMap<>(); + Map<Trainer, Type> trainerTypes = new TreeMap<>(); for (Trainer t : currentTrainers) { - applyLevelModifierToTrainerPokemon(t, levelModifier); if (t.tag != null && t.tag.equals("IRIVAL")) { // This is the first rival in Yellow. His Pokemon is used to determine the non-player // starter, so we can't change it here. Just skip it. @@ -1938,14 +1883,12 @@ public abstract class AbstractRomHandler implements RomHandler { groups.put(group, new ArrayList<>()); } groups.get(group).add(t); - assignedTrainers.add(t); } else if (group.startsWith("GIO")) { // Giovanni has same grouping as his gym, gym 8 if (!groups.containsKey("GYM8")) { groups.put("GYM8", new ArrayList<>()); } groups.get("GYM8").add(t); - assignedTrainers.add(t); } } @@ -1975,49 +1918,9 @@ public abstract class AbstractRomHandler implements RomHandler { if (group.equals("CHAMPION")) { usedUberTypes.add(typeForGroup); } - // Themed groups just have a theme, no special criteria - for (Trainer t : trainersInGroup) { - for (TrainerPokemon tp : t.pokemon) { - boolean swapThisMegaEvo = swapMegaEvos && tp.canMegaEvolve(); - boolean wgAllowed = (!noEarlyWonderGuard) || tp.level >= 20; - Pokemon oldPK = tp.pokemon; - if (tp.forme > 0) { - oldPK = getAltFormeOfPokemon(oldPK, tp.forme); - } - Pokemon newPK = - pickReplacement( - oldPK, - usePowerLevels, - typeForGroup, - noLegendaries, - wgAllowed, - false, - swapThisMegaEvo, - abilitiesAreRandomized, - includeFormes, - banIrregularAltFormes, - new ArrayList<>() - - ); - tp.absolutePokeNumber = newPK.number; - tp.pokemon = newPK; - setFormeForTrainerPokemon(tp, newPK); - tp.abilitySlot = getRandomAbilitySlot(newPK); - - if (swapThisMegaEvo) { - tp.heldItem = newPK - .megaEvolutionsFrom - .get(this.random.nextInt(newPK.megaEvolutionsFrom.size())) - .argument; - } - tp.resetMoves = true; - if (shinyChance) { - if (this.random.nextInt(256) == 0) { - tp.IVs |= (1 << 30); - } - } - } + for (Trainer t : trainersInGroup) { + trainerTypes.put(t, typeForGroup); } } @@ -2027,14 +1930,47 @@ public abstract class AbstractRomHandler implements RomHandler { List<Trainer> scrambledTrainers = new ArrayList<>(currentTrainers); Collections.shuffle(scrambledTrainers, this.random); + // Elite Four Unique Pokemon related + boolean eliteFourUniquePokemon = eliteFourUniquePokemonNumber > 0; + List<Pokemon> illegalList = new ArrayList<>(); + List<Pokemon> bannedFromUniqueList = new ArrayList<>(); + boolean illegalEvoChains = false; + List<Integer> eliteFourIndices = getEliteFourTrainers(forceChallengeMode); + if (eliteFourUniquePokemon) { + // Sort Elite Four Trainers to the start of the list + scrambledTrainers.sort((t1, t2) -> + Boolean.compare(eliteFourIndices.contains(currentTrainers.indexOf(t2)+1),eliteFourIndices.contains(currentTrainers.indexOf(t1)+1))); + illegalEvoChains = forceFullyEvolved; + if (rivalCarriesStarter) { + for (Pokemon starter: starterList) { + // If rival/friend carries starter, the starters cannot be set as unique + bannedFromUniqueList.add(starter); + setEvoChainAsIllegal(starter, bannedFromUniqueList, true); + + // If the final boss is a rival/friend, the fully evolved starters will be unique + if (hasRivalFinalBattle()) { + cachedAllList.removeAll(getFinalEvos(starter)); + if (illegalEvoChains) { + illegalList.add(starter); + setEvoChainAsIllegal(starter, illegalList, true); + } + } + } + } + } + // Give a type to each unassigned trainer for (Trainer t : scrambledTrainers) { + applyLevelModifierToTrainerPokemon(t, levelModifier); if (t.tag != null && t.tag.equals("IRIVAL")) { - continue; // skip + // This is the first rival in Yellow. His Pokemon is used to determine the non-player + // starter, so we can't change it here. Just skip it. + continue; } - if (!assignedTrainers.contains(t)) { - Type typeForTrainer = pickType(weightByFrequency, noLegendaries, includeFormes); + Type typeForTrainer = trainerTypes.get(t); + if (typeForTrainer == null) { + typeForTrainer = pickType(weightByFrequency, noLegendaries, includeFormes); // Ubers: can't have the same type as each other if (t.tag != null && t.tag.equals("UBER")) { while (usedUberTypes.contains(typeForTrainer)) { @@ -2042,45 +1978,103 @@ public abstract class AbstractRomHandler implements RomHandler { } usedUberTypes.add(typeForTrainer); } - for (TrainerPokemon tp : t.pokemon) { - boolean swapThisMegaEvo = swapMegaEvos && tp.canMegaEvolve(); - boolean shedAllowed = (!noEarlyWonderGuard) || tp.level >= 20; - Pokemon oldPK = tp.pokemon; - if (tp.forme > 0) { - oldPK = getAltFormeOfPokemon(oldPK, tp.forme); - } - Pokemon newPK = - pickReplacement( - oldPK, - usePowerLevels, - typeForTrainer, - noLegendaries, - shedAllowed, - false, - swapThisMegaEvo, - abilitiesAreRandomized, - includeFormes, - banIrregularAltFormes, - new ArrayList<>() - ); - tp.absolutePokeNumber = newPK.number; - tp.pokemon = newPK; - setFormeForTrainerPokemon(tp, newPK); - tp.abilitySlot = getRandomAbilitySlot(newPK); - - if (swapThisMegaEvo) { - tp.heldItem = newPK - .megaEvolutionsFrom - .get(this.random.nextInt(newPK.megaEvolutionsFrom.size())) - .argument; - } - - tp.resetMoves = true; - if (shinyChance) { - if (this.random.nextInt(256) == 0) { - tp.IVs |= (1 << 30); + } + + int trainerIndex = currentTrainers.indexOf(t) + 1; + + List<TrainerPokemon> trainerPokemonList = new ArrayList<>(t.pokemon); + + // Elite Four Unique Pokemon related + boolean eliteFourTrackPokemon = false; + boolean eliteFourRival = false; + if (eliteFourUniquePokemon && eliteFourIndices.contains(trainerIndex)) { + eliteFourTrackPokemon = true; + Collections.reverse(trainerPokemonList); + trainerPokemonList.sort((tp1, tp2) -> Integer.compare(tp2.level, tp1.level)); + if (rivalCarriesStarter && (t.tag.contains("RIVAL") || t.tag.contains("FRIEND"))) { + eliteFourRival = true; + } + } + + for (TrainerPokemon tp : trainerPokemonList) { + boolean swapThisMegaEvo = swapMegaEvos && tp.canMegaEvolve(); + boolean wgAllowed = (!noEarlyWonderGuard) || tp.level >= 20; + boolean eliteFourSetUniquePokemon = + eliteFourTrackPokemon && eliteFourUniquePokemonNumber > trainerPokemonList.indexOf(tp); + boolean willForceEvolve = forceFullyEvolved && tp.level >= forceFullyEvolvedLevel; + + Pokemon oldPK = tp.pokemon; + if (tp.forme > 0) { + oldPK = getAltFormeOfPokemon(oldPK, tp.forme); + } + + bannedList = new ArrayList<>(); + bannedList.addAll(usedAsUniqueList); + if (illegalEvoChains && willForceEvolve) { + bannedList.addAll(illegalList); + } + if (eliteFourSetUniquePokemon) { + bannedList.addAll(bannedFromUniqueList); + } + + Pokemon newPK = + pickReplacement( + oldPK, + usePowerLevels, + typeForTrainer, + noLegendaries, + wgAllowed, + false, + swapThisMegaEvo, + abilitiesAreRandomized, + includeFormes, + banIrregularAltFormes + ); + + // Chosen Pokemon is locked in past here + tp.absolutePokeNumber = newPK.number; + tp.pokemon = newPK; + setFormeForTrainerPokemon(tp, newPK); + tp.abilitySlot = getRandomAbilitySlot(newPK); + tp.resetMoves = true; + + if (!eliteFourRival) { + if (eliteFourSetUniquePokemon) { + List<Pokemon> actualPKList; + if (willForceEvolve) { + actualPKList = getFinalEvos(newPK); + } else { + actualPKList = new ArrayList<>(); + actualPKList.add(newPK); + } + for (Pokemon actualPK: actualPKList) { + usedAsUniqueList.add(actualPK); + if (illegalEvoChains) { + setEvoChainAsIllegal(actualPK, illegalList, willForceEvolve); + } } } + if (eliteFourTrackPokemon) { + bannedFromUniqueList.add(newPK); + if (illegalEvoChains) { + setEvoChainAsIllegal(newPK, bannedFromUniqueList, willForceEvolve); + } + } + } else { + eliteFourRival = false; + } + + if (swapThisMegaEvo) { + tp.heldItem = newPK + .megaEvolutionsFrom + .get(this.random.nextInt(newPK.megaEvolutionsFrom.size())) + .argument; + } + + if (shinyChance) { + if (this.random.nextInt(256) == 0) { + tp.IVs |= (1 << 30); + } } } } @@ -2166,6 +2160,11 @@ public abstract class AbstractRomHandler implements RomHandler { } @Override + public boolean hasRivalFinalBattle() { + return false; + } + + @Override public void forceFullyEvolvedTrainerPokes(Settings settings) { int minLevel = settings.getTrainersForceFullyEvolvedLevel(); @@ -6217,14 +6216,16 @@ public abstract class AbstractRomHandler implements RomHandler { private Map<Type, List<Pokemon>> cachedReplacementLists; private List<Pokemon> cachedAllList; - private List<Pokemon> permanentlyBannedList = new ArrayList<>(); + private List<Pokemon> bannedList = new ArrayList<>(); + private List<Pokemon> usedAsUniqueList = 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, - List<Pokemon> eliteFourPlacedPokemon) { + boolean abilitiesAreRandomized, boolean allowAltFormes, boolean banIrregularAltFormes) { List<Pokemon> pickFrom; + List<Pokemon> withoutBannedPokemon; + if (swapMegaEvos) { pickFrom = megaEvolutionsList .stream() @@ -6235,7 +6236,9 @@ public abstract class AbstractRomHandler implements RomHandler { } else { pickFrom = cachedAllList; } + if (usePlacementHistory) { + // "Distributed" settings double placementAverage = getPlacementAverage(); pickFrom = pickFrom .stream() @@ -6244,15 +6247,8 @@ public abstract class AbstractRomHandler implements RomHandler { if (pickFrom.isEmpty()) { 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) { + } else if (type != null && cachedReplacementLists != null) { + // "Type Themed" settings if (!cachedReplacementLists.containsKey(type)) { // System.out.println(current.name + " using cachedReplacementLists"); List<Pokemon> pokemonOfType = allowAltFormes ? pokemonOfTypeInclFormes(type, noLegendaries) : @@ -6280,6 +6276,11 @@ public abstract class AbstractRomHandler implements RomHandler { } } + withoutBannedPokemon = pickFrom.stream().filter(pk -> !bannedList.contains(pk)).collect(Collectors.toList()); + if (!withoutBannedPokemon.isEmpty()) { + pickFrom = withoutBannedPokemon; + } + if (usePowerLevels) { // start with within 10% and add 5% either direction till we find // something diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java index 6f03e67..5669de8 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java @@ -1098,7 +1098,7 @@ public class Gen1RomHandler extends AbstractGBCRomHandler { }
@Override
- public List<Integer> getEliteFourTrainers() {
+ public List<Integer> getEliteFourTrainers(boolean isChallengeMode) {
return new ArrayList<>();
}
@@ -1167,6 +1167,11 @@ public class Gen1RomHandler extends AbstractGBCRomHandler { }
@Override
+ public boolean hasRivalFinalBattle() {
+ return true;
+ }
+
+ @Override
public boolean isYellow() {
return romEntry.isYellow;
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java index 1fd707d..faf548f 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java @@ -922,7 +922,7 @@ public class Gen2RomHandler extends AbstractGBCRomHandler { }
@Override
- public List<Integer> getEliteFourTrainers() {
+ public List<Integer> getEliteFourTrainers(boolean isChallengeMode) {
return new ArrayList<>();
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java index b8c54fc..8b3c6f7 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java @@ -1513,16 +1513,8 @@ 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; - } + public List<Integer> getEliteFourTrainers(boolean isChallengeMode) { + return Arrays.stream(romEntry.arrayEntries.get("EliteFourIndices")).boxed().collect(Collectors.toList()); } @@ -3945,6 +3937,11 @@ public class Gen3RomHandler extends AbstractGBRomHandler { } @Override + public boolean hasRivalFinalBattle() { + return romEntry.romType == Gen3Constants.RomType_FRLG; + } + + @Override public List<Integer> getAllConsumableHeldItems() { return Gen3Constants.consumableHeldItems; } diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index 7fc5b14..2997bc9 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -2489,16 +2489,8 @@ 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;
- }
+ public List<Integer> getEliteFourTrainers(boolean isChallengeMode) {
+ return Arrays.stream(romEntry.arrayEntries.get("EliteFourIndices")).boxed().collect(Collectors.toList());
}
@Override
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java index 3d756a6..cec0049 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java @@ -1445,15 +1445,11 @@ 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;
+ public List<Integer> getEliteFourTrainers(boolean isChallengeMode) {
+ if (isChallengeMode) {
+ return Arrays.stream(romEntry.arrayEntries.get("ChallengeModeEliteFourIndices")).boxed().collect(Collectors.toList());
+ } else {
+ return Arrays.stream(romEntry.arrayEntries.get("EliteFourIndices")).boxed().collect(Collectors.toList());
}
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java index 7db767f..080c5f2 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java @@ -1879,16 +1879,8 @@ 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; - } + public List<Integer> getEliteFourTrainers(boolean isChallengeMode) { + return Arrays.stream(romEntry.arrayEntries.get("EliteFourIndices")).boxed().collect(Collectors.toList()); } @Override diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java index 166f68b..523a3e6 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen7RomHandler.java @@ -1593,16 +1593,8 @@ 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; - } + public List<Integer> getEliteFourTrainers(boolean isChallengeMode) { + return Arrays.stream(romEntry.arrayEntries.get("EliteFourIndices")).boxed().collect(Collectors.toList()); } @Override @@ -3570,6 +3562,11 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { } @Override + public boolean hasRivalFinalBattle() { + return true; + } + + @Override public List<Integer> getSensibleHeldItemsFor(TrainerPokemon tp, boolean consumableOnly, List<Move> moves, Map<Integer, List<MoveLearnt>> movesets) { List<Integer> items = new ArrayList<>(); items.addAll(Gen7Constants.generalPurposeConsumableItems); diff --git a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java index bbccb54..2fc9bc8 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java @@ -243,7 +243,7 @@ public interface RomHandler { List<Integer> getMainPlaythroughTrainers();
- List<Integer> getEliteFourTrainers();
+ List<Integer> getEliteFourTrainers(boolean isChallengeMode);
void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode);
@@ -261,6 +261,8 @@ public interface RomHandler { void rivalCarriesStarter();
+ boolean hasRivalFinalBattle();
+
void forceFullyEvolvedTrainerPokes(Settings settings);
void onlyChangeTrainerLevels(Settings settings);
|