diff --git a/app/src/main/java/com/kamron/pogoiv/pokeflycomponents/IVPopupButton.java b/app/src/main/java/com/kamron/pogoiv/pokeflycomponents/IVPopupButton.java index ce528453c..79e0c381b 100644 --- a/app/src/main/java/com/kamron/pogoiv/pokeflycomponents/IVPopupButton.java +++ b/app/src/main/java/com/kamron/pogoiv/pokeflycomponents/IVPopupButton.java @@ -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("*"); diff --git a/app/src/main/java/com/kamron/pogoiv/scanlogic/PokeInfoCalculator.java b/app/src/main/java/com/kamron/pogoiv/scanlogic/PokeInfoCalculator.java index cc6cd614f..fcd098462 100644 --- a/app/src/main/java/com/kamron/pogoiv/scanlogic/PokeInfoCalculator.java +++ b/app/src/main/java/com/kamron/pogoiv/scanlogic/PokeInfoCalculator.java @@ -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++) { @@ -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]) + ); + } + } } } @@ -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 getForms(Pokemon poke) { + ArrayList 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. * @@ -387,10 +431,12 @@ public ArrayList getEvolutionLine(Pokemon poke) { poke = getLowestEvolution(poke); ArrayList 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; diff --git a/app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java b/app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java index 99e5e0a2b..6f4d3aba7 100644 --- a/app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java +++ b/app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java @@ -44,6 +44,13 @@ public String getLetter() { */ public final List evolutions; + /** + * Forms of this Pokemon. + * This list dose not include the normal form. + * The normal form pokemon is this pokemon itself. + */ + public final List forms; + /** * Pokemon name for OCR, this is what you saw in PokemonGo app. */ @@ -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; } diff --git a/app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonNameCorrector.java b/app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonNameCorrector.java index 8ceafae85..692c6e2c8 100644 --- a/app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonNameCorrector.java +++ b/app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonNameCorrector.java @@ -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; } diff --git a/app/src/main/res/values-de/pokemons.xml b/app/src/main/res/values-de/pokemons.xml index 70762f9d8..3508b9910 100644 --- a/app/src/main/res/values-de/pokemons.xml +++ b/app/src/main/res/values-de/pokemons.xml @@ -388,9 +388,6 @@ Groudon Rayquaza Jirachi - Deoxys_Defense - Deoxys_Attack - Deoxys_Speed Deoxys \ No newline at end of file diff --git a/app/src/main/res/values-fr/pokemons.xml b/app/src/main/res/values-fr/pokemons.xml index a224f9e9a..f7df0cc59 100644 --- a/app/src/main/res/values-fr/pokemons.xml +++ b/app/src/main/res/values-fr/pokemons.xml @@ -388,9 +388,6 @@ Groudon Rayquaza Jirachi - Deoxys_Defense - Deoxys_Attack - Deoxys_Speed Deoxys \ No newline at end of file diff --git a/app/src/main/res/values/forms.xml b/app/src/main/res/values/forms.xml new file mode 100644 index 000000000..a882445b9 --- /dev/null +++ b/app/src/main/res/values/forms.xml @@ -0,0 +1,43 @@ + + + + 3 + 1 + + + + + Attack Forme + Defense Forme + Speed Forme + + Alola Form + + + + + 414 + 144 + 230 + + 230 + + + + + 46 + 330 + 218 + + 158 + + + + + 100 + 100 + 100 + + 190 + + \ No newline at end of file diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 813978074..2afb5bfea 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -389,9 +389,6 @@ 270 284 210 - 144 - 414 - 230 345 @@ -783,9 +780,6 @@ 251 170 210 - 330 - 46 - 218 115 @@ -1177,9 +1171,6 @@ 182 191 200 - 100 - 100 - 100 100 @@ -1571,11 +1562,7 @@ -1 -1 -1 - -1 - -1 - -1 -1 - @@ -1966,9 +1953,6 @@ -1 -1 -1 - -1 - -1 - -1 -1 @@ -2366,9 +2350,396 @@ 382 383 384 - 385 - 386 - 387 - 388 + 385 + + + + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + 1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + 0 diff --git a/app/src/main/res/values/pokemons.xml b/app/src/main/res/values/pokemons.xml index 820ef7a4b..38b94d2dc 100644 --- a/app/src/main/res/values/pokemons.xml +++ b/app/src/main/res/values/pokemons.xml @@ -389,9 +389,6 @@ Groudon Rayquaza Jirachi - Deoxys_Defense - Deoxys_Attack - Deoxys_Speed Deoxys