mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-08-20 07:34:28 -05:00
Add King Salmonid guesses
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}`));
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
BIN
src/assets/img/king-cohozuna.png
Normal file
BIN
src/assets/img/king-cohozuna.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/assets/img/king-horrorboros.png
Normal file
BIN
src/assets/img/king-horrorboros.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -8,13 +8,15 @@
|
||||
</div>
|
||||
|
||||
<div class="hidden ss:block text-shadow text-white text-xl">
|
||||
<template v-if="time.isUpcoming(schedule.startTime)">
|
||||
<KingSalmonid :schedule="schedule" class="inline-block -mb-1 mr-2" />
|
||||
|
||||
<div class="inline-block" v-if="time.isUpcoming(schedule.startTime)">
|
||||
Shift opens
|
||||
{{ $t('time.in', { time: formatDurationHoursFromNow(schedule.startTime, true) }) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
</div>
|
||||
<div class="inline-block" v-else>
|
||||
{{ $t('time.remaining', { time: formatDurationHoursFromNow(schedule.endTime) }) }}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -26,6 +28,8 @@
|
||||
</div>
|
||||
|
||||
<div class="text-shadow text-zinc-300 ss:hidden">
|
||||
<KingSalmonid :schedule="schedule" class="inline-block align-middle" />
|
||||
|
||||
{{ $t('time.remaining', { time: formatDurationFromNow(schedule.endTime) }) }}
|
||||
</div>
|
||||
|
||||
@@ -52,6 +56,7 @@
|
||||
import { formatDurationFromNow, formatDurationHoursFromNow } from '@/common/time';
|
||||
import { useTimeStore } from '../../stores/time.mjs';
|
||||
import StageImage from '../StageImage.vue';
|
||||
import KingSalmonid from './KingSalmonid.vue';
|
||||
import SalmonRunWeapons from './SalmonRunWeapons.vue';
|
||||
|
||||
defineProps({
|
||||
|
||||
25
src/components/salmonrun/KingSalmonid.vue
Normal file
25
src/components/salmonrun/KingSalmonid.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<img
|
||||
src="@/assets/img/king-cohozuna.png"
|
||||
:class="size"
|
||||
:title="$t('salmonrun.kings.maybe-cohozuna')"
|
||||
v-if="schedule.__splatoon3ink_king_salmonid_guess === 'Cohozuna'"
|
||||
/>
|
||||
<img
|
||||
src="@/assets/img/king-horrorboros.png"
|
||||
:class="size"
|
||||
:title="$t('salmonrun.kings.maybe-horrorboros')"
|
||||
v-if="schedule.__splatoon3ink_king_salmonid_guess === 'Horrorboros'"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineProps({
|
||||
schedule: Object,
|
||||
size: {
|
||||
default: 'w-6',
|
||||
},
|
||||
})
|
||||
</script>
|
||||
@@ -21,6 +21,8 @@
|
||||
<StageImage class="w-1/5" imgClass="rounded" :stage="schedule.settings.coopStage" hide-label />
|
||||
|
||||
<div class="flex-1 text-sm text-zinc-300 text-shadow">
|
||||
<KingSalmonid :schedule="schedule" class="inline-block align-middle" size="w-5" />
|
||||
|
||||
{{ $t(`splatnet.stages.${schedule.settings.coopStage.id}.name`, schedule.settings.coopStage.name) }}
|
||||
|
||||
<span class="text-xs inline-block bg-splatoon-bigRun bg-opacity-80 text-white rounded px-2" v-if="schedule.isBigRun">
|
||||
@@ -38,6 +40,7 @@
|
||||
<script setup>
|
||||
import { formatDurationFromNow } from '@/common/time';
|
||||
import StageImage from '../StageImage.vue';
|
||||
import KingSalmonid from './KingSalmonid.vue';
|
||||
import SalmonRunWeapons from './SalmonRunWeapons.vue';
|
||||
|
||||
defineProps({
|
||||
|
||||
Reference in New Issue
Block a user