Skip to content

Commit

Permalink
Added EXTRA_DATES config option for automatic raid hour creator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjasoturi committed Aug 23, 2024
1 parent bd34bec commit b147c8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion core/tools/automate_raid_hour_creation/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
[2,"<-Gym id there and event note for 2nd gym here"],
[3,"<-Gym id there and event note for 3rd gym here"]
],
"URL": "https://www.yourhost.com/PokemonRaidBot/index.php?apikey=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
"URL": "https://www.yourhost.com/PokemonRaidBot/index.php?apikey=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
"EXTRA_DATES":[]
}
14 changes: 7 additions & 7 deletions core/tools/automate_raid_hour_creation/raid_hour_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$end->sub($interval);
$event_start = $start->format('Y-m-d H:i:s');
$event_end = $end->format('Y-m-d H:i:s');
if($event['type'] == 'raid-hour' && (($raids->rowcount() > 0 && !in_array($event_start, $raids_res)) || $raids->rowcount() === 0)) {
if($event['type'] == 'raid-hour' && $event_start > $now && (($raids->rowcount() > 0 && !in_array($event_start, $raids_res)) || $raids->rowcount() === 0)) {
$mon_name = trim(str_replace('Raid Hour','',str_replace('Forme','',$event['name'])));
$mon_split = explode(' ',$mon_name);
$part_count = count($mon_split);
Expand Down Expand Up @@ -71,15 +71,15 @@
$pokemon = $mon[0];
$pokemon_form = $mon[1];
}
$raid_to_create[] = [$pokemon, $pokemon_form,$event_start,$event_end];
$raid_to_create[] = [$pokemon, $pokemon_form,$event_start,$event_end, '5'];
$datesToCreate[] = $event_start;
}
}
if($now->format('w') == 3 && !in_array($now->format('Y-m-d H:i:s'), $raids_res) && !in_array($now->format('Y-m-d H:i:s'), $datesToCreate)) {
if(($now->format('w') == 3 || in_array($now->format('Y-m-d'), $config->EXTRA_DATES)) && !in_array($now->format('Y-m-d H:i:s'), $raids_res) && !in_array($now->format('Y-m-d H:i:s'), $datesToCreate)) {
$start_time = gmdate('Y-m-d H:i:s',mktime(18,0,0));
$end_time = gmdate('Y-m-d H:i:s',mktime(19,0,0));
$mon = get_current_bosses($start_time);
if($mon !== false) $raid_to_create[] = [$mon[0], $mon[1] ,$start_time, $end_time];
if($mon !== false) $raid_to_create[] = [$mon[0], $mon[1] ,$start_time, $end_time, $mon[2]];
}
}
try {
Expand All @@ -98,10 +98,10 @@
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
');

$now = gmdate('Y-m-d H:i:s');
foreach($raid_to_create as $raid_info) {
foreach($config->GYM_INFOS as $t) {
$now = gmdate('Y-m-d H:i:s');
$query->execute([$config->RAID_CREATOR_ID,$raid_info[0],$raid_info[1],$now,'5',$raid_info[2],$raid_info[3],$t[0],$config->RAID_HOUR_EVENT_ID,$t[1]]);
$query->execute([$config->RAID_CREATOR_ID,$raid_info[0],$raid_info[1],$now,$raid_info[4],$raid_info[2],$raid_info[3],$t[0],$config->RAID_HOUR_EVENT_ID,$t[1]]);
}
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ function get_current_bosses($spawn) {
}
}
if($pokemon === false) return false;
return [$pokemon,$pokemon_form];
return [$pokemon, $pokemon_form, $level];
}
function curl_get_contents($url)
{
Expand Down

0 comments on commit b147c8d

Please sign in to comment.