Skip to content

Commit

Permalink
Merge pull request Dabomstew#24 from sickoe/tpLevel
Browse files Browse the repository at this point in the history
Trainer pokemon level modifier
  • Loading branch information
Dabomstew authored Jul 22, 2016
2 parents b398eab + fe9e243 commit 2a21e77
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/com/dabomstew/pkrandom/Randomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public int randomize(final String filename, final PrintStream log, long seed) {
// Trainer Pokemon
if (settings.getTrainersMod() == Settings.TrainersMod.RANDOM) {
romHandler.randomizeTrainerPokes(settings.isTrainersUsePokemonOfSimilarStrength(),
settings.isTrainersBlockLegendaries(), settings.isTrainersBlockEarlyWonderGuard());
settings.isTrainersBlockLegendaries(), settings.isTrainersBlockEarlyWonderGuard(),settings.isTrainersLevelModified() ? settings.getTrainersLevelModifier() : 0);
} else if (settings.getTrainersMod() == Settings.TrainersMod.TYPE_THEMED) {
romHandler.typeThemeTrainerPokes(settings.isTrainersUsePokemonOfSimilarStrength(),
settings.isTrainersMatchTypingDistribution(), settings.isTrainersBlockLegendaries(),
Expand Down
32 changes: 30 additions & 2 deletions src/com/dabomstew/pkrandom/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Settings {

public static final int VERSION = 172;

public static final int LENGTH_OF_SETTINGS_DATA = 35;
public static final int LENGTH_OF_SETTINGS_DATA = 36;

private CustomNamesSet customNames;

Expand Down Expand Up @@ -144,7 +144,10 @@ public enum TrainersMod {
private boolean randomizeTrainerClassNames;
private boolean trainersForceFullyEvolved;
private int trainersForceFullyEvolvedLevel = 30;

private boolean trainersLevelModified;
private int trainersLevelModifier = 0;


public enum WildPokemonMod {
UNCHANGED, RANDOM, AREA_MAPPING, GLOBAL_MAPPING
}
Expand Down Expand Up @@ -378,6 +381,9 @@ public String toString() {
} catch (IOException e) {

}

// @ 35 trainer pokemon level modifier
out.write((trainersLevelModified ? 0x80 : 0) | trainersLevelModifier);

try {
byte[] romName = this.romName.getBytes("US-ASCII");
Expand All @@ -388,6 +394,8 @@ public String toString() {
} catch (IOException e) {
out.write(0);
}



byte[] current = out.toByteArray();
CRC32 checksum = new CRC32();
Expand Down Expand Up @@ -571,6 +579,9 @@ public static Settings fromString(String settingsString) throws UnsupportedEncod
int codeTweaks = FileFunctions.readFullInt(data, 31);

settings.setCurrentMiscTweaks(codeTweaks);

settings.setTrainersLevelModified(restoreState(data[35], 7));
settings.setTrainersLevelModifier(data[35] & 0x7F);

int romNameLength = data[LENGTH_OF_SETTINGS_DATA] & 0xFF;
String romName = new String(data, LENGTH_OF_SETTINGS_DATA + 1, romNameLength, "US-ASCII");
Expand Down Expand Up @@ -1186,6 +1197,23 @@ public Settings setTrainersForceFullyEvolvedLevel(int trainersForceFullyEvolvedL
this.trainersForceFullyEvolvedLevel = trainersForceFullyEvolvedLevel;
return this;
}
public boolean isTrainersLevelModified() {
return trainersLevelModified;
}

public Settings setTrainersLevelModified(boolean trainersLevelModified) {
this.trainersLevelModified = trainersLevelModified;
return this;
}

public int getTrainersLevelModifier() {
return trainersLevelModifier;
}

public Settings setTrainersLevelModifier(int trainersLevelModifier) {
this.trainersLevelModifier = trainersLevelModifier;
return this;
}

public WildPokemonMod getWildPokemonMod() {
return wildPokemonMod;
Expand Down
3 changes: 3 additions & 0 deletions src/com/dabomstew/pkrandom/gui/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ RandomizerGUI.tpForceFullyEvolvedCB.text=Force Fully Evolved at Level:
RandomizerGUI.tpForceFullyEvolvedCB.toolTipText=<html>Checking this will force all trainer Pokemon at or above the level you select below to be fully evolved regardless of other settings.<br />Pokemon below the selected level will be randomly picked like normal.
RandomizerGUI.wpCatchRateSlider.toolTipText=<html>If Minimum Catch Rate is selected, allows you to set the level used.\n<br />Level 1: "Normal" minimum catch rate from old versions (normal Pokemon 30% at low HP, legendaries 15%)\n<br />Level 2: "Buffed" minimum catch rate (normal Pokemon 50% at low HP, legendaries 25%)\n<br />Level 3: "Super" minimum catch rate (normal Pokemon 80% at low HP, legendaries 40%)\n<br />Level 4: "Maximum" minimum catch rate (everything 255 catch rate, the highest available without changing game code)
RandomizerGUI.tpForceFullyEvolvedSlider.toolTipText=Use this slider to select the minimum level to force fully evolved Pokemon at if said option is checked above.
RandomizerGUI.tpLevelModifierCB.text=Level Modifier
RandomizerGUI.tpLevelModifierCB.toolTipText=Modify trainer pokemon's level
RandomizerGUI.tpLevelModifierSlider.toolTipText=Use this slider to select the modifier for trainer pokemon's level
RandomizerGUI.pmsReorderDamagingMovesCB.text=Reorder Damaging Moves
RandomizerGUI.pmsReorderDamagingMovesCB.toolTipText=<html>Reorders the randomized movesets so that less powerful damaging moves are learnt before those with high power.\n<br />The positions of non-damaging moves will not change.
RandomizerGUI.pmsForceGoodDamagingCB.text=Force % of Good Damaging Moves
Expand Down
30 changes: 30 additions & 0 deletions src/com/dabomstew/pkrandom/gui/RandomizerGUI.form
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,8 @@
<Component id="tcnRandomizeCB" min="-2" max="-2" attributes="0"/>
<Component id="tpForceFullyEvolvedCB" min="-2" max="-2" attributes="0"/>
<Component id="tpForceFullyEvolvedSlider" min="-2" max="-2" attributes="0"/>
<Component id="tpLevelModifierCB" min="-2" max="-2" attributes="0"/>
<Component id="tpLevelModifierSlider" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
Expand All @@ -1957,6 +1959,7 @@
<Component id="tpTypeThemedRB" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tpTypeWeightingCB" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tpForceFullyEvolvedCB" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tpLevelModifierCB" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand Down Expand Up @@ -2120,6 +2123,33 @@
<Property name="value" type="int" value="30"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="tpLevelModifierCB">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/dabomstew/pkrandom/gui/Bundle.properties" key="RandomizerGUI.tpLevelModifierCB.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/dabomstew/pkrandom/gui/Bundle.properties" key="RandomizerGUI.tpLevelModifierCB.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tpForceFullyEvolvedCBActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSlider" name="tpLevelModifierSlider">
<Properties>
<Property name="majorTickSpacing" type="int" value="5"/>
<Property name="maximum" type="int" value="0.5"/>
<Property name="minimum" type="int" value="2"/>
<Property name="minorTickSpacing" type="int" value="1"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/dabomstew/pkrandom/gui/Bundle.properties" key="RandomizerGUI.tpLevelModifierSlider.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="value" type="int" value="1"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
67 changes: 62 additions & 5 deletions src/com/dabomstew/pkrandom/gui/RandomizerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,9 @@ private void initialFormState() {
this.tpUnchangedRB.setEnabled(false);
this.tpForceFullyEvolvedCB.setEnabled(false);
this.tpForceFullyEvolvedSlider.setEnabled(false);
this.tpLevelModifierCB.setEnabled(false);
this.tpLevelModifierSlider.setEnabled(false);

this.tpUnchangedRB.setSelected(true);
this.tpPowerLevelsCB.setSelected(false);
this.tpRivalCarriesStarterCB.setSelected(false);
Expand All @@ -803,6 +806,8 @@ private void initialFormState() {
this.tpNoEarlyShedinjaCB.setSelected(false);
this.tpForceFullyEvolvedCB.setSelected(false);
this.tpForceFullyEvolvedSlider.setValue(this.tpForceFullyEvolvedSlider.getMinimum());
this.tpLevelModifierCB.setSelected(false);
this.tpLevelModifierSlider.setValue(0);

this.tnRandomizeCB.setEnabled(false);
this.tcnRandomizeCB.setEnabled(false);
Expand Down Expand Up @@ -1345,11 +1350,14 @@ private void enableOrDisableSubControls() {
this.tpNoEarlyShedinjaCB.setSelected(false);
this.tpForceFullyEvolvedCB.setEnabled(false);
this.tpForceFullyEvolvedCB.setSelected(false);
this.tpLevelModifierCB.setEnabled(false);
this.tpLevelModifierCB.setSelected(false);
} else {
this.tpPowerLevelsCB.setEnabled(true);
this.tpNoLegendariesCB.setEnabled(true);
this.tpNoEarlyShedinjaCB.setEnabled(true);
this.tpForceFullyEvolvedCB.setEnabled(true);
this.tpLevelModifierCB.setEnabled(true);
}

if (this.tpForceFullyEvolvedCB.isSelected()) {
Expand All @@ -1358,6 +1366,13 @@ private void enableOrDisableSubControls() {
this.tpForceFullyEvolvedSlider.setEnabled(false);
this.tpForceFullyEvolvedSlider.setValue(this.tpForceFullyEvolvedSlider.getMinimum());
}

if (this.tpLevelModifierCB.isSelected()) {
this.tpLevelModifierSlider.setEnabled(true);
} else {
this.tpLevelModifierSlider.setEnabled(false);
this.tpLevelModifierSlider.setValue(0);
}

if (!this.spUnchangedRB.isSelected() || !this.tpUnchangedRB.isSelected()) {
this.tpRivalCarriesStarterCB.setEnabled(true);
Expand Down Expand Up @@ -1692,6 +1707,8 @@ private void restoreStateFromSettings(Settings settings) {
this.tpNoEarlyShedinjaCB.setSelected(settings.isTrainersBlockEarlyWonderGuard());
this.tpForceFullyEvolvedCB.setSelected(settings.isTrainersForceFullyEvolved());
this.tpForceFullyEvolvedSlider.setValue(settings.getTrainersForceFullyEvolvedLevel());
this.tpLevelModifierCB.setSelected(settings.isTrainersLevelModified());
this.tpLevelModifierSlider.setValue(settings.getTrainersLevelModifier());

this.wpARCatchEmAllRB
.setSelected(settings.getWildPokemonRestrictionMod() == Settings.WildPokemonRestrictionMod.CATCH_EM_ALL);
Expand Down Expand Up @@ -1844,6 +1861,8 @@ private Settings createSettingsFromState(CustomNamesSet customNames) {
settings.setTrainersBlockEarlyWonderGuard(tpNoEarlyShedinjaCB.isSelected());
settings.setTrainersForceFullyEvolved(tpForceFullyEvolvedCB.isSelected());
settings.setTrainersForceFullyEvolvedLevel(tpForceFullyEvolvedSlider.getValue());
settings.setTrainersLevelModified(tpLevelModifierCB.isSelected());
settings.setTrainersLevelModifier(tpLevelModifierSlider.getValue());

settings.setWildPokemonMod(wpUnchangedRB.isSelected(), wpRandomRB.isSelected(), wpArea11RB.isSelected(),
wpGlobalRB.isSelected());
Expand Down Expand Up @@ -2477,6 +2496,9 @@ private void pbsChangesRandomRBActionPerformed(java.awt.event.ActionEvent evt) {
private void tpForceFullyEvolvedCBActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tpForceFullyEvolvedCBActionPerformed
this.enableOrDisableSubControls();
}// GEN-LAST:event_tpForceFullyEvolvedCBActionPerformed
private void tpLevelModifierCBActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tpForceFullyEvolvedCBActionPerformed
this.enableOrDisableSubControls();
}

private void wpCatchRateCBActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_wpCatchRateCBActionPerformed
this.enableOrDisableSubControls();
Expand Down Expand Up @@ -2654,6 +2676,8 @@ public void approveSelection() {
tpNoEarlyShedinjaCB = new javax.swing.JCheckBox();
tpForceFullyEvolvedCB = new javax.swing.JCheckBox();
tpForceFullyEvolvedSlider = new javax.swing.JSlider();
tpLevelModifierCB = new javax.swing.JCheckBox();
tpLevelModifierSlider = new javax.swing.JSlider();
wildsInnerPanel = new javax.swing.JPanel();
wildPokemonPanel = new javax.swing.JPanel();
wpUnchangedRB = new javax.swing.JRadioButton();
Expand Down Expand Up @@ -3716,6 +3740,23 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
tpForceFullyEvolvedSlider.setPaintTicks(true);
tpForceFullyEvolvedSlider.setToolTipText(bundle.getString("RandomizerGUI.tpForceFullyEvolvedSlider.toolTipText")); // NOI18N
tpForceFullyEvolvedSlider.setValue(30);

tpLevelModifierCB.setText(bundle.getString("RandomizerGUI.tpLevelModifierCB.text")); // NOI18N
tpLevelModifierCB.setToolTipText(bundle.getString("RandomizerGUI.tpLevelModifierCB.toolTipText")); // NOI18N
tpLevelModifierCB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tpLevelModifierCBActionPerformed(evt);
}
});

tpLevelModifierSlider.setMajorTickSpacing(10);
tpLevelModifierSlider.setMaximum(50);
tpLevelModifierSlider.setMinimum(-50);
tpLevelModifierSlider.setMinorTickSpacing(5);
tpLevelModifierSlider.setPaintLabels(true);
tpLevelModifierSlider.setPaintTicks(true);
tpLevelModifierSlider.setToolTipText(bundle.getString("RandomizerGUI.tpLevelModifierSlider.toolTipText")); // NOI18N
tpLevelModifierSlider.setValue(0);

javax.swing.GroupLayout trainersPokemonPanelLayout = new javax.swing.GroupLayout(trainersPokemonPanel);
trainersPokemonPanel.setLayout(trainersPokemonPanelLayout);
Expand All @@ -3742,7 +3783,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(tnRandomizeCB)
.addComponent(tcnRandomizeCB)
.addComponent(tpForceFullyEvolvedCB)
.addComponent(tpForceFullyEvolvedSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(tpForceFullyEvolvedSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(trainersPokemonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tpLevelModifierCB)
.addComponent(tpLevelModifierSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
))
.addContainerGap(143, Short.MAX_VALUE))
);
trainersPokemonPanelLayout.setVerticalGroup(
Expand All @@ -3751,24 +3797,32 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(trainersPokemonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tpUnchangedRB)
.addComponent(tpRivalCarriesStarterCB)
.addComponent(tnRandomizeCB))
.addComponent(tnRandomizeCB)
.addComponent(tpLevelModifierCB)
)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(trainersPokemonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tpRandomRB)
.addComponent(tpPowerLevelsCB)
.addComponent(tcnRandomizeCB))
.addComponent(tcnRandomizeCB)
.addComponent(tpLevelModifierSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(trainersPokemonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tpTypeThemedRB)
.addComponent(tpTypeWeightingCB)
.addComponent(tpForceFullyEvolvedCB))
.addComponent(tpForceFullyEvolvedCB)
)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(trainersPokemonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(trainersPokemonPanelLayout.createSequentialGroup()
.addComponent(tpNoLegendariesCB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(tpNoEarlyShedinjaCB))
.addComponent(tpForceFullyEvolvedSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(tpForceFullyEvolvedSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

Expand Down Expand Up @@ -4726,6 +4780,9 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
private javax.swing.JMenuItem toggleScrollPaneMenuItem;
private javax.swing.JCheckBox tpForceFullyEvolvedCB;
private javax.swing.JSlider tpForceFullyEvolvedSlider;
private javax.swing.JCheckBox tpLevelModifierCB;
private javax.swing.JSlider tpLevelModifierSlider;

private javax.swing.JCheckBox tpNoEarlyShedinjaCB;
private javax.swing.JCheckBox tpNoLegendariesCB;
private javax.swing.JCheckBox tpPowerLevelsCB;
Expand Down
Loading

0 comments on commit 2a21e77

Please sign in to comment.