summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorZach Meadows <52054422+Zach-Meadows@users.noreply.github.com>2022-06-11 17:23:36 -0400
committerrafa_99 <raroma09@gmail.com>2022-06-12 19:25:48 +0100
commit76431f3f79463ecdf3e46031d596e12996d6e471 (patch)
tree0b23a415ad8dee59b51bc8835cf21fcc47aa37e3 /src/com
parente729b9b64c9009653e2e73c99e3f040191c18b70 (diff)
random option added to custom starters (#455)
* random option added to custom starters
Diffstat (limited to 'src/com')
-rw-r--r--src/com/sneed/pkrandom/newgui/Bundle.properties2
-rw-r--r--src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java13
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java52
3 files changed, 55 insertions, 12 deletions
diff --git a/src/com/sneed/pkrandom/newgui/Bundle.properties b/src/com/sneed/pkrandom/newgui/Bundle.properties
index 95ecf3f..80bae63 100644
--- a/src/com/sneed/pkrandom/newgui/Bundle.properties
+++ b/src/com/sneed/pkrandom/newgui/Bundle.properties
@@ -90,7 +90,7 @@ GUI.startersStaticsTradesPanel=Starters, Statics & Trades
GUI.spPanel.title=Starter Pokemon
GUI.spUnchangedRadioButton.toolTipText=Don't change the starter Pokemon.
GUI.spUnchangedRadioButton.text=Unchanged
-GUI.spCustomRadioButton.toolTipText=Lets you pick the 3 starter pokemon you want to use.
+GUI.spCustomRadioButton.toolTipText=Lets you pick the 3 starter pokemon you want to use, or "Random" at the top of the selector.
GUI.spCustomRadioButton.text=Custom
GUI.spRandomCompletelyRadioButton.toolTipText=Picks 3 random starter Pokemon to be used.
GUI.spRandomCompletelyRadioButton.text=Random (completely)
diff --git a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
index 9f18148..fdb05ad 100644
--- a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
+++ b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
@@ -3519,17 +3519,20 @@ public class NewRandomizerGUI {
.filter(pk -> pk == null || !pk.actuallyCosmetic)
.collect(Collectors.toList()) :
romHandler.getPokemon();
- String[] pokeNames = new String[allPokes.size() - 1];
+ String[] pokeNames = new String[allPokes.size()];
+ pokeNames[0] = "Random";
for (int i = 1; i < allPokes.size(); i++) {
- pokeNames[i - 1] = allPokes.get(i).fullName();
+ pokeNames[i] = allPokes.get(i).fullName();
+
}
+
spComboBox1.setModel(new DefaultComboBoxModel<>(pokeNames));
- spComboBox1.setSelectedIndex(allPokes.indexOf(currentStarters.get(0)) - 1);
+ spComboBox1.setSelectedIndex(allPokes.indexOf(currentStarters.get(0)));
spComboBox2.setModel(new DefaultComboBoxModel<>(pokeNames));
- spComboBox2.setSelectedIndex(allPokes.indexOf(currentStarters.get(1)) - 1);
+ spComboBox2.setSelectedIndex(allPokes.indexOf(currentStarters.get(1)));
if (!romHandler.isYellow()) {
spComboBox3.setModel(new DefaultComboBoxModel<>(pokeNames));
- spComboBox3.setSelectedIndex(allPokes.indexOf(currentStarters.get(2)) - 1);
+ spComboBox3.setSelectedIndex(allPokes.indexOf(currentStarters.get(2)));
}
String[] baseStatGenerationNumbers = new String[Math.min(3, GlobalConstants.HIGHEST_POKEMON_GEN - romHandler.generationOfPokemon())];
diff --git a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java
index f3471db..966a071 100755
--- a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java
@@ -3187,25 +3187,65 @@ public abstract class AbstractRomHandler implements RomHandler {
@Override
public void customStarters(Settings settings) {
+ boolean abilitiesUnchanged = settings.getAbilitiesMod() == Settings.AbilitiesMod.UNCHANGED;
int[] customStarters = settings.getCustomStarters();
boolean allowAltFormes = settings.isAllowStarterAltFormes();
+ boolean banIrregularAltFormes = settings.isBanIrregularAltFormes();
List<Pokemon> romPokemon = getPokemonInclFormes()
.stream()
.filter(pk -> pk == null || !pk.actuallyCosmetic)
.collect(Collectors.toList());
+ List<Pokemon> banned = getBannedFormesForPlayerPokemon();
pickedStarters = new ArrayList<>();
- Pokemon pkmn1 = romPokemon.get(customStarters[0]);
- pickedStarters.add(pkmn1);
- Pokemon pkmn2 = romPokemon.get(customStarters[1]);
- pickedStarters.add(pkmn2);
+ if (abilitiesUnchanged) {
+ List<Pokemon> abilityDependentFormes = getAbilityDependentFormes();
+ banned.addAll(abilityDependentFormes);
+ }
+ if (banIrregularAltFormes) {
+ banned.addAll(getIrregularFormes());
+ }
+ // loop to add chosen pokemon to banned, preventing it from being a random option.
+ for (int i = 0; i < customStarters.length; i = i + 1){
+ if (!(customStarters[i] - 1 == 0)){
+ banned.add(romPokemon.get(customStarters[i] - 1));
+ }
+ }
+ if (customStarters[0] - 1 == 0){
+ Pokemon pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ while (pickedStarters.contains(pkmn) || banned.contains(pkmn) || pkmn.actuallyCosmetic) {
+ pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ }
+ pickedStarters.add(pkmn);
+ } else {
+ Pokemon pkmn1 = romPokemon.get(customStarters[0] - 1);
+ pickedStarters.add(pkmn1);
+ }
+ if (customStarters[1] - 1 == 0){
+ Pokemon pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ while (pickedStarters.contains(pkmn) || banned.contains(pkmn) || pkmn.actuallyCosmetic) {
+ pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ }
+ pickedStarters.add(pkmn);
+ } else {
+ Pokemon pkmn2 = romPokemon.get(customStarters[1] - 1);
+ pickedStarters.add(pkmn2);
+ }
if (isYellow()) {
setStarters(pickedStarters);
} else {
- Pokemon pkmn3 = romPokemon.get(customStarters[2]);
- pickedStarters.add(pkmn3);
+ if (customStarters[2] - 1 == 0){
+ Pokemon pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ while (pickedStarters.contains(pkmn) || banned.contains(pkmn) || pkmn.actuallyCosmetic) {
+ pkmn = allowAltFormes ? randomPokemonInclFormes() : randomPokemon();
+ }
+ pickedStarters.add(pkmn);
+ } else {
+ Pokemon pkmn3 = romPokemon.get(customStarters[2] - 1);
+ pickedStarters.add(pkmn3);
+ }
if (starterCount() > 3) {
for (int i = 3; i < starterCount(); i++) {
Pokemon pkmn = random2EvosPokemon(allowAltFormes);