Skip to content

Commit 0955cae

Browse files
committed
Added HP Distribution Fix
1 parent c77d01b commit 0955cae

File tree

3 files changed

+156
-28
lines changed

3 files changed

+156
-28
lines changed

src/randomizer/Pokemon_TCG/PTCG1_Randomizer.java

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public class PTCG1_Randomizer {
2828

2929
Move blankMove = new Move();
3030

31+
boolean maxEvolutionsHaveBeenFound = false;
32+
33+
3134
public PTCG1_Randomizer(File game, String seed){
3235

3336

@@ -316,6 +319,7 @@ public void randomizeMoves(boolean keepStage, boolean keepMoveAmount){
316319

317320

318321

322+
319323
for(int j = moveList.size()-1; j >= 0; j--){
320324
Move currMove = moveList.get(j);
321325

@@ -452,7 +456,7 @@ public void randomizeDeckPointersInRom(boolean skipStarterDecks){
452456
int[] skippedDeckIDs = new int[]{}; // for skipping starter decks. eventually might let users pick decks to skip
453457

454458
if(skipStarterDecks){
455-
skippedDeckIDs = new int[]{ 5,7,9 }; // hardcoded values from the assembly. might need to include extra decks here as well
459+
skippedDeckIDs = new int[]{ 5,6,7,8,9,10 }; // hardcoded values from the assembly. might need to include extra decks here as well
456460
}
457461

458462
ArrayList<Word> deckPointers = new ArrayList<Word>();
@@ -507,11 +511,13 @@ public void randomizeHP(int low, int high, boolean allowGlitchHP){
507511
mons[i].hp =(byte) ((int)(rand.nextInt((high-low)/10)*10 + low));
508512
}
509513
}
514+
515+
516+
510517
}
511518

512519
public void SanquiRemoveTutorialFromRom(){
513-
//NOTE: this writes directly to rom
514-
520+
515521
//magic numbers
516522
int sizeOfTutorial = 229;
517523
int tutorialStartLoc = 0xD76F;
@@ -536,8 +542,14 @@ public ArrayList<MonCardData> indicesOfPokemonFromNamePointer(Word namePointer,
536542
}
537543
return ret;
538544
}
545+
546+
547+
539548
public void randomizeEvolutions(int maxSize, boolean monoType){
540549

550+
if(maxSize < 1)
551+
maxSize = 999;
552+
541553
ArrayList<MonCardData> randMons = new ArrayList<MonCardData>(Arrays.asList(mons));
542554
Collections.shuffle(randMons, rand);
543555
ArrayList<MonCardData> tempInd; // used a few times for a short amount of time
@@ -607,15 +619,15 @@ public void randomizeEvolutions(int maxSize, boolean monoType){
607619
currMon = newMon;
608620
}
609621

610-
tempInd = indicesOfPokemonFromNamePointer(currMon.name, randMons);
622+
tempInd = indicesOfPokemonFromNamePointer(currMon.name, usedMons);
611623
for(MonCardData mc : tempInd){
612624
mc.highestStage = true;
613625
}
614626

615627

616628
}
617629

618-
630+
maxEvolutionsHaveBeenFound = true;
619631
}
620632

621633
public void setMoveTypeToMonType() {
@@ -670,6 +682,80 @@ public void setMoveTypeToMonType() {
670682

671683
}
672684

685+
686+
public void findMaxEvolutionsForMons(){
687+
for(MonCardData monCurrent : mons){
688+
boolean foundHigher = false;
689+
690+
for(MonCardData monPossibleEvo : mons){
691+
if(monPossibleEvo.preEvoName.equals(monCurrent.name)){
692+
foundHigher = true;
693+
break;
694+
}
695+
696+
}
697+
698+
if(!foundHigher)
699+
monCurrent.highestStage = true;
700+
701+
}
702+
703+
704+
maxEvolutionsHaveBeenFound = true;
705+
}
706+
707+
708+
public boolean fixHPForChains() {
709+
710+
711+
if(!maxEvolutionsHaveBeenFound)
712+
findMaxEvolutionsForMons();
713+
714+
ArrayList<MonCardData> monsList = new ArrayList<MonCardData>(Arrays.asList(mons));
715+
716+
while(monsList.size() > 0){
717+
718+
ArrayList<MonCardData> evolutionChain = new ArrayList<MonCardData>();
719+
ArrayList<MonCardData> chainStageMons;
720+
ArrayList<Byte> HPs = new ArrayList<Byte>();
721+
722+
MonCardData currMon = null;
723+
724+
for(int i = 0; i < monsList.size(); i++){
725+
if(monsList.get(i).highestStage){
726+
currMon = monsList.get(i);
727+
}
728+
}
729+
730+
if(currMon == null){
731+
return false;
732+
}
733+
734+
735+
chainStageMons = indicesOfPokemonFromNamePointer(currMon.name, monsList);
736+
while(chainStageMons.size() > 0){
737+
currMon = chainStageMons.get(0); //we know it's >0, we need another mon for the next stage
738+
for(MonCardData mc : chainStageMons){
739+
evolutionChain.add(mc);
740+
HPs.add(mc.hp);
741+
monsList.remove(mc);
742+
743+
}
744+
745+
chainStageMons = indicesOfPokemonFromNamePointer(currMon.preEvoName, monsList);
746+
}
747+
748+
Collections.sort(HPs);
749+
for(int i = 0; i < evolutionChain.size(); i++){
750+
evolutionChain.get(i).hp = HPs.get(evolutionChain.size() - i - 1);
751+
}
752+
753+
}
754+
755+
756+
return true;
757+
}
758+
673759

674760

675761
}

src/randomizer/Pokemon_TCG/PTCG1_UI.form

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,13 @@
235235
</Group>
236236
</Group>
237237
</Group>
238-
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
238+
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
239239
</Group>
240240
<Group type="102" attributes="0">
241241
<Group type="103" groupAlignment="0" attributes="0">
242242
<Component id="jSeparator4" alignment="0" max="32767" attributes="0"/>
243243
<Group type="102" attributes="0">
244244
<Group type="103" groupAlignment="0" attributes="0">
245-
<Component id="randomizeHealth" alignment="0" min="-2" max="-2" attributes="0"/>
246245
<Group type="102" alignment="0" attributes="0">
247246
<EmptySpace max="-2" attributes="0"/>
248247
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
@@ -254,8 +253,6 @@
254253
<Component id="healthHigh" min="-2" pref="48" max="-2" attributes="0"/>
255254
<EmptySpace type="unrelated" max="-2" attributes="0"/>
256255
<Component id="allowGlitchHPs" min="-2" max="-2" attributes="0"/>
257-
<EmptySpace max="-2" attributes="0"/>
258-
<Component id="evosHaveMoreHP" min="-2" max="-2" attributes="0"/>
259256
</Group>
260257
<Component id="randomizeSets" alignment="0" min="-2" max="-2" attributes="0"/>
261258
</Group>
@@ -270,21 +267,29 @@
270267
<Component id="movesCostSameAsType" min="-2" max="-2" attributes="0"/>
271268
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
272269
</Group>
270+
<Group type="102" alignment="0" attributes="0">
271+
<Component id="randomizeHealth" min="-2" max="-2" attributes="0"/>
272+
<EmptySpace max="32767" attributes="0"/>
273+
<Component id="evosHaveMoreHP" min="-2" max="-2" attributes="0"/>
274+
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
275+
</Group>
273276
</Group>
274277
</DimensionLayout>
275278
<DimensionLayout dim="1">
276279
<Group type="103" groupAlignment="0" attributes="0">
277280
<Group type="102" alignment="0" attributes="0">
278281
<EmptySpace max="-2" attributes="0"/>
279-
<Component id="randomizeHealth" min="-2" max="-2" attributes="0"/>
282+
<Group type="103" groupAlignment="3" attributes="0">
283+
<Component id="randomizeHealth" alignment="3" min="-2" max="-2" attributes="0"/>
284+
<Component id="evosHaveMoreHP" alignment="3" min="-2" max="-2" attributes="0"/>
285+
</Group>
280286
<EmptySpace max="-2" attributes="0"/>
281287
<Group type="103" groupAlignment="3" attributes="0">
282288
<Component id="healthLow" alignment="3" min="-2" max="-2" attributes="0"/>
283289
<Component id="healthHigh" alignment="3" min="-2" max="-2" attributes="0"/>
284290
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
285291
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
286292
<Component id="allowGlitchHPs" alignment="3" min="-2" max="-2" attributes="0"/>
287-
<Component id="evosHaveMoreHP" alignment="3" min="-2" max="-2" attributes="0"/>
288293
</Group>
289294
<EmptySpace pref="6" max="32767" attributes="0"/>
290295
<Component id="jSeparator4" min="-2" max="-2" attributes="0"/>
@@ -403,7 +408,7 @@
403408
</Component>
404409
<Component class="javax.swing.JCheckBox" name="evosHaveMoreHP">
405410
<Properties>
406-
<Property name="text" type="java.lang.String" value="Fix Evolution Health "/>
411+
<Property name="text" type="java.lang.String" value="Fix Evolution HP Distribution Bug"/>
407412
<Property name="toolTipText" type="java.lang.String" value="Evolutions have &gt;= health of lower form"/>
408413
</Properties>
409414
</Component>
@@ -610,14 +615,19 @@
610615
</Group>
611616
<Group type="102" attributes="0">
612617
<Group type="103" groupAlignment="0" attributes="0">
613-
<Component id="randomizeEvolutions" min="-2" max="-2" attributes="0"/>
614618
<Component id="randomizeWarps" min="-2" max="-2" attributes="0"/>
619+
<Component id="randomizeEvolutions" alignment="0" min="-2" max="-2" attributes="0"/>
615620
</Group>
616621
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
617622
</Group>
618623
</Group>
619624
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
620625
</Group>
626+
<Group type="102" alignment="0" attributes="0">
627+
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
628+
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
629+
<EmptySpace max="32767" attributes="0"/>
630+
</Group>
621631
</Group>
622632
</DimensionLayout>
623633
<DimensionLayout dim="1">
@@ -633,7 +643,9 @@
633643
<Component id="setMaxEvolutionChain" alignment="3" min="-2" max="-2" attributes="0"/>
634644
<Component id="maxEvolutionChainValue" alignment="3" min="-2" max="-2" attributes="0"/>
635645
</Group>
636-
<EmptySpace pref="83" max="32767" attributes="0"/>
646+
<EmptySpace pref="35" max="32767" attributes="0"/>
647+
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
648+
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
637649
</Group>
638650
</Group>
639651
</DimensionLayout>
@@ -648,7 +660,7 @@
648660
<Component class="javax.swing.JCheckBox" name="randomizeEvolutions">
649661
<Properties>
650662
<Property name="text" type="java.lang.String" value="Randomize Evolutions"/>
651-
<Property name="toolTipText" type="java.lang.String" value="Allows for randomized evolutions. MIGHT BREAK HP FIX."/>
663+
<Property name="toolTipText" type="java.lang.String" value="Allows for randomized evolutions. BREAKS MOVE RADNOMIZATION WITHIN STAGE"/>
652664
</Properties>
653665
<Events>
654666
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="randomizeEvolutionsActionPerformed"/>
@@ -673,6 +685,14 @@
673685
<Property name="toolTipText" type="java.lang.String" value="if &lt;1 or not a number, sets evolution size to infinite"/>
674686
</Properties>
675687
</Component>
688+
<Component class="javax.swing.JLabel" name="jLabel7">
689+
<Properties>
690+
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
691+
<Font name="Tahoma" size="18" style="1"/>
692+
</Property>
693+
<Property name="text" type="java.lang.String" value="THESE MAY BREAK SOMETHING."/>
694+
</Properties>
695+
</Component>
676696
</SubComponents>
677697
</Container>
678698
</SubComponents>

0 commit comments

Comments
 (0)