Added support for League/Challenge battles in Splatoon 3 (also updated schedule time format which is incompatible with the old one so it will break everything lol).

This commit is contained in:
flash 2023-06-01 20:59:15 +00:00
parent db5dc0e507
commit d34bf5a4af

View file

@ -262,14 +262,17 @@ if($typeId === SP_TYPE_SCHED) { // SCHEDULE SHIT
$includeRanked = $includeSeries || $includeOpen; $includeRanked = $includeSeries || $includeOpen;
function splatoon3_schedule_gen($target, $node): void { function splatoon3_schedule_gen($target, $node): void {
$target->start = $node->startTime; $target->periods = [[
$target->end = $node->endTime; 'start' => $node->startTime,
'end' => $node->endTime,
]];
} }
function splatoon3_schedule_vs($target, $settings): void { function splatoon3_schedule_vs($target, $settings): void {
global $localeInfo; global $localeInfo;
$target->variant = 'vs'; $target->variant = 'vs';
$target->flags = [];
$target->ruleset = [ $target->ruleset = [
'id' => $settings->vsRule->rule, 'id' => $settings->vsRule->rule,
@ -286,6 +289,15 @@ if($typeId === SP_TYPE_SCHED) { // SCHEDULE SHIT
]; ];
} }
function splatoon3_schedule_periods($target, $periods): void {
$target->periods = [];
foreach($periods as $period)
$target->periods[] = [
'start' => $period->startTime,
'end' => $period->endTime,
];
}
if($includeRegular && !empty($data->regularSchedules->nodes)) { if($includeRegular && !empty($data->regularSchedules->nodes)) {
$schedule = []; $schedule = [];
@ -401,22 +413,38 @@ if($typeId === SP_TYPE_SCHED) { // SCHEDULE SHIT
} }
} }
if($includeLeague && !empty($data->leagueSchedules->nodes)) { if($includeLeague && !empty($data->eventSchedules->nodes)) {
$schedule = []; $schedule = [];
foreach($data->leagueSchedules->nodes as $node) { foreach($data->eventSchedules->nodes as $node) {
if(empty($node->leagueMatchSetting)) if(empty($node->leagueMatchSetting))
continue; continue;
$schedule[] = $item = new stdClass; $schedule[] = $item = new stdClass;
splatoon3_schedule_gen($item, $node); splatoon3_schedule_periods($item, $node->timePeriods);
splatoon3_schedule_vs($item, $node->leagueMatchSetting); splatoon3_schedule_vs($item, $node->leagueMatchSetting);
$item->flags[] = 'league';
if(!empty($node->leagueMatchSetting->leagueMatchEvent)) {
$event = $node->leagueMatchSetting->leagueMatchEvent;
$eventLocale = $localeInfo->events->{$event->id};
$item->league = [
'id' => $event->leagueMatchEventId,
'name' => $eventLocale->name ?? $event->name,
'desc' => $eventLocale->desc ?? $event->desc,
'rules' => [
'lines' => explode('<br />', $eventLocale->regulation ?? $event->regulation),
'url' => $event->regulationUrl,
],
];
}
} }
if(!empty($schedule)) { if(!empty($schedule)) {
$gameModes[] = [ $gameModes[] = [
'id' => 'league', 'id' => 'league',
'name' => 'League Battle', 'name' => 'Challenge Battle',
'colour' => 0xFFF02D7D, 'colour' => 0xFFF02D7D,
]; ];
@ -636,8 +664,10 @@ if($typeId === SP_TYPE_SCHED) { // SCHEDULE SHIT
$includeSalmon = $filterAll || in_array('coop', $filters); $includeSalmon = $filterAll || in_array('coop', $filters);
function splatoon2_schedule_gen($target, $node): void { function splatoon2_schedule_gen($target, $node): void {
$target->start = splatoon2_format_date($node->start_time); $target->periods = [[
$target->end = splatoon2_format_date($node->end_time); 'start' => splatoon2_format_date($node->start_time),
'end' => splatoon2_format_date($node->end_time),
]];
} }
function splatoon2_schedule_vs($target, $node): void { function splatoon2_schedule_vs($target, $node): void {