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

Commit 02b54d9

Browse files
committed
[C] improve detection Galarian and evolution line including Galarian forms.
1 parent 5c6d97a commit 02b54d9

File tree

3 files changed

+149
-15
lines changed

3 files changed

+149
-15
lines changed

app/src/main/java/com/kamron/pogoiv/scanlogic/PokeInfoCalculator.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public class PokeInfoCalculator {
2727
private List<Pokemon> formVariantPokemons;
2828
private String[] pokeNamesWithForm = {};
2929

30+
public static final int MELTAN_INDEX_OFFSET = 5;
31+
public static final int MELMETAL_INDEX_OFFSET = 4;
32+
public static final int OBSTAGOON_INDEX_OFFSET = 3;
33+
public static final int PERRSERKER_INDEX_OFFSET = 2;
34+
public static final int SIRFETCHD_INDEX_OFFSET = 1;
35+
3036
/**
3137
* Pokemons who's name appears as a type of candy.
3238
* For most, this is the basePokemon (ie: Pidgey candies)
@@ -177,13 +183,18 @@ private void populatePokemon(@NonNull GoIVSettings settings, @NonNull Resources
177183
int pokeListSize = names.length;
178184
ArrayList<Pokemon> formVariantPokemons = new ArrayList<>();
179185

180-
// quick hardcoded patch for Meltan and Melmetal
181-
// Tentatively use pokedex list size until supporting discontinuous pokedex numbers,
182-
// like as #493 Arceus, #808 Meltan, #809 Melmetal.
183-
candyNamesArray[pokeListSize - 2] = pokeListSize - 2;
184-
candyNamesArray[pokeListSize - 1] = pokeListSize - 2;
185-
devolution[pokeListSize - 1] = pokeListSize - 2;
186-
// END patch for Meltan and Melmetal
186+
// quick hardcoded patch for supporting discontinuous pokedex number pokemons followings
187+
// #808 Meltan
188+
// #809 Melmetal
189+
// #862 Obstagoon,
190+
// #863 Perrserker,
191+
// #865 Sirfetch'd
192+
// currently GoIV logic expects that pokedex numbers are continuous and less than pokeListSize.
193+
// so this patch shifts these to dummy indexes, with pokeListSize offset.
194+
candyNamesArray[pokeListSize - MELTAN_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
195+
candyNamesArray[pokeListSize - MELMETAL_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
196+
devolution[pokeListSize - MELMETAL_INDEX_OFFSET] = pokeListSize - MELTAN_INDEX_OFFSET;
197+
// END patch for supporting discontinuous pokedex number pokemons
187198

188199
for (int i = 0; i < pokeListSize; i++) {
189200
PokemonBase p = new PokemonBase(names[i], displayNames[i], i, devolution[i], evolutionCandyCost[i]);

app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonBase.java

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,99 @@ public Pokemon getForm(@NonNull Pokemon otherForm) {
7070
// In that case return the first one, which can be done in any case if this base has multiple forms (because
7171
// then we know that the other form is the single one). But if the other form has multiple forms it also needs
7272
// to verify that the other form is actually the first one.
73+
74+
final int pokeListSize = PokeInfoCalculator.getInstance().getPokedex().size();
75+
76+
if (number == 51) { // #52 Meowth
77+
// check #863 Perrserker with its index number in pokemons.xml
78+
if (otherForm.number == pokeListSize - PokeInfoCalculator.PERRSERKER_INDEX_OFFSET) {
79+
// return Galarian forms
80+
return forms.get(2);
81+
} else {
82+
return getForm(otherForm.formName);
83+
}
84+
}
85+
if (number == 52) { // #53 Persian
86+
return getForm(otherForm.formName);
87+
}
88+
if (number == 82) { // #83 Farfetch'd
89+
// check #865 Sirfetch'd with its index number in pokemons.xml
90+
if (otherForm.number == pokeListSize - PokeInfoCalculator.SIRFETCHD_INDEX_OFFSET) {
91+
// return Galarian forms
92+
return forms.get(1);
93+
} else {
94+
return getForm(otherForm.formName);
95+
}
96+
}
97+
if (number == 262 || number == 263) { // #263 ZIGZAGOON or #264 LINOONE
98+
// check #862 OBSTAGOON with its index number in pokemons.xml
99+
if (otherForm.number == pokeListSize - PokeInfoCalculator.OBSTAGOON_INDEX_OFFSET) {
100+
// return Galarian forms
101+
return forms.get(1);
102+
} else {
103+
return getForm(otherForm.formName);
104+
}
105+
}
106+
if (number == 553) { // #554 Darumaka
107+
// check #555 Darmanitan
108+
if (otherForm.number == 554 && otherForm.base.forms.get(0) == otherForm) {
109+
// return Normal Form
110+
return forms.get(0);
111+
}
112+
// check #555 Darmanitan Galarian
113+
if (otherForm.number == 554 && otherForm.base.forms.get(2) == otherForm) {
114+
// return Galarian Form
115+
return forms.get(1);
116+
} else {
117+
return getForm(otherForm.formName);
118+
}
119+
}
120+
if (number == 554) { // #555 Darmanitan
121+
// check #554 Darumaka Normal
122+
if (otherForm.number == 553 && otherForm.base.forms.get(0) == otherForm) {
123+
// return Standard Form
124+
return forms.get(0);
125+
}
126+
// check #554 Darumaka Galarian
127+
if (otherForm.number == 553 && otherForm.base.forms.get(1) == otherForm) {
128+
// return Galarian Standard Form
129+
return forms.get(2);
130+
} else {
131+
return getForm(otherForm.formName);
132+
}
133+
}
134+
if (number == pokeListSize
135+
- PokeInfoCalculator.OBSTAGOON_INDEX_OFFSET) { // #862 OBSTAGOON index number in pokemons.xml
136+
// check #263 ZIGZAGOON Galarian
137+
if (otherForm.number == 262 && otherForm.base.forms.get(1) == otherForm) {
138+
return forms.get(0);
139+
}
140+
// check #264 LINOONE Galarian
141+
if (otherForm.number == 263 && otherForm.base.forms.get(1) == otherForm) {
142+
return forms.get(0);
143+
} else {
144+
return getForm(otherForm.formName);
145+
}
146+
}
147+
if (number == pokeListSize
148+
- PokeInfoCalculator.PERRSERKER_INDEX_OFFSET) { // #863 Perrserker index number in pokemons.xml
149+
// check #52 Meowth Galarian
150+
if (otherForm.number == 51 && otherForm.base.forms.get(2) == otherForm) {
151+
return forms.get(0);
152+
} else {
153+
return getForm(otherForm.formName);
154+
}
155+
}
156+
if (number == pokeListSize
157+
- PokeInfoCalculator.SIRFETCHD_INDEX_OFFSET) { // #865 Sirfetch'd index number in pokemons.xml
158+
// check #83 Farfetch'd Galarian
159+
if (otherForm.number == 82 && otherForm.base.forms.get(1) == otherForm) {
160+
return forms.get(0);
161+
} else {
162+
return getForm(otherForm.formName);
163+
}
164+
}
165+
73166
if ((otherForm.base.forms.size() == 1 && forms.size() > 1)
74167
|| (forms.size() == 1 && otherForm.base.forms.size() > 1 && otherForm.base.forms.get(0) == otherForm)) {
75168
return forms.get(0);

app/src/main/java/com/kamron/pogoiv/scanlogic/PokemonNameCorrector.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ public PokeDist getPossiblePokemon(@NonNull ScanData scanData) {
181181
}
182182

183183

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

191191
}
@@ -289,7 +289,7 @@ private PokeDist createFormPokeDistances(PokeDist guess, ScanData scanData, Type
289289
return null;
290290
}
291291

292-
private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
292+
private PokeDist checkVariant(PokeDist guess, ScanData scanData) {
293293
try {
294294
switch (guess.pokemon.number) {
295295
case (102): // Exeggutor (dex 103)
@@ -323,8 +323,7 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
323323
// check types including steel
324324
return createFormPokeDist(guess, scanData, Type.STEEL, 1);
325325
case (51): // Meowth
326-
// check types including dark
327-
return createFormPokeDist(guess, scanData, Type.DARK, 1);
326+
return createFormPokeDistances(guess, scanData, Type.NORMAL, Type.DARK, Type.STEEL);
328327
case (52): // Persian
329328
// check types including dark
330329
return createFormPokeDist(guess, scanData, Type.DARK, 1);
@@ -337,6 +336,8 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
337336
case (75): // Golem
338337
// check types including electric
339338
return createFormPokeDist(guess, scanData, Type.ELECTRIC, 1);
339+
case (82): // Farfetch'd
340+
return createFormPokeDist(guess, scanData, Type.FIGHTING, 1);
340341
case (87): // Grimer
341342
// check types including dark
342343
return createFormPokeDist(guess, scanData, Type.DARK, 1);
@@ -346,6 +347,12 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
346347
case (104): // Marowak
347348
// check types including fire
348349
return createFormPokeDist(guess, scanData, Type.FIRE, 1);
350+
case (109): // Weezing
351+
return createFormPokeDist(guess, scanData, Type.FAIRY, 1);
352+
case (262): // Zigzagoon
353+
return createFormPokeDist(guess, scanData, Type.DARK, 1);
354+
case (263): // Linoone
355+
return createFormPokeDist(guess, scanData, Type.DARK, 1);
349356
case (412): // Wormadam
350357
return createFormPokeDistances(guess, scanData, Type.DARK, Type.GROUND, Type.STEEL);
351358
case (478): // Rotom
@@ -357,10 +364,33 @@ private PokeDist checkAlolanVariant(PokeDist guess, ScanData scanData) {
357364
dist = new PokeDist(guess.pokemon.base.forms.get(0), 0);
358365
}
359366
return dist;
360-
case (492): // Rotom
367+
case (492): // Arceus
361368
return createFormPokeDistances(guess, scanData, Type.NORMAL, Type.FIGHTING, Type.FLYING, Type.POISON,
362369
Type.GROUND, Type.ROCK, Type.BUG, Type.GHOST, Type.STEEL, Type.FIRE, Type.WATER, Type.GRASS,
363370
Type.ELECTRIC, Type.PSYCHIC, Type.ICE, Type.DRAGON, Type.DARK, Type.FAIRY);
371+
case (553): // Darumaka
372+
return createFormPokeDist(guess, scanData, Type.ICE, 1);
373+
case (554): // Darmanitan
374+
dist = createFormPokeDist(guess, scanData, Type.PSYCHIC, 1);
375+
// check Zen Form
376+
if (dist == null) {
377+
// check Standard Form
378+
if (createFormPokeDist(guess, scanData, Type.ICE, 1) == null) {
379+
dist = createFormPokeDist(guess, scanData, Type.FIRE, 0);
380+
}
381+
// check Galarian Standard Form
382+
else if (createFormPokeDist(guess, scanData, Type.FIRE, 1) == null) {
383+
dist = createFormPokeDist(guess, scanData, Type.ICE, 2);
384+
}
385+
// Galarian Zen Form
386+
else {
387+
dist = createFormPokeDist(guess, scanData, Type.ICE, 3);
388+
}
389+
}
390+
return dist;
391+
case (617): // Stunfisk
392+
return createFormPokeDist(guess, scanData, Type.STEEL, 1);
393+
364394
default:
365395
// do nothing
366396

0 commit comments

Comments
 (0)