From 260f70fa37ad45c6c50790e9bdb2ca3e106d680a Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Mon, 20 Feb 2023 21:07:17 -0800 Subject: [PATCH] Move Salmon Run mystery weapon detection to the data store --- app/social/generators/SalmonRunStatus.mjs | 12 ++---------- src/stores/schedules.mjs | 7 ++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/social/generators/SalmonRunStatus.mjs b/app/social/generators/SalmonRunStatus.mjs index 1099476..1a9e11b 100644 --- a/app/social/generators/SalmonRunStatus.mjs +++ b/app/social/generators/SalmonRunStatus.mjs @@ -19,14 +19,6 @@ export default class SalmonRunStatus extends StatusGenerator return Date.parse(schedule.startTime); } - _isGrizzcoMystery(schedule) { - return schedule.settings.weapons.some(w => w.__splatoon3ink_id === 'edcfecb7e8acd1a7') - } - - _isMystery(schedule) { - return schedule.settings.weapons.some(w => w.name === 'Random'); - } - async _getStatus() { let schedule = await this.getActiveSchedule(); @@ -34,9 +26,9 @@ export default class SalmonRunStatus extends StatusGenerator let mode = schedule.isBigRun ? 'BIG RUN' : 'Salmon Run'; - if (this._isGrizzcoMystery(schedule)) { + if (schedule.isGrizzcoMystery) { lines.push(`${mode} is now open on ${schedule.settings.coopStage.name} with GRIZZCO MYSTERY WEAPONS! #salmonrun #splatoon3`); - } else if (this._isMystery(schedule)) { + } else if (schedule.isMystery) { lines.push(`${mode} is now open on ${schedule.settings.coopStage.name} with MYSTERY WEAPONS! #salmonrun #splatoon3`); } else { lines.push(`${mode} is now open on ${schedule.settings.coopStage.name}! #salmonrun #splatoon3`); diff --git a/src/stores/schedules.mjs b/src/stores/schedules.mjs index 6be17c4..c3e9a7e 100644 --- a/src/stores/schedules.mjs +++ b/src/stores/schedules.mjs @@ -84,7 +84,12 @@ export const useSalmonRunSchedulesStore = defineScheduleStore('salmonRun', { let nodes = [] .concat(data?.coopGroupingSchedule.regularSchedules.nodes.map(n => ({ ...n, isBigRun: false }))) .concat(data?.coopGroupingSchedule.bigRunSchedules.nodes.map(n => ({ ...n, isBigRun: true }))) - .filter(n => n); + .filter(n => n) + .map(n => ({ + ...n, + isMystery: n.setting.weapons.some(w => w.name === 'Random'), + isGrizzcoMystery: n.setting.weapons.some(w => w.__splatoon3ink_id === 'edcfecb7e8acd1a7'), + })); return sortBy(nodes, 'startTime'); },