@@ -117,26 +117,6 @@ function parse_master_data($game_master_url) {
117
117
// Collected from pogoprotos (hoping they won't change, so hard coding them here)
118
118
$ mega_names = array (-1 => 'mega ' , -2 => 'mega_x ' , -3 => 'mega_y ' , -4 => 'primal ' );
119
119
$ pokemon_array = [];
120
- $ typeArray = [
121
- 1 => 'normal ' ,
122
- 2 => 'fighting ' ,
123
- 3 => 'flying ' ,
124
- 4 => 'poison ' ,
125
- 5 => 'ground ' ,
126
- 6 => 'rock ' ,
127
- 7 => 'bug ' ,
128
- 8 => 'ghost ' ,
129
- 9 => 'steel ' ,
130
- 10 => 'fire ' ,
131
- 11 => 'water ' ,
132
- 12 => 'grass ' ,
133
- 13 => 'electric ' ,
134
- 14 => 'psychic ' ,
135
- 15 => 'ice ' ,
136
- 16 => 'dragon ' ,
137
- 17 => 'dark ' ,
138
- 18 => 'fairy ' ,
139
- ];
140
120
$ weatherboost_table = array (
141
121
1 => '4 ' ,
142
122
2 => '5 ' ,
@@ -165,16 +145,12 @@ function parse_master_data($game_master_url) {
165
145
if (!isset ($ row ['stats ' ]['attack ' ]) || !isset ($ row ['stats ' ]['defense ' ]) || !isset ($ row ['stats ' ]['stamina ' ])) {
166
146
continue ;
167
147
}
168
- $ type = $ type2 = '' ;
169
- foreach ($ row ['types ' ] as $ key => $ data ) {
170
- if ($ type == '' ) {
171
- $ type = $ typeArray [$ key ];
172
- $ weather = $ weatherboost_table [$ key ];
173
- continue ;
174
- }
175
- $ type2 = $ typeArray [$ key ];
176
- $ weather .= $ weatherboost_table [$ key ];
177
- }
148
+ $ pokemon_types = array_keys ($ row ['types ' ]);
149
+ $ weather = $ weatherboost_table [$ pokemon_types [0 ]];
150
+ if (!isset ($ pokemon_types [1 ]))
151
+ $ pokemon_types [1 ] = '' ;
152
+ elseif ($ weatherboost_table [$ pokemon_types [0 ]] != $ weatherboost_table [$ pokemon_types [1 ]])
153
+ $ weather .= $ weatherboost_table [$ pokemon_types [1 ]];
178
154
foreach ($ row ['forms ' ] as $ formData ) {
179
155
if (($ formData ['name ' ] == 'Unset ' && count ($ row ['forms ' ]) > 1 ) || $ formData ['name ' ] == 'Shadow ' || $ formData ['name ' ] == 'Purified ' ) continue ;
180
156
if ($ formData ['name ' ] == 'Normal ' ) {
@@ -197,8 +173,8 @@ function parse_master_data($game_master_url) {
197
173
'min_weather_cp ' => $ min_weather_cp ,
198
174
'max_weather_cp ' => $ max_weather_cp ,
199
175
'weather ' => $ weather ,
200
- 'type ' => $ type ,
201
- 'type2 ' => $ type2 ,
176
+ 'type ' => $ pokemon_types [ 0 ] ,
177
+ 'type2 ' => $ pokemon_types [ 1 ] ,
202
178
];
203
179
}
204
180
if (!isset ($ row ['tempEvolutions ' ])) continue ;
@@ -207,16 +183,12 @@ function parse_master_data($game_master_url) {
207
183
$ form_id = -$ tempData ['tempEvoId ' ];
208
184
$ form_name = $ mega_names [$ form_id ];
209
185
if (isset ($ tempData ['types ' ])) {
210
- $ type = '' ;
211
- foreach ($ tempData ['types ' ] as $ key => $ data ) {
212
- if ($ type == '' ) {
213
- $ type = $ typeArray [$ key ];
214
- $ weather = $ weatherboost_table [$ key ];
215
- continue ;
216
- }
217
- $ type2 = $ typeArray [$ key ];
218
- $ weather .= $ weatherboost_table [$ key ];
219
- }
186
+ $ pokemon_types = array_keys ($ tempData ['types ' ]);
187
+ $ weather = $ weatherboost_table [$ pokemon_types [0 ]];
188
+ if (!isset ($ pokemon_types [1 ]))
189
+ $ pokemon_types [1 ] = '' ;
190
+ elseif ($ weatherboost_table [$ pokemon_types [0 ]] != $ weatherboost_table [$ pokemon_types [1 ]])
191
+ $ weather .= $ weatherboost_table [$ pokemon_types [1 ]];
220
192
}
221
193
[$ min_cp , $ max_cp , $ min_weather_cp , $ max_weather_cp ] = calculate_cps ($ row ['stats ' ]);
222
194
$ pokemon_array [$ pokemon_id ][$ form_name ] = [
@@ -228,8 +200,8 @@ function parse_master_data($game_master_url) {
228
200
'min_weather_cp ' => $ min_weather_cp ,
229
201
'max_weather_cp ' => $ max_weather_cp ,
230
202
'weather ' => $ weather ,
231
- 'type ' => $ type ,
232
- 'type2 ' => $ type2 ,
203
+ 'type ' => $ pokemon_types [ 0 ] ,
204
+ 'type2 ' => $ pokemon_types [ 1 ] ,
233
205
];
234
206
}
235
207
}
0 commit comments