| @@ 263-297 (lines=35) @@ | ||
| 260 | return $array; |
|
| 261 | } |
|
| 262 | ||
| 263 | public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) |
|
| 264 | { |
|
| 265 | $inmap_pkms_filter = ''; |
|
| 266 | $where = ' WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = '.$pokemon_id; |
|
| 267 | ||
| 268 | $reqTestIv = 'SELECT MAX(atk_iv) AS iv FROM sightings '.$where; |
|
| 269 | $resultTestIv = $this->mysqli->query($reqTestIv); |
|
| 270 | $testIv = $resultTestIv->fetch_object(); |
|
| 271 | if (!is_null($inmap_pokemons) && ('' != $inmap_pokemons)) { |
|
| 272 | foreach ($inmap_pokemons as $inmap) { |
|
| 273 | $inmap_pkms_filter .= "'".$inmap."',"; |
|
| 274 | } |
|
| 275 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ','); |
|
| 276 | $where .= ' AND encounter_id NOT IN ('.$inmap_pkms_filter.') '; |
|
| 277 | } |
|
| 278 | if (null != $testIv->iv && !is_null($ivMin) && ('' != $ivMin)) { |
|
| 279 | $where .= ' AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= ('.$ivMin.') '; |
|
| 280 | } |
|
| 281 | if (null != $testIv->iv && !is_null($ivMax) && ('' != $ivMax)) { |
|
| 282 | $where .= ' AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= ('.$ivMax.') '; |
|
| 283 | } |
|
| 284 | $req = 'SELECT pokemon_id, lat AS latitude, lon AS longitude, |
|
| 285 | FROM_UNIXTIME(expire_timestamp) AS disappear_time, |
|
| 286 | FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, |
|
| 287 | atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina, |
|
| 288 | move_1, move_2 |
|
| 289 | FROM sightings '.$where.' |
|
| 290 | LIMIT 5000'; |
|
| 291 | $result = $this->mysqli->query($req); |
|
| 292 | $spawns = array(); |
|
| 293 | while ($data = $result->fetch_object()) { |
|
| 294 | $spawns[] = $data; |
|
| 295 | } |
|
| 296 | ||
| 297 | return $spawns; |
|
| 298 | } |
|
| 299 | ||
| 300 | public function getPokemonSliderMinMax() |
|
| @@ 266-298 (lines=33) @@ | ||
| 263 | return $array; |
|
| 264 | } |
|
| 265 | ||
| 266 | public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) |
|
| 267 | { |
|
| 268 | $inmap_pkms_filter = ''; |
|
| 269 | $where = ' WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = '.$pokemon_id; |
|
| 270 | $reqTestIv = 'SELECT MAX(individual_attack) AS iv FROM pokemon '.$where; |
|
| 271 | $resultTestIv = $this->mysqli->query($reqTestIv); |
|
| 272 | $testIv = $resultTestIv->fetch_object(); |
|
| 273 | if (!is_null($inmap_pokemons) && ('' != $inmap_pokemons)) { |
|
| 274 | foreach ($inmap_pokemons as $inmap) { |
|
| 275 | $inmap_pkms_filter .= "'".$inmap."',"; |
|
| 276 | } |
|
| 277 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ','); |
|
| 278 | $where .= ' AND encounter_id NOT IN ('.$inmap_pkms_filter.') '; |
|
| 279 | } |
|
| 280 | if (null != $testIv->iv && !is_null($ivMin) && ('' != $ivMin)) { |
|
| 281 | $where .= ' AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= ('.$ivMin.') '; |
|
| 282 | } |
|
| 283 | if (null != $testIv->iv && !is_null($ivMax) && ('' != $ivMax)) { |
|
| 284 | $where .= ' AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <= ('.$ivMax.') '; |
|
| 285 | } |
|
| 286 | $req = "SELECT pokemon_id, encounter_id, latitude, longitude, disappear_time, |
|
| 287 | CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."') AS disappear_time_real, |
|
| 288 | individual_attack, individual_defense, individual_stamina, move_1, move_2 |
|
| 289 | FROM pokemon ".$where.' |
|
| 290 | LIMIT 5000'; |
|
| 291 | $result = $this->mysqli->query($req); |
|
| 292 | $spawns = array(); |
|
| 293 | while ($data = $result->fetch_object()) { |
|
| 294 | $spawns[] = $data; |
|
| 295 | } |
|
| 296 | ||
| 297 | return $spawns; |
|
| 298 | } |
|
| 299 | ||
| 300 | public function getPokemonSliderMinMax() |
|
| 301 | { |
|