Skip to content

Commit

Permalink
Added raid egg to pokemon keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjasoturi committed Jul 19, 2021
1 parent 0e2f1cd commit 475f0aa
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions logic/pokemon_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ function pokemon_keys($gym_id_plus_letter, $raid_level, $action, $event_id = fal
global $config;
// Init empty keys array.
$keys = [];

$time_now = dt2time(utcnow(), 'Y-m-d H:i');

$egg_id = '999' . $raid_level;

// Get pokemon from database
$query = '
$query = '
SELECT pokemon.id, pokemon.pokedex_id, pokemon.pokemon_form_id
FROM raid_bosses
LEFT JOIN pokemon
Expand All @@ -25,24 +28,19 @@ function pokemon_keys($gym_id_plus_letter, $raid_level, $action, $event_id = fal
DATE_SUB(\'' . $time_now . '\', INTERVAL '.$config->RAID_EGG_DURATION.' MINUTE) between date_start and date_end
OR DATE_ADD(\'' . $time_now . '\', INTERVAL '.$config->RAID_DURATION.' MINUTE) between date_start and date_end
)
ORDER BY pokemon.pokedex_id
UNION
SELECT id, pokedex_id, pokemon_form_id
FROM pokemon
WHERE pokedex_id = \'' . $egg_id . '\'
ORDER BY pokedex_id
';
$rs = my_query($query);
$egg_insert = true;
// Add key for each raid level
while ($pokemon = $rs->fetch()) {
$keys[] = array(
'text' => get_local_pokemon_name($pokemon['pokedex_id'], $pokemon['pokemon_form_id']),
'callback_data' => $gym_id_plus_letter . ':' . $action . ':' . (($event_id!==false) ? $event_id . ',' . $raid_level . ',' : '') . $pokemon['id']
);
if($pokemon['pokedex_id'] > 9990) $egg_insert = false;
}
if($egg_insert) {
$egg_id = '999' . $raid_level;
$keys[] = array(
'text' => get_local_pokemon_name($egg_id, 0),
'callback_data' => $gym_id_plus_letter . ':' . $action . ':' . (($event_id!==false) ? $event_id . ',' . $raid_level . ',' : '') . $egg_id
);
}

// Get the inline key array.
Expand Down

0 comments on commit 475f0aa

Please sign in to comment.