18
18
import POGOProtos .Enums .PokemonIdOuterClass .PokemonId ;
19
19
import POGOProtos .Networking .Responses .DownloadItemTemplatesResponseOuterClass .DownloadItemTemplatesResponse .ItemTemplate ;
20
20
import POGOProtos .Settings .Master .PokemonSettingsOuterClass .PokemonSettings ;
21
+ import com .pokegoapi .main .PokemonMeta ;
21
22
22
23
import java .util .ArrayList ;
23
24
import java .util .HashMap ;
@@ -29,6 +30,7 @@ public class Evolutions {
29
30
30
31
/**
31
32
* Initializes these evolutions from PokemonSettings
33
+ *
32
34
* @param templates the templates to initialize from
33
35
*/
34
36
public static void initialize (List <ItemTemplate > templates ) {
@@ -37,15 +39,21 @@ public static void initialize(List<ItemTemplate> templates) {
37
39
if (template .hasPokemonSettings ()) {
38
40
PokemonSettings settings = template .getPokemonSettings ();
39
41
PokemonId [] parents = {};
42
+ PokemonId pokemon = settings .getPokemonId ();
40
43
if (settings .getParentPokemonId () != null ) {
41
- parents = new PokemonId []{settings .getParentPokemonId ()};
44
+ PokemonSettings parentSettings = PokemonMeta .getPokemonSettings (settings .getParentPokemonId ());
45
+ List <PokemonId > parentEvolutions = parentSettings != null ? parentSettings .getEvolutionIdsList ()
46
+ : null ;
47
+ if (parentEvolutions != null && parentEvolutions .contains (pokemon )) {
48
+ parents = new PokemonId []{settings .getParentPokemonId ()};
49
+ }
42
50
}
43
- Evolution evolution = new Evolution (parents , settings . getPokemonId () );
44
- EVOLUTIONS .put (settings . getPokemonId () , evolution );
51
+ Evolution evolution = new Evolution (parents , pokemon );
52
+ EVOLUTIONS .put (pokemon , evolution );
45
53
for (PokemonId parent : parents ) {
46
54
Evolution parentEvolution = EVOLUTIONS .get (parent );
47
55
if (parentEvolution != null ) {
48
- parentEvolution .addEvolution (settings . getPokemonId () );
56
+ parentEvolution .addEvolution (pokemon );
49
57
}
50
58
}
51
59
}
0 commit comments