From d7ce778ea9b8d98324b5f32dfb40108011f35e2f Mon Sep 17 00:00:00 2001 From: Ajarmar Date: Sat, 26 Oct 2019 22:22:55 +0200 Subject: some refactoring --- .../pkrandom/romhandlers/AbstractRomHandler.java | 27 ++++------------------ .../pkrandom/romhandlers/Gen1RomHandler.java | 5 ++++ .../pkrandom/romhandlers/Gen2RomHandler.java | 5 ++++ .../pkrandom/romhandlers/Gen3RomHandler.java | 5 ++++ .../pkrandom/romhandlers/Gen4RomHandler.java | 5 ++++ .../pkrandom/romhandlers/Gen5RomHandler.java | 13 +++++++++++ .../dabomstew/pkrandom/romhandlers/RomHandler.java | 4 +++- 7 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java index e3b2a43..f69c118 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java @@ -48,7 +48,6 @@ import com.dabomstew.pkrandom.CustomNamesSet; import com.dabomstew.pkrandom.MiscTweak; import com.dabomstew.pkrandom.RomFunctions; import com.dabomstew.pkrandom.constants.GlobalConstants; -import com.dabomstew.pkrandom.constants.Gen5Constants; import com.dabomstew.pkrandom.exceptions.RandomizationException; import com.dabomstew.pkrandom.pokemon.Encounter; import com.dabomstew.pkrandom.pokemon.EncounterSet; @@ -3764,7 +3763,7 @@ public abstract class AbstractRomHandler implements RomHandler { } - protected void setPlacementHistory(Pokemon newPK) { + private void setPlacementHistory(Pokemon newPK) { List placedPK = new ArrayList(placementHistory.keySet()); if (placedPK.contains(newPK)) { placementHistory.put(newPK, placementHistory.get(newPK) + 1); @@ -3776,7 +3775,7 @@ public abstract class AbstractRomHandler implements RomHandler { } - public int getPlacementHistory(Pokemon newPK) { + private int getPlacementHistory(Pokemon newPK) { List placedPK = new ArrayList(placementHistory.keySet()); if (placedPK.contains(newPK)) { return placementHistory.get(newPK); @@ -3787,7 +3786,7 @@ public abstract class AbstractRomHandler implements RomHandler { } // currently not used - public boolean decidePlacementAverage(Pokemon newPK) { + private boolean decidePlacementAverage(Pokemon newPK) { // This method will return true if the number of times a pokemon has been // placed is less than average of all placed pokemon's appearances // E.g., Charmander's been placed once, but the average for all pokemon is 2.2 @@ -3816,7 +3815,7 @@ public abstract class AbstractRomHandler implements RomHandler { } - public List getBelowAveragePlacements() { + private List getBelowAveragePlacements() { // This method will return true if the number of times a pokemon has been // placed is less than average of all placed pokemon's appearances // E.g., Charmander's been placed once, but the average for all pokemon is 2.2 @@ -3858,25 +3857,9 @@ public abstract class AbstractRomHandler implements RomHandler { return toPlacePK; - } - - public List getMainPlaythroughTrainers() { - if (this.getROMCode().equals("IRBO") || this.getROMCode().equals("IRAO")) { // BW1 - List trainers = Gen5Constants.bw1MainPlaythroughTrainers; - return trainers; - } - else if (this.getROMCode().equals("IRDO") || this.getROMCode().equals("IREO")) { // BW2 - List trainers = Gen5Constants.bw2MainPlaythroughTrainers; - return trainers; - } - else { - return Gen5Constants.emptyPlaythroughTrainers; - - } - - } + @Override public void renderPlacementHistory() { List placedPK = new ArrayList(placementHistory.keySet()); for (Pokemon p : placedPK) { diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java index 16ef273..d4f9dfd 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen1RomHandler.java @@ -1021,6 +1021,11 @@ public class Gen1RomHandler extends AbstractGBCRomHandler { return allTrainers; } + @Override + public List getMainPlaythroughTrainers() { + return new ArrayList<>(); // Not implemented + } + public void setTrainers(List trainerData) { 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 7ae788b..0cca73f 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen2RomHandler.java @@ -887,6 +887,11 @@ public class Gen2RomHandler extends AbstractGBCRomHandler { return allTrainers; } + @Override + public List getMainPlaythroughTrainers() { + return new ArrayList<>(); // Not implemented + } + @Override public void setTrainers(List trainerData) { int traineroffset = romEntry.getValue("TrainerDataTableOffset"); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java index a89760b..3e31f37 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java @@ -1429,6 +1429,11 @@ public class Gen3RomHandler extends AbstractGBRomHandler { return theTrainers; } + @Override + public List getMainPlaythroughTrainers() { + return new ArrayList<>(); // Not implemented + } + @Override public void setTrainers(List trainerData) { int baseOffset = romEntry.getValue("TrainerData"); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index e317573..4f3b65a 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -1339,6 +1339,11 @@ public class Gen4RomHandler extends AbstractDSRomHandler { return allTrainers; } + @Override + public List getMainPlaythroughTrainers() { + return new ArrayList<>(); // Not implemented + } + @Override public void setTrainers(List trainerData) { Iterator allTrainers = trainerData.iterator(); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java index 2bb8357..667fa42 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen5RomHandler.java @@ -1099,6 +1099,19 @@ public class Gen5RomHandler extends AbstractDSRomHandler { return allTrainers; } + @Override + public List getMainPlaythroughTrainers() { + if (romEntry.romType == Gen5Constants.Type_BW) { // BW1 + return Gen5Constants.bw1MainPlaythroughTrainers; + } + else if (romEntry.romType == Gen5Constants.Type_BW2) { // BW2 + return Gen5Constants.bw2MainPlaythroughTrainers; + } + else { + return Gen5Constants.emptyPlaythroughTrainers; + } + } + @Override public void setTrainers(List trainerData) { Iterator allTrainers = trainerData.iterator(); diff --git a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java index 4529fc0..82128ae 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java @@ -161,6 +161,8 @@ public interface RomHandler { // Randomizer: trainer pokemon public List getTrainers(); + public List getMainPlaythroughTrainers(); + public void setTrainers(List trainerData); public void randomizeTrainerPokes(boolean usePowerLevels, boolean noLegendaries, boolean noEarlyWonderGuard, @@ -226,7 +228,7 @@ public interface RomHandler { public boolean setStaticPokemon(List staticPokemon); - public void randomizeStaticPokemon(boolean swap_legendaries, boolean similar_strength, boolean limit_bw_muskateers); + public void randomizeStaticPokemon(boolean swapLegendaries, boolean similarStrength, boolean limitMusketeers); public boolean canChangeStaticPokemon(); -- cgit v1.2.3