diff --git a/src/scripts/main.js b/src/scripts/main.js index 10a32bf5..5f72bbc2 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1207,6 +1207,7 @@ import * as detailingFuncs from './modules/details/legacy'; "Labyrinth": stagingFuncs.addLabyrinthStage, "Living Garden": stagingFuncs.addGardenStage, "Lost City": stagingFuncs.addLostCityStage, + "Mousoleum": stagingFuncs.addMousoleumStage, "Moussu Picchu": stagingFuncs.addMoussuPicchuStage, "Muridae Market": stagingFuncs.addMuridaeMarketStage, "Queso Geyser": stagingFuncs.addQuesoGeyserStage, diff --git a/src/scripts/modules/stages/environments/moussuPicchu.ts b/src/scripts/modules/stages/environments/moussuPicchu.ts new file mode 100644 index 00000000..5d06860b --- /dev/null +++ b/src/scripts/modules/stages/environments/moussuPicchu.ts @@ -0,0 +1,19 @@ +import {type User} from '@scripts/types/hg'; +import {type IntakeMessage} from '@scripts/types/mhct'; +import {type IStager} from '../stages.types'; + +export class MoussuPicchuStager implements IStager { + readonly environment: string = 'Moussu Picchu'; + + addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { + if (!userPre.quests.QuestMoussuPicchu) { + throw new Error('QuestMoussuPicchu is undefined'); + } + + const elements = userPre.quests.QuestMoussuPicchu.elements; + message.stage = { + rain: `Rain ${elements.rain.level}`, + wind: `Wind ${elements.wind.level}`, + }; + } +} diff --git a/src/scripts/modules/stages/index.ts b/src/scripts/modules/stages/index.ts index ab4ee68f..52108bb1 100644 --- a/src/scripts/modules/stages/index.ts +++ b/src/scripts/modules/stages/index.ts @@ -6,6 +6,7 @@ import {ForbiddenGroveStager} from './environments/forbiddenGrove'; import {FungalCavernStager} from './environments/fungalCavern'; import {HarbourStager} from './environments/harbour'; import {IceFortressStager} from './environments/iceFortress'; +import {MoussuPicchuStager} from './environments/moussuPicchu'; import {MousoleumStager} from './environments/mousoleum'; import {SuperBrieFactoryStager} from './environments/superBrieFactory'; @@ -17,6 +18,7 @@ const stageModules: IStager[] = [ new FungalCavernStager(), new HarbourStager(), new IceFortressStager(), + new MoussuPicchuStager(), new MousoleumStager(), new SuperBrieFactoryStager(), ]; diff --git a/src/scripts/modules/stages/legacy.js b/src/scripts/modules/stages/legacy.js index 1592b4be..c2edb019 100644 --- a/src/scripts/modules/stages/legacy.js +++ b/src/scripts/modules/stages/legacy.js @@ -28,21 +28,6 @@ export function addFestiveCometStage(message, user, user_post, hunt) { } } -/** - * MP stage reflects the weather categories - * @param {Object } message The message to be sent. - * @param {Object } user The user state object, when the hunt was invoked (pre-hunt). - * @param {Object } user_post The user state object, after the hunt. - * @param {Object } hunt The journal entry corresponding to the active hunt. - */ -export function addMoussuPicchuStage(message, user, user_post, hunt) { - const elements = user.quests.QuestMoussuPicchu.elements; - message.stage = { - rain: `Rain ${elements.rain.level}`, - wind: `Wind ${elements.wind.level}`, - }; -} - /** * WWR stage reflects the zones' rage categories * @param {Object } message The message to be sent. diff --git a/src/scripts/types/hg.ts b/src/scripts/types/hg.ts index 147d8319..907de10b 100644 --- a/src/scripts/types/hg.ts +++ b/src/scripts/types/hg.ts @@ -53,7 +53,7 @@ export interface Quests { QuestLivingGarden?: unknown QuestLostCity?: unknown QuestMousoleum?: quests.QuestMousoleum - QuestMoussuPicchu?: unknown + QuestMoussuPicchu?: quests.QuestMoussuPicchu QuestPollutionOutbreak?: unknown QuestQuesoGeyser?: unknown QuestRelicHunter?: unknown diff --git a/src/scripts/types/quests/index.ts b/src/scripts/types/quests/index.ts index 346029aa..10effe7e 100644 --- a/src/scripts/types/quests/index.ts +++ b/src/scripts/types/quests/index.ts @@ -6,6 +6,7 @@ export * from '@scripts/types/quests/harbour'; export * from '@scripts/types/quests/iceberg'; export * from '@scripts/types/quests/iceFortress'; export * from '@scripts/types/quests/mousoleum'; +export * from '@scripts/types/quests/moussuPicchu'; export * from '@scripts/types/quests/superBrieFactory'; export * from '@scripts/types/quests/tableOfContents'; export * from '@scripts/types/quests/springHunt'; diff --git a/src/scripts/types/quests/moussuPicchu.ts b/src/scripts/types/quests/moussuPicchu.ts new file mode 100644 index 00000000..e68e4f8a --- /dev/null +++ b/src/scripts/types/quests/moussuPicchu.ts @@ -0,0 +1,15 @@ +export interface QuestMoussuPicchu { + elements: { + wind: ElementIndicator + rain: ElementIndicator + storm: { + level: 'none' | ElementLevel + } + } +} + +interface ElementIndicator { + level: ElementLevel +} + +type ElementLevel = 'low' | 'medium' | 'high' | 'max'; diff --git a/tests/scripts/modules/stages/environments/moussuPicchu.spec.ts b/tests/scripts/modules/stages/environments/moussuPicchu.spec.ts new file mode 100644 index 00000000..d9281ecc --- /dev/null +++ b/tests/scripts/modules/stages/environments/moussuPicchu.spec.ts @@ -0,0 +1,48 @@ +import {MoussuPicchuStager} from "@scripts/modules/stages/environments/moussuPicchu"; +import {User} from "@scripts/types/hg"; +import {IntakeMessage} from "@scripts/types/mhct"; + +describe('MoussuPicchuStager', () => { + const ElementLevels = ['low', 'medium', 'high', 'max']; + + it('should be for the "Moussu Picchu" environment', () => { + const stager = new MoussuPicchuStager(); + expect(stager.environment).toBe('Moussu Picchu'); + }); + + describe.each(ElementLevels)('%p rain level', (rainLevel) => { + describe.each(ElementLevels)('%p wind level', (windLevel) => { + it(`should set stage wind and rain levels to ${rainLevel} and ${windLevel}`, () => { + const stager = new MoussuPicchuStager(); + + const message = {} as IntakeMessage; + const preUser = {quests: {QuestMoussuPicchu: { + elements: { + rain: {level: rainLevel}, + wind: {level: windLevel}, + }, + }}} as User; + const postUser = {} as User; + const journal = {}; + stager.addStage(message, preUser, postUser, journal); + + const expected = { + rain: `Rain ${rainLevel}`, + wind: `Wind ${windLevel}`, + }; + expect(message.stage).toStrictEqual(expected); + }); + }); + }); + + it.each([undefined, null])('should throw when QuestMoussuPicchu is %p', (quest) => { + const stager = new MoussuPicchuStager(); + + const message = {} as IntakeMessage; + const preUser = {quests: {QuestMoussuPicchu: quest}} as User; + const postUser = {} as User; + const journal = {}; + expect(() => stager.addStage(message, preUser, postUser, journal)) + .toThrow('QuestMoussuPicchu is undefined'); + }); +});