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

[Suggestion] pokemon types data #878

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static PokeInfoCalculator getInstance() {
*/
private PokeInfoCalculator(@NonNull GoIVSettings settings, @NonNull Resources res) {
populatePokemon(settings, res);
this.typeNamesArray = res.getStringArray(R.array.typeName);
}

public List<Pokemon> getPokedex() {
Expand Down Expand Up @@ -146,11 +145,14 @@ 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 String[] types = res.getStringArray(R.array.type);

int pokeListSize = names.length;
typeNamesArray = res.getStringArray(R.array.typeName);

for (int i = 0; i < pokeListSize; i++) {
Pokemon p = new Pokemon(names[i], displayNames[i], i, attack[i], defense[i], stamina[i], devolution[i],
evolutionCandyCost[i]);
evolutionCandyCost[i], getTypeNames(types[i]));
pokedex.add(p);
pokemap.put(names[i].toLowerCase(), p);
if (!names[i].equals(displayNames[i])) {
Expand Down Expand Up @@ -439,7 +441,43 @@ public int getHPAtLevel(IVScanResult ivScanResult, double selectedLevel, Pokemon
return averageHP;
}

public String getTypeName(int typeNameNum) {
return typeNamesArray[typeNameNum];
/**
* Get localized pokemon type names as a string array from a base20 value defined in types.xml.
*
* @param typeBase20 a pokemon type value indicated with 2 digits base20 value defined in types.xml
* @return A string array including localized pokemon type names. This array has 2 elements as max-length for a
* multi-type pokemon, or 1 element as min-length for a single type pokemon.
* If invalid value input, currently "N/A" returned as 1 element string array.
*/
private String[] getTypeNames(String typeBase20) {
// check invalid value
if (typeBase20.length() != 2) {
//TODO error handling
String[] typeNames = {"N/A"};
return typeNames;
}

Integer[] typeNum = new Integer[2];

typeNum[0] = Integer.parseInt(typeBase20.substring(0, 1), 20); // 1st type
typeNum[1] = Integer.parseInt(typeBase20.substring(1, 2), 20); // 2nd type

// check invalid value
if (!(0 < typeNum[0] && typeNum[0] < typeNamesArray.length)
|| !(0 <= typeNum[1] && typeNum[1] < typeNamesArray.length)) {
//TODO error handling
String[] typeNames = {"N/A"};
return typeNames;
}

if (typeNum[1] == 0) {
// Single-type Pokemon
String[] typeNames = {typeNamesArray[typeNum[0] - 1]};
return typeNames;
} else {
// Multi-type Pokemon
String[] typeNames = {typeNamesArray[typeNum[0] - 1], typeNamesArray[typeNum[1] - 1]};
return typeNames;
}
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/kamron/pogoiv/scanlogic/Pokemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public String getCharacter() {
public final int baseStamina;
public final int devoNumber;
public final int candyEvolutionCost;
public final String[] types;

public Pokemon(String name, String displayName, int number, int baseAttack, int baseDefense, int baseStamina,
int devoNumber, int candyEvolutionCost) {
int devoNumber, int candyEvolutionCost, String[] types) {
this.name = name;
this.displayName = displayName;
this.number = number;
Expand All @@ -68,6 +69,7 @@ public Pokemon(String name, String displayName, int number, int baseAttack, int
this.devoNumber = devoNumber;
this.evolutions = new ArrayList<>();
this.candyEvolutionCost = candyEvolutionCost;
this.types = types;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ public PokeDist getPossiblePokemon(String poketext, String candytext, Optional<I
//3. check correction for Eevee’s Evolution using it's Pokemon Type
if (guess.pokemon == null && candytext.toLowerCase().contains(pokeInfoCalculator.get(132).name.toLowerCase())) {
HashMap<String, String> eeveelutionCorrection = new HashMap<>();
eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(2), //WATER
pokeInfoCalculator.get(133).name); //Vaporeon
eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(3), //ELECTRIC
pokeInfoCalculator.get(134).name); //Jolteon
eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(1), //FIRE
pokeInfoCalculator.get(135).name); //Flareon
eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(10), //PSYCHIC
pokeInfoCalculator.get(195).name); //Espeon
eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(15), //DARK
pokeInfoCalculator.get(196).name); //Umbreon
Pokemon vaporeon = pokeInfoCalculator.get(133);
Pokemon jolteon = pokeInfoCalculator.get(134);
Pokemon flareon = pokeInfoCalculator.get(135);
Pokemon espeon = pokeInfoCalculator.get(195);
Pokemon umbreon = pokeInfoCalculator.get(196);
eeveelutionCorrection.put(vaporeon.types[0], vaporeon.name); //WATER
eeveelutionCorrection.put(jolteon.types[0], jolteon.name); //ELECTRIC
eeveelutionCorrection.put(flareon.types[0], flareon.name); //FIRE
eeveelutionCorrection.put(espeon.types[0], espeon.name); //PSYCHIC
eeveelutionCorrection.put(umbreon.types[0], umbreon.name); //DARK
// Preparing for the future....
// eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(4), //GRASS
// pokeInfoCalculator.get(469).name); //Leafeon
// eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(5), //ICE
// pokeInfoCalculator.get(470).name); //Glaceon
// eeveelutionCorrection.put(pokeInfoCalculator.getTypeName(17), //FAIRY
// pokeInfoCalculator.get(699).name); //Sylveon
// Pokemon leafeon = pokeInfoCalculator.get(469);
// Pokemon glaceon = pokeInfoCalculator.get(470);
// Pokemon sylveon = pokeInfoCalculator.get(699);
// eeveelutionCorrection.put(leafeon.types[0], leafeon.name); //GRASS
// eeveelutionCorrection.put(glaceon.types[0], glaceon.name); //ICE
// eeveelutionCorrection.put(sylveon.types[0], sylveon.name); //FAIRY
if (eeveelutionCorrection.containsKey(pokemonType)) {
poketext = eeveelutionCorrection.get(pokemonType);
guess = new PokeDist(pokeInfoCalculator.get(poketext), 0);
Expand Down
23 changes: 0 additions & 23 deletions app/src/main/res/values-es/pokemons.xml

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/main/res/values-es/types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="typeName">
<!-- 0 NONE -->
<!-- 1 normal --> <item>NORMAL</item>
<!-- 2 fire --> <item>FUEGO</item>
<!-- 3 water --> <item>AGUA</item>
<!-- 4 grass --> <item>PLANTA</item>
<!-- 5 electric --> <item>ELÉCTRICO</item>
<!-- 6 ice --> <item>HIELO</item>
<!-- 7 fighting --> <item>LUCHA</item>
<!-- 8 poison --> <item>VENENO</item>
<!-- 9 ground --> <item>TIERRA</item>
<!-- A flying --> <item>VOLADOR</item>
<!-- B psychic --> <item>PSÍQUICO</item>
<!-- C bug --> <item>BICHO</item>
<!-- D rock --> <item>ROCA</item>
<!-- E ghost --> <item>FANTASMA</item>
<!-- F dragon --> <item>DRAGÓN</item>
<!-- G dark --> <item>SINIESTRO</item>
<!-- H steel --> <item>ACERO</item>
<!-- I fairy --> <item>HADA</item>
<!-- J RESERVED -->
</string-array>
</resources>
23 changes: 0 additions & 23 deletions app/src/main/res/values-it/pokemons.xml

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/main/res/values-it/types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="typeName">
<!-- 0 NONE -->
<!-- 1 normal --> <item>NORMALE</item>
<!-- 2 fire --> <item>FUOCO</item>
<!-- 3 water --> <item>ACQUA</item>
<!-- 4 grass --> <item>ERBA</item>
<!-- 5 electric --> <item>ELETTRO</item>
<!-- 6 ice --> <item>GHIACCIO</item>
<!-- 7 fighting --> <item>LOTTA</item>
<!-- 8 poison --> <item>VELENO</item>
<!-- 9 ground --> <item>TERRA</item>
<!-- A flying --> <item>VOLANTE</item>
<!-- B psychic --> <item>PSICO</item>
<!-- C bug --> <item>COLEOTTERO</item>
<!-- D rock --> <item>ROCCIA</item>
<!-- E ghost --> <item>SPETTRO</item>
<!-- F dragon --> <item>DRAGO</item>
<!-- G dark --> <item>BUIO</item>
<!-- H steel --> <item>ACCIAIO</item>
<!-- I fairy --> <item>FOLLETTO</item>
<!-- J RESERVED -->
</string-array>
</resources>
20 changes: 0 additions & 20 deletions app/src/main/res/values/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,4 @@
<item>Deoxys_Speed</item>
<item>Deoxys</item>
</string-array>
<string-array name="typeName">
<!-- 0 normal --> <item>NORMAL</item>
<!-- 1 fire --> <item>FIRE</item>
<!-- 2 water --> <item>WATER</item>
<!-- 3 electric --> <item>ELECTRIC</item>
<!-- 4 grass --> <item>GRASS</item>
<!-- 5 ice --> <item>ICE</item>
<!-- 6 fighting --> <item>FIGHTING</item>
<!-- 7 poison --> <item>POISON</item>
<!-- 8 ground --> <item>GROUND</item>
<!-- 9 flying --> <item>FLYING</item>
<!-- 10 psychic --> <item>PSYCHIC</item>
<!-- 11 bug --> <item>BUG</item>
<!-- 12 rock --> <item>ROCK</item>
<!-- 13 ghost --> <item>GHOST</item>
<!-- 14 dragon --> <item>DRAGON</item>
<!-- 15 dark --> <item>DARK</item>
<!-- 16 steel --> <item>STEEL</item>
<!-- 17 fairy --> <item>FAIRY</item>
</string-array>
</resources>
Loading