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

Commit

Permalink
Merge pull request #1091 from udnp/pr/galarian-GM1591923010145076
Browse files Browse the repository at this point in the history
Galarian Pokemons
  • Loading branch information
nahojjjen authored Jun 17, 2020
2 parents 547830c + 02b54d9 commit 84cd2ca
Show file tree
Hide file tree
Showing 9 changed files with 451 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public class PokeInfoCalculator {
private List<Pokemon> formVariantPokemons;
private String[] pokeNamesWithForm = {};

public static final int MELTAN_INDEX_OFFSET = 5;
public static final int MELMETAL_INDEX_OFFSET = 4;
public static final int OBSTAGOON_INDEX_OFFSET = 3;
public static final int PERRSERKER_INDEX_OFFSET = 2;
public static final int SIRFETCHD_INDEX_OFFSET = 1;

/**
* Pokemons who's name appears as a type of candy.
* For most, this is the basePokemon (ie: Pidgey candies)
Expand Down Expand Up @@ -177,13 +183,18 @@ private void populatePokemon(@NonNull GoIVSettings settings, @NonNull Resources
int pokeListSize = names.length;
ArrayList<Pokemon> formVariantPokemons = new ArrayList<>();

// quick hardcoded patch for Meltan and Melmetal
// Tentatively use pokedex list size until supporting discontinuous pokedex numbers,
// like as #493 Arceus, #808 Meltan, #809 Melmetal.
candyNamesArray[pokeListSize - 2] = pokeListSize - 2;
candyNamesArray[pokeListSize - 1] = pokeListSize - 2;
devolution[pokeListSize - 1] = pokeListSize - 2;
// END patch for Meltan and Melmetal
// quick hardcoded patch for supporting discontinuous pokedex number pokemons followings
// #808 Meltan
// #809 Melmetal
// #862 Obstagoon,
// #863 Perrserker,
// #865 Sirfetch'd
// currently GoIV logic expects that pokedex numbers are continuous and less than pokeListSize.
// so this patch shifts these to dummy indexes, with pokeListSize offset.
candyNamesArray[pokeListSize - MELTAN_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
candyNamesArray[pokeListSize - MELMETAL_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
devolution[pokeListSize - MELMETAL_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
// END patch for supporting discontinuous pokedex number pokemons

for (int i = 0; i < pokeListSize; i++) {
PokemonBase p = new PokemonBase(names[i], displayNames[i], i, devolution[i], evolutionCandyCost[i]);
Expand Down
93 changes: 93 additions & 0 deletions app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,99 @@ public Pokemon getForm(@NonNull Pokemon otherForm) {
// In that case return the first one, which can be done in any case if this base has multiple forms (because
// then we know that the other form is the single one). But if the other form has multiple forms it also needs
// to verify that the other form is actually the first one.

final int pokeListSize = PokeInfoCalculator.getInstance().getPokedex().size();

if (number == 51) { // #52 Meowth
// check #863 Perrserker with its index number in pokemons.xml
if (otherForm.number == pokeListSize - PokeInfoCalculator.PERRSERKER_INDEX_OFFSET) {
// return Galarian forms
return forms.get(2);
} else {
return getForm(otherForm.formName);
}
}
if (number == 52) { // #53 Persian
return getForm(otherForm.formName);
}
if (number == 82) { // #83 Farfetch'd
// check #865 Sirfetch'd with its index number in pokemons.xml
if (otherForm.number == pokeListSize - PokeInfoCalculator.SIRFETCHD_INDEX_OFFSET) {
// return Galarian forms
return forms.get(1);
} else {
return getForm(otherForm.formName);
}
}
if (number == 262 || number == 263) { // #263 ZIGZAGOON or #264 LINOONE
// check #862 OBSTAGOON with its index number in pokemons.xml
if (otherForm.number == pokeListSize - PokeInfoCalculator.OBSTAGOON_INDEX_OFFSET) {
// return Galarian forms
return forms.get(1);
} else {
return getForm(otherForm.formName);
}
}
if (number == 553) { // #554 Darumaka
// check #555 Darmanitan
if (otherForm.number == 554 && otherForm.base.forms.get(0) == otherForm) {
// return Normal Form
return forms.get(0);
}
// check #555 Darmanitan Galarian
if (otherForm.number == 554 && otherForm.base.forms.get(2) == otherForm) {
// return Galarian Form
return forms.get(1);
} else {
return getForm(otherForm.formName);
}
}
if (number == 554) { // #555 Darmanitan
// check #554 Darumaka Normal
if (otherForm.number == 553 && otherForm.base.forms.get(0) == otherForm) {
// return Standard Form
return forms.get(0);
}
// check #554 Darumaka Galarian
if (otherForm.number == 553 && otherForm.base.forms.get(1) == otherForm) {
// return Galarian Standard Form
return forms.get(2);
} else {
return getForm(otherForm.formName);
}
}
if (number == pokeListSize
- PokeInfoCalculator.OBSTAGOON_INDEX_OFFSET) { // #862 OBSTAGOON index number in pokemons.xml
// check #263 ZIGZAGOON Galarian
if (otherForm.number == 262 && otherForm.base.forms.get(1) == otherForm) {
return forms.get(0);
}
// check #264 LINOONE Galarian
if (otherForm.number == 263 && otherForm.base.forms.get(1) == otherForm) {
return forms.get(0);
} else {
return getForm(otherForm.formName);
}
}
if (number == pokeListSize
- PokeInfoCalculator.PERRSERKER_INDEX_OFFSET) { // #863 Perrserker index number in pokemons.xml
// check #52 Meowth Galarian
if (otherForm.number == 51 && otherForm.base.forms.get(2) == otherForm) {
return forms.get(0);
} else {
return getForm(otherForm.formName);
}
}
if (number == pokeListSize
- PokeInfoCalculator.SIRFETCHD_INDEX_OFFSET) { // #865 Sirfetch'd index number in pokemons.xml
// check #83 Farfetch'd Galarian
if (otherForm.number == 82 && otherForm.base.forms.get(1) == otherForm) {
return forms.get(0);
} else {
return getForm(otherForm.formName);
}
}

if ((otherForm.base.forms.size() == 1 && forms.size() > 1)
|| (forms.size() == 1 && otherForm.base.forms.size() > 1 && otherForm.base.forms.get(0) == otherForm)) {
return forms.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ public PokeDist getPossiblePokemon(@NonNull ScanData scanData) {
}


//6. Check if the found pokemon should be alolan variant or not.
//6. Check if the found pokemon should be its variant(e.g. Alolan, Galarian, or its specific form) or not.
if (scanData != null && scanData.getPokemonType() != null) {
PokeDist alolanGuess = checkAlolanVariant(guess, scanData);
if (alolanGuess != null) {
guess = alolanGuess;
PokeDist variantGuess = checkVariant(guess, scanData);
if (variantGuess != null) {
guess = variantGuess;
}

}
Expand Down Expand Up @@ -289,7 +289,7 @@ private PokeDist createFormPokeDistances(PokeDist guess, ScanData scanData, Type
return null;
}

private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
private PokeDist checkVariant(PokeDist guess, ScanData scanData) {
try {
switch (guess.pokemon.number) {
case (102): // Exeggutor (dex 103)
Expand Down Expand Up @@ -323,8 +323,7 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
// check types including steel
return createFormPokeDist(guess, scanData, Type.STEEL, 1);
case (51): // Meowth
// check types including dark
return createFormPokeDist(guess, scanData, Type.DARK, 1);
return createFormPokeDistances(guess, scanData, Type.NORMAL, Type.DARK, Type.STEEL);
case (52): // Persian
// check types including dark
return createFormPokeDist(guess, scanData, Type.DARK, 1);
Expand All @@ -337,6 +336,8 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
case (75): // Golem
// check types including electric
return createFormPokeDist(guess, scanData, Type.ELECTRIC, 1);
case (82): // Farfetch'd
return createFormPokeDist(guess, scanData, Type.FIGHTING, 1);
case (87): // Grimer
// check types including dark
return createFormPokeDist(guess, scanData, Type.DARK, 1);
Expand All @@ -346,6 +347,12 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
case (104): // Marowak
// check types including fire
return createFormPokeDist(guess, scanData, Type.FIRE, 1);
case (109): // Weezing
return createFormPokeDist(guess, scanData, Type.FAIRY, 1);
case (262): // Zigzagoon
return createFormPokeDist(guess, scanData, Type.DARK, 1);
case (263): // Linoone
return createFormPokeDist(guess, scanData, Type.DARK, 1);
case (412): // Wormadam
return createFormPokeDistances(guess, scanData, Type.DARK, Type.GROUND, Type.STEEL);
case (478): // Rotom
Expand All @@ -357,10 +364,33 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
dist = new PokeDist(guess.pokemon.base.forms.get(0), 0);
}
return dist;
case (492): // Rotom
case (492): // Arceus
return createFormPokeDistances(guess, scanData, Type.NORMAL, Type.FIGHTING, Type.FLYING, Type.POISON,
Type.GROUND, Type.ROCK, Type.BUG, Type.GHOST, Type.STEEL, Type.FIRE, Type.WATER, Type.GRASS,
Type.ELECTRIC, Type.PSYCHIC, Type.ICE, Type.DRAGON, Type.DARK, Type.FAIRY);
case (553): // Darumaka
return createFormPokeDist(guess, scanData, Type.ICE, 1);
case (554): // Darmanitan
dist = createFormPokeDist(guess, scanData, Type.PSYCHIC, 1);
// check Zen Form
if (dist == null) {
// check Standard Form
if (createFormPokeDist(guess, scanData, Type.ICE, 1) == null) {
dist = createFormPokeDist(guess, scanData, Type.FIRE, 0);
}
// check Galarian Standard Form
else if (createFormPokeDist(guess, scanData, Type.FIRE, 1) == null) {
dist = createFormPokeDist(guess, scanData, Type.ICE, 2);
}
// Galarian Zen Form
else {
dist = createFormPokeDist(guess, scanData, Type.ICE, 3);
}
}
return dist;
case (617): // Stunfisk
return createFormPokeDist(guess, scanData, Type.STEEL, 1);

default:
// do nothing

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-de/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@
<item>Genesect</item>
<item>Meltan</item>
<item>Melmetal</item>
<item>Barrikadax</item>
<item>Mauzinger</item>
<item>Lauchzelot</item>
</string-array>
<string-array name="typeName">
<!-- 0 normal -->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@
<item>Genesect</item>
<item>Meltan</item>
<item>Melmetal</item>
<item>Ixon</item>
<item>Berserkatt</item>
<item>Palarticho</item>
</string-array>
<string-array name="typeName">
<!-- 0 normal -->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rTW/pokemons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -654,5 +654,8 @@
<item>蓋諾賽克特</item>
<item>美錄坦</item>
<item>美錄梅塔</item>
<item>堵攔熊</item>
<item>喵頭目</item>
<item>蔥遊兵</item>
</string-array>
</resources>
Loading

0 comments on commit 84cd2ca

Please sign in to comment.