Skip to content

Commit 4a338d9

Browse files
committed
Another getdb fix
- Fixed duplicate weatherboost indicators - Simplified Pokémon type storing logic. The type is now stored as int instead of string, so the db column data type probably should be changed some day also.
1 parent 873ba7d commit 4a338d9

19 files changed

+16
-44
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mods/getdb.php

+16-44
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,6 @@ function parse_master_data($game_master_url) {
117117
// Collected from pogoprotos (hoping they won't change, so hard coding them here)
118118
$mega_names = array(-1 => 'mega', -2 => 'mega_x', -3 => 'mega_y', -4 => 'primal');
119119
$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-
];
140120
$weatherboost_table = array(
141121
1 => '4',
142122
2 => '5',
@@ -165,16 +145,12 @@ function parse_master_data($game_master_url) {
165145
if(!isset($row['stats']['attack']) || !isset($row['stats']['defense']) || !isset($row['stats']['stamina'])) {
166146
continue;
167147
}
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]];
178154
foreach($row['forms'] as $formData) {
179155
if(($formData['name'] == 'Unset' && count($row['forms']) > 1) || $formData['name'] == 'Shadow' || $formData['name'] == 'Purified') continue;
180156
if($formData['name'] == 'Normal') {
@@ -197,8 +173,8 @@ function parse_master_data($game_master_url) {
197173
'min_weather_cp' => $min_weather_cp,
198174
'max_weather_cp' => $max_weather_cp,
199175
'weather' => $weather,
200-
'type' => $type,
201-
'type2' => $type2,
176+
'type' => $pokemon_types[0],
177+
'type2' => $pokemon_types[1],
202178
];
203179
}
204180
if(!isset($row['tempEvolutions'])) continue;
@@ -207,16 +183,12 @@ function parse_master_data($game_master_url) {
207183
$form_id = -$tempData['tempEvoId'];
208184
$form_name = $mega_names[$form_id];
209185
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]];
220192
}
221193
[$min_cp, $max_cp, $min_weather_cp, $max_weather_cp] = calculate_cps($row['stats']);
222194
$pokemon_array[$pokemon_id][$form_name] = [
@@ -228,8 +200,8 @@ function parse_master_data($game_master_url) {
228200
'min_weather_cp' => $min_weather_cp,
229201
'max_weather_cp' => $max_weather_cp,
230202
'weather' => $weather,
231-
'type' => $type,
232-
'type2' => $type2,
203+
'type' => $pokemon_types[0],
204+
'type2' => $pokemon_types[1],
233205
];
234206
}
235207
}

0 commit comments

Comments
 (0)