diff --git a/app/data/updaters/StageScheduleUpdater.mjs b/app/data/updaters/StageScheduleUpdater.mjs index 4aac05e..4f4d415 100644 --- a/app/data/updaters/StageScheduleUpdater.mjs +++ b/app/data/updaters/StageScheduleUpdater.mjs @@ -1,4 +1,6 @@ +import ValueCache from "../../common/ValueCache.mjs"; import DataUpdater from "./DataUpdater.mjs"; +import _ from 'lodash'; export default class StageScheduleUpdater extends DataUpdater { @@ -40,7 +42,53 @@ export default class StageScheduleUpdater extends DataUpdater }, ]; - getData(locale) { - return this.splatnet(locale).getStageScheduleData(); + async getData(locale) { + let data = await this.splatnet(locale).getStageScheduleData(); + + await this.processKingSalmonids(data); + + return data; + } + + async processKingSalmonids(data) { + let cache = new ValueCache('kingsalmonids'); + let guesses = (await cache.getData()) || []; + + // Get all known schedule times + let schedules = _.sortBy([ + ..._.get(data, 'data.coopGroupingSchedule.regularSchedules.nodes'), + ..._.get(data, 'data.coopGroupingSchedule.bigRunSchedules.nodes'), + ..._.get(data, 'data.coopGroupingSchedule.teamContestSchedules.nodes'), + ], 'startTime'); + + // Remove cached times that don't exist anymore + guesses = guesses.filter(g => schedules.some(s => s.startTime === g.startTime)); + + // Process each schedule + let king = null; + for (let schedule of schedules) { + // Look for an existing guess + let guess = guesses.find(g => g.startTime === schedule.startTime); + + // Determine the king for the current rotation + king = guess ? guess.king : this.nextKingSalmonid(king); + + // If we didn't have it cached, add this guess to the cache + if (!guess) { + guesses.push({ startTime: schedule.startTime, king }); + } + + schedule.__splatoon3ink_king_salmonid_guess = king; + } + + await cache.setData(_.sortBy(guesses, 'startTime')); + } + + nextKingSalmonid(last = null) { + const sequence = ['Cohozuna', 'Horrorboros']; + + let index = sequence.indexOf(last) + 1; + + return sequence[index % sequence.length]; } } diff --git a/app/social/generators/SalmonRunStatus.mjs b/app/social/generators/SalmonRunStatus.mjs index 1a9e11b..25f8bb6 100644 --- a/app/social/generators/SalmonRunStatus.mjs +++ b/app/social/generators/SalmonRunStatus.mjs @@ -36,6 +36,12 @@ export default class SalmonRunStatus extends StatusGenerator lines.push(''); + let king = schedule.__splatoon3ink_king_salmonid_guess; + if (king) { + lines.push(`King Salmonid guess: ${king}`); + lines.push(''); + } + lines.push('Current weapons:'); lines.push(...schedule.settings.weapons.map(w => `– ${w.name}`)); diff --git a/src/assets/i18n/en-US.json b/src/assets/i18n/en-US.json index 8f1486a..f118039 100644 --- a/src/assets/i18n/en-US.json +++ b/src/assets/i18n/en-US.json @@ -35,7 +35,11 @@ "salmonrun": { "title": "Salmon Run", "weapons": "Supplied Weapons", - "bigrun": "Big Run" + "bigrun": "Big Run", + "kings": { + "maybe-cohozuna": "Maybe: Cohozuna?", + "maybe-horrorboros": "Maybe: Horrorboros?" + } }, "festival": { "title": "Splatfests", diff --git a/src/assets/img/king-cohozuna.png b/src/assets/img/king-cohozuna.png new file mode 100644 index 0000000..a972350 Binary files /dev/null and b/src/assets/img/king-cohozuna.png differ diff --git a/src/assets/img/king-horrorboros.png b/src/assets/img/king-horrorboros.png new file mode 100644 index 0000000..7643243 Binary files /dev/null and b/src/assets/img/king-horrorboros.png differ diff --git a/src/components/salmonrun/ExpandedSalmonRunRow.vue b/src/components/salmonrun/ExpandedSalmonRunRow.vue index f7881ed..8b33657 100644 --- a/src/components/salmonrun/ExpandedSalmonRunRow.vue +++ b/src/components/salmonrun/ExpandedSalmonRunRow.vue @@ -8,13 +8,15 @@
+
+