diff --git a/src/Splatoon/ISplatoonHasSchedules.php b/src/Splatoon/ISplatoonHasSchedules.php index 51eb6a6..3390cba 100644 --- a/src/Splatoon/ISplatoonHasSchedules.php +++ b/src/Splatoon/ISplatoonHasSchedules.php @@ -3,7 +3,7 @@ namespace Satori\Splatoon; interface ISplatoonHasSchedules extends ISplatoonGame { public function isValidScheduleFilter(string $filter): bool; - public function getScheduleFestival(): ?ISplatoonScheduleFestival; + public function getScheduleFestival(ISplatoonLocale $locale): ?ISplatoonScheduleFestival; public function getScheduleFilters(): array; public function getScheduleFilterAlias(string $filter): string; public function getScheduleModes(ISplatoonLocale $locale, array $filters): array; diff --git a/src/Splatoon/ISplatoonScheduleEntryVs.php b/src/Splatoon/ISplatoonScheduleEntryVs.php index 2d54fba..3e8fb06 100644 --- a/src/Splatoon/ISplatoonScheduleEntryVs.php +++ b/src/Splatoon/ISplatoonScheduleEntryVs.php @@ -2,5 +2,5 @@ namespace Satori\Splatoon; interface ISplatoonScheduleEntryVs extends ISplatoonScheduleEntry { - public function getRuleset(): ISplatoonVsRuleset; + public function getRuleset(): ?ISplatoonVsRuleset; } diff --git a/src/Splatoon/Splatoon2/Splatoon2Game.php b/src/Splatoon/Splatoon2/Splatoon2Game.php index 115c0ef..0ea6e88 100644 --- a/src/Splatoon/Splatoon2/Splatoon2Game.php +++ b/src/Splatoon/Splatoon2/Splatoon2Game.php @@ -199,7 +199,7 @@ class Splatoon2Game implements ISplatoonGame, ISplatoonHasFestivals, ISplatoonHa return $modes; } - public function getScheduleFestival(): ?ISplatoonScheduleFestival { + public function getScheduleFestival(ISplatoonLocale $locale): ?ISplatoonScheduleFestival { return null; } diff --git a/src/Splatoon/Splatoon2/Splatoon2ScheduleEntryVs.php b/src/Splatoon/Splatoon2/Splatoon2ScheduleEntryVs.php index b5f88ca..44e5d72 100644 --- a/src/Splatoon/Splatoon2/Splatoon2ScheduleEntryVs.php +++ b/src/Splatoon/Splatoon2/Splatoon2ScheduleEntryVs.php @@ -37,7 +37,7 @@ class Splatoon2ScheduleEntryVs implements ISplatoonScheduleEntryVs { return $stages; } - public function getRuleset(): ISplatoonVsRuleset { + public function getRuleset(): ?ISplatoonVsRuleset { return new Splatoon2VsRuleset($this->locale, $this->entryInfo['rule']); } } diff --git a/src/Splatoon/Splatoon3/Splatoon3Game.php b/src/Splatoon/Splatoon3/Splatoon3Game.php index 72130a7..c241479 100644 --- a/src/Splatoon/Splatoon3/Splatoon3Game.php +++ b/src/Splatoon/Splatoon3/Splatoon3Game.php @@ -238,12 +238,12 @@ class Splatoon3Game implements ISplatoonGame, ISplatoonHasFestivals, ISplatoonHa return $modes; } - public function getScheduleFestival(): ?ISplatoonScheduleFestival { + public function getScheduleFestival(ISplatoonLocale $locale): ?ISplatoonScheduleFestival { $raw = $this->getRawScheduleData(); if(!array_key_exists('data', $raw) || empty($raw['data']['currentFest'])) return null; - return new Splatoon3ScheduleFestival($this->locale, $raw['data']['currentFest']); + return new Splatoon3ScheduleFestival($locale, $raw['data']['currentFest']); } public function getSchedules(ISplatoonLocale $locale, array $filters): array { diff --git a/src/Splatoon/Splatoon3/Splatoon3ScheduleEntryVs.php b/src/Splatoon/Splatoon3/Splatoon3ScheduleEntryVs.php index 3b36ea0..4a74212 100644 --- a/src/Splatoon/Splatoon3/Splatoon3ScheduleEntryVs.php +++ b/src/Splatoon/Splatoon3/Splatoon3ScheduleEntryVs.php @@ -29,10 +29,14 @@ class Splatoon3ScheduleEntryVs implements ISplatoonScheduleEntryVs { } public function getStages(): array { - return XArray::select($this->matchSetting['vsStages'], fn($stage) => new Splatoon3Stage($this->locale, $stage)); + return array_key_exists('vsStages', $this->matchSetting) + ? XArray::select($this->matchSetting['vsStages'], fn($stage) => new Splatoon3Stage($this->locale, $stage)) + : []; } - public function getRuleset(): ISplatoonVsRuleset { - return new Splatoon3VsRuleset($this->locale, $this->matchSetting['vsRule']); + public function getRuleset(): ?ISplatoonVsRuleset { + return array_key_exists('vsRule', $this->matchSetting) + ? new Splatoon3VsRuleset($this->locale, $this->matchSetting['vsRule']) + : null; } } diff --git a/src/Splatoon/Splatoon3/Splatoon3ScheduleFestival.php b/src/Splatoon/Splatoon3/Splatoon3ScheduleFestival.php index 6ed3c17..623f9c1 100644 --- a/src/Splatoon/Splatoon3/Splatoon3ScheduleFestival.php +++ b/src/Splatoon/Splatoon3/Splatoon3ScheduleFestival.php @@ -19,15 +19,15 @@ class Splatoon3ScheduleFestival implements ISplatoonScheduleFestival { } public function getStartTime(): int { - return $this->festInfo['startTime']; + return strtotime($this->festInfo['startTime']); } public function getMidTermTime(): int { - return $this->festInfo['endTime']; + return strtotime($this->festInfo['endTime']); } public function getEndTime(): int { - return $this->festInfo['midtermTime']; + return strtotime($this->festInfo['midtermTime']); } public function getState(): string { diff --git a/src/Splatoon/SplatoonRoutes.php b/src/Splatoon/SplatoonRoutes.php index 810a026..11ef994 100644 --- a/src/Splatoon/SplatoonRoutes.php +++ b/src/Splatoon/SplatoonRoutes.php @@ -56,7 +56,7 @@ class SplatoonRoutes extends RouteHandler { // can't really test this while there's no splatfest going on, test it later $fest = null; - $festInfo = $gameInfo->getScheduleFestival(); + $festInfo = $gameInfo->getScheduleFestival($localeInfo); if($festInfo !== null) { $fest = new stdClass; $fest->id = $festInfo->getId(); @@ -128,10 +128,12 @@ class SplatoonRoutes extends RouteHandler { $schedule->variant = 'vs'; $rulesetInfo = $scheduleInfo->getRuleset(); - $schedule->ruleset = new stdClass; - $schedule->ruleset->id = $rulesetInfo->getId(); - $schedule->ruleset->name = $rulesetInfo->getName(); - $schedule->ruleset->short = $rulesetInfo->getShortName(); + if($rulesetInfo instanceof ISplatoonVsRuleset) { + $schedule->ruleset = new stdClass; + $schedule->ruleset->id = $rulesetInfo->getId(); + $schedule->ruleset->name = $rulesetInfo->getName(); + $schedule->ruleset->short = $rulesetInfo->getShortName(); + } if($scheduleInfo instanceof ISplatoonScheduleEntryVsLeague) { $schedule->flags[] = 'league';