Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

patch for Alola Exeggutor and other Alolans #926

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,16 @@ public void showQuickIVPreviewLook(@NonNull ScanResult scanResult) {
int high = highest.percentPerfect;

final StringBuilder text = new StringBuilder();
String pokemonName = scanResult.pokemon.name;
if (pokemonName.contains(" - ")) { // check including form name
pokemonName = pokemonName.replace(" - ", "\n");
}
if (scanResult.getIVCombinationsCount() == 1 || high == low) { // Display something like "IV: 98%"
text.append(getContext().getString(
R.string.iv_button_exact_result_preview_format, scanResult.pokemon.name, low));
R.string.iv_button_exact_result_preview_format, pokemonName, low));
} else { // Display something like "IV: 55 - 87%"
text.append(getContext().getString(
R.string.iv_button_range_result_preview_format, scanResult.pokemon.name, low, high));
R.string.iv_button_range_result_preview_format, pokemonName, low, high));
}
if (scanResult.levelRange.min != scanResult.levelRange.max) {
text.append("*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private void populatePokemon(@NonNull GoIVSettings settings, @NonNull Resources
final int[] devolution = res.getIntArray(R.array.devolutionNumber);
final int[] evolutionCandyCost = res.getIntArray(R.array.evolutionCandyCost);
final int[] candyNamesArray = res.getIntArray(R.array.candyNames);
final int[] formsCountIndex = res.getIntArray(R.array.formsCountIndex);

int pokeListSize = names.length;
for (int i = 0; i < pokeListSize; i++) {
Expand All @@ -165,6 +166,30 @@ private void populatePokemon(@NonNull GoIVSettings settings, @NonNull Resources
candyPokemons.add(pokedex.get(candyNamesArray[i]));
basePokemons.add(pokedex.get(i));
}

if (formsCountIndex[i] != -1) {
int[] formsCount = res.getIntArray(R.array.formsCount);
int formsStartIndex = 0;

for (int j = 0; j < formsCountIndex[i]; j++) {
formsStartIndex += formsCount[j];
}

for (int j = 0; j < formsCount[formsCountIndex[i]]; j++) {
pokedex.get(i).forms.add(new Pokemon(
String.format("%s - %s",
pokedex.get(i).name, res.getStringArray(R.array.formNames)[formsStartIndex + j]),
String.format("%s - %s",
pokedex.get(i).toString(), res.getStringArray(R.array.formNames)[formsStartIndex + j]),
i,
res.getIntArray(R.array.formAttack)[formsStartIndex + j],
res.getIntArray(R.array.formDefense)[formsStartIndex + j],
res.getIntArray(R.array.formStamina)[formsStartIndex + j],
devolution[i],
evolutionCandyCost[i])
);
}
}
}
}

Expand Down Expand Up @@ -377,6 +402,25 @@ private Pokemon getLowestEvolution(Pokemon poke) {
return devoPoke;
}

/**
* Get all the pokemon forms for a pokemon.
*
* @param poke a pokemon, example Exeggutor
* @return all the pokemon forms, in the example would return Exeggutor normal and Exeggutor Alola
*/
private ArrayList<Pokemon> getForms(Pokemon poke) {
ArrayList<Pokemon> list = new ArrayList<>();
Pokemon normalFormPokemon = pokedex.get(poke.number);
list.add(normalFormPokemon);

if (normalFormPokemon.forms.isEmpty()) {
return list; // normal form only
}

list.addAll(normalFormPokemon.forms);
return list;
}

/**
* Returns the evolution line of a pokemon.
*
Expand All @@ -387,10 +431,12 @@ public ArrayList<Pokemon> getEvolutionLine(Pokemon poke) {
poke = getLowestEvolution(poke);

ArrayList<Pokemon> list = new ArrayList<>();
list.add(poke); //add self
list.addAll(poke.evolutions); //add all immediate evolutions
for (Pokemon evolution : poke.evolutions) {
list.addAll(evolution.evolutions);
list.addAll(getForms(poke));
for (Pokemon evolution2nd : poke.evolutions) {
list.addAll(getForms(evolution2nd));
for (Pokemon evolution3rd : evolution2nd.evolutions) {
list.addAll(getForms(evolution3rd));
}
}

return list;
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public String getLetter() {
*/
public final List<Pokemon> evolutions;

/**
* Forms of this Pokemon.
* This list dose not include the normal form.
* The normal form pokemon is this pokemon itself.
*/
public final List<Pokemon> forms;

/**
* Pokemon name for OCR, this is what you saw in PokemonGo app.
*/
Expand Down Expand Up @@ -71,6 +78,7 @@ public Pokemon(String name, String displayName, int number, int baseAttack, int
this.baseStamina = baseStamina;
this.devoNumber = devoNumber;
this.evolutions = new ArrayList<>();
this.forms = new ArrayList<>();
this.candyEvolutionCost = candyEvolutionCost;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ public PokeDist getPossiblePokemon(@NonNull ScanData scanData) {
if (guess.pokemon == null) {
guess = getNicknameGuess(scanData.getPokemonName(), pokeInfoCalculator.getPokedex());
}

// check Alola form
switch (guess.pokemon.number) {
case (102): // Exeggutor
// check types including dragon
if (scanData.getPokemonType().toLowerCase().contains(
pokeInfoCalculator.getTypeName(14).toLowerCase())) {
guess = new PokeDist(pokeInfoCalculator.get(102).forms.get(0), 0);
}
break;

default:
// do nothing
}

return guess;
}

Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values-de/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@
<item>Groudon</item>
<item>Rayquaza</item>
<item>Jirachi</item>
<item>Deoxys_Defense</item>
<item>Deoxys_Attack</item>
<item>Deoxys_Speed</item>
<item>Deoxys</item>
</string-array>
</resources>
3 changes: 0 additions & 3 deletions app/src/main/res/values-fr/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@
<item>Groudon</item>
<item>Rayquaza</item>
<item>Jirachi</item>
<item>Deoxys_Defense</item>
<item>Deoxys_Attack</item>
<item>Deoxys_Speed</item>
<item>Deoxys</item>
</string-array>
</resources>
43 changes: 43 additions & 0 deletions app/src/main/res/values/forms.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer-array name="formsCount">
<item>3</item><!-- Deoxys -->
<item>1</item><!-- Exeggutor -->
</integer-array>

<string-array name="formNames">
<!-- Deoxys -->
<item>Attack Forme</item>
<item>Defense Forme</item>
<item>Speed Forme</item>
<!-- Exeggutor -->
<item>Alola Form</item>
</string-array>

<integer-array name="formAttack">
<!-- Deoxys -->
<item>414</item> <!--DeoxysAttack-->
<item>144</item> <!--DeoxysDefens-->
<item>230</item> <!--DeoxysSpeed -->
<!-- Exeggutor -->
<item>230</item> <!--ExeggutorAlola-->
</integer-array>

<integer-array name="formDefense">
<!-- Deoxys -->
<item>46</item> <!--DeoxysAttack-->
<item>330</item> <!--DeoxysDefens-->
<item>218</item> <!--DeoxysSpeed -->
<!-- Exeggutor -->
<item>158</item> <!--ExeggutorAlola-->
</integer-array>

<integer-array name="formStamina">
<!-- Deoxys -->
<item>100</item> <!--DeoxysAttack-->
<item>100</item> <!--DeoxysDefens-->
<item>100</item> <!--DeoxysSpeed -->
<!-- Exeggutor -->
<item>190</item> <!--ExeggutorAlola-->
</integer-array>
</resources>
Loading