Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moussu Picchu Stager #470

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions src/scripts/modules/stages/environments/moussuPicchu.ts
Original file line number Diff line number Diff line change
@@ -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}`,
};
}
}
2 changes: 2 additions & 0 deletions src/scripts/modules/stages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -17,6 +18,7 @@ const stageModules: IStager[] = [
new FungalCavernStager(),
new HarbourStager(),
new IceFortressStager(),
new MoussuPicchuStager(),
new MousoleumStager(),
new SuperBrieFactoryStager(),
];
Expand Down
15 changes: 0 additions & 15 deletions src/scripts/modules/stages/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ export function addFestiveCometStage(message, user, user_post, hunt) {
}
}

/**
* MP stage reflects the weather categories
* @param {Object <string, any>} message The message to be sent.
* @param {Object <string, any>} user The user state object, when the hunt was invoked (pre-hunt).
* @param {Object <string, any>} user_post The user state object, after the hunt.
* @param {Object <string, any>} 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 <string, any>} message The message to be sent.
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/types/hg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/scripts/types/quests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
15 changes: 15 additions & 0 deletions src/scripts/types/quests/moussuPicchu.ts
Original file line number Diff line number Diff line change
@@ -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';
48 changes: 48 additions & 0 deletions tests/scripts/modules/stages/environments/moussuPicchu.spec.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});