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