Splatfest related fixes.
This commit is contained in:
parent
e77c8e5a8f
commit
8777631062
8 changed files with 23 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
namespace Satori\Splatoon;
|
||||
|
||||
interface ISplatoonScheduleEntryVs extends ISplatoonScheduleEntry {
|
||||
public function getRuleset(): ISplatoonVsRuleset;
|
||||
public function getRuleset(): ?ISplatoonVsRuleset;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class Splatoon2Game implements ISplatoonGame, ISplatoonHasFestivals, ISplatoonHa
|
|||
return $modes;
|
||||
}
|
||||
|
||||
public function getScheduleFestival(): ?ISplatoonScheduleFestival {
|
||||
public function getScheduleFestival(ISplatoonLocale $locale): ?ISplatoonScheduleFestival {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
Reference in a new issue