Skip to content

Commit

Permalink
Added HP Distribution Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anmart committed Jul 19, 2016
1 parent c77d01b commit 0955cae
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 28 deletions.
96 changes: 91 additions & 5 deletions src/randomizer/Pokemon_TCG/PTCG1_Randomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class PTCG1_Randomizer {

Move blankMove = new Move();

boolean maxEvolutionsHaveBeenFound = false;


public PTCG1_Randomizer(File game, String seed){


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




for(int j = moveList.size()-1; j >= 0; j--){
Move currMove = moveList.get(j);

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

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

ArrayList<Word> deckPointers = new ArrayList<Word>();
Expand Down Expand Up @@ -507,11 +511,13 @@ public void randomizeHP(int low, int high, boolean allowGlitchHP){
mons[i].hp =(byte) ((int)(rand.nextInt((high-low)/10)*10 + low));
}
}



}

public void SanquiRemoveTutorialFromRom(){
//NOTE: this writes directly to rom


//magic numbers
int sizeOfTutorial = 229;
int tutorialStartLoc = 0xD76F;
Expand All @@ -536,8 +542,14 @@ public ArrayList<MonCardData> indicesOfPokemonFromNamePointer(Word namePointer,
}
return ret;
}



public void randomizeEvolutions(int maxSize, boolean monoType){

if(maxSize < 1)
maxSize = 999;

ArrayList<MonCardData> randMons = new ArrayList<MonCardData>(Arrays.asList(mons));
Collections.shuffle(randMons, rand);
ArrayList<MonCardData> tempInd; // used a few times for a short amount of time
Expand Down Expand Up @@ -607,15 +619,15 @@ public void randomizeEvolutions(int maxSize, boolean monoType){
currMon = newMon;
}

tempInd = indicesOfPokemonFromNamePointer(currMon.name, randMons);
tempInd = indicesOfPokemonFromNamePointer(currMon.name, usedMons);
for(MonCardData mc : tempInd){
mc.highestStage = true;
}


}


maxEvolutionsHaveBeenFound = true;
}

public void setMoveTypeToMonType() {
Expand Down Expand Up @@ -670,6 +682,80 @@ public void setMoveTypeToMonType() {

}


public void findMaxEvolutionsForMons(){
for(MonCardData monCurrent : mons){
boolean foundHigher = false;

for(MonCardData monPossibleEvo : mons){
if(monPossibleEvo.preEvoName.equals(monCurrent.name)){
foundHigher = true;
break;
}

}

if(!foundHigher)
monCurrent.highestStage = true;

}


maxEvolutionsHaveBeenFound = true;
}


public boolean fixHPForChains() {


if(!maxEvolutionsHaveBeenFound)
findMaxEvolutionsForMons();

ArrayList<MonCardData> monsList = new ArrayList<MonCardData>(Arrays.asList(mons));

while(monsList.size() > 0){

ArrayList<MonCardData> evolutionChain = new ArrayList<MonCardData>();
ArrayList<MonCardData> chainStageMons;
ArrayList<Byte> HPs = new ArrayList<Byte>();

MonCardData currMon = null;

for(int i = 0; i < monsList.size(); i++){
if(monsList.get(i).highestStage){
currMon = monsList.get(i);
}
}

if(currMon == null){
return false;
}


chainStageMons = indicesOfPokemonFromNamePointer(currMon.name, monsList);
while(chainStageMons.size() > 0){
currMon = chainStageMons.get(0); //we know it's >0, we need another mon for the next stage
for(MonCardData mc : chainStageMons){
evolutionChain.add(mc);
HPs.add(mc.hp);
monsList.remove(mc);

}

chainStageMons = indicesOfPokemonFromNamePointer(currMon.preEvoName, monsList);
}

Collections.sort(HPs);
for(int i = 0; i < evolutionChain.size(); i++){
evolutionChain.get(i).hp = HPs.get(evolutionChain.size() - i - 1);
}

}


return true;
}



}
40 changes: 30 additions & 10 deletions src/randomizer/Pokemon_TCG/PTCG1_UI.form
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,13 @@
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSeparator4" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="randomizeHealth" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
Expand All @@ -254,8 +253,6 @@
<Component id="healthHigh" min="-2" pref="48" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="allowGlitchHPs" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="evosHaveMoreHP" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="randomizeSets" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
Expand All @@ -270,21 +267,29 @@
<Component id="movesCostSameAsType" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="randomizeHealth" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="evosHaveMoreHP" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="randomizeHealth" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="randomizeHealth" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="evosHaveMoreHP" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="healthLow" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="healthHigh" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="allowGlitchHPs" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="evosHaveMoreHP" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="6" max="32767" attributes="0"/>
<Component id="jSeparator4" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -403,7 +408,7 @@
</Component>
<Component class="javax.swing.JCheckBox" name="evosHaveMoreHP">
<Properties>
<Property name="text" type="java.lang.String" value="Fix Evolution Health "/>
<Property name="text" type="java.lang.String" value="Fix Evolution HP Distribution Bug"/>
<Property name="toolTipText" type="java.lang.String" value="Evolutions have &gt;= health of lower form"/>
</Properties>
</Component>
Expand Down Expand Up @@ -610,14 +615,19 @@
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="randomizeEvolutions" min="-2" max="-2" attributes="0"/>
<Component id="randomizeWarps" min="-2" max="-2" attributes="0"/>
<Component id="randomizeEvolutions" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
Expand All @@ -633,7 +643,9 @@
<Component id="setMaxEvolutionChain" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="maxEvolutionChainValue" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="83" max="32767" attributes="0"/>
<EmptySpace pref="35" max="32767" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -648,7 +660,7 @@
<Component class="javax.swing.JCheckBox" name="randomizeEvolutions">
<Properties>
<Property name="text" type="java.lang.String" value="Randomize Evolutions"/>
<Property name="toolTipText" type="java.lang.String" value="Allows for randomized evolutions. MIGHT BREAK HP FIX."/>
<Property name="toolTipText" type="java.lang.String" value="Allows for randomized evolutions. BREAKS MOVE RADNOMIZATION WITHIN STAGE"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="randomizeEvolutionsActionPerformed"/>
Expand All @@ -673,6 +685,14 @@
<Property name="toolTipText" type="java.lang.String" value="if &lt;1 or not a number, sets evolution size to infinite"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="18" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="THESE MAY BREAK SOMETHING."/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Loading

0 comments on commit 0955cae

Please sign in to comment.