Skip to content

Commit

Permalink
Merge pull request #467 from m-h-c-t/mousoleum-stager
Browse files Browse the repository at this point in the history
Mousoleum Stager
  • Loading branch information
AardWolf authored Oct 10, 2023
2 parents d8abd6d + 3b24d96 commit 7c25656
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@ 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
16 changes: 16 additions & 0 deletions src/scripts/modules/stages/environments/mousoleum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {type User} from '@scripts/types/hg';
import {type IntakeMessage} from '@scripts/types/mhct';
import {type IStager} from '../stages.types';

export class MousoleumStager implements IStager {
readonly environment: string = 'Mousoleum';

/* Add the "wall state" for Mousoleum hunts */
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void {
if (!userPre.quests.QuestMousoleum) {
throw new Error('QuestMousoleum is undefined');
}

message.stage = (userPre.quests.QuestMousoleum.has_wall) ? "Has Wall" : "No Wall";
}
}
2 changes: 2 additions & 0 deletions src/scripts/modules/stages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {FloatingIslandsStager} from './environments/floatingIslands';
import {ForbiddenGroveStager} from './environments/forbiddenGrove';
import {FungalCavernStager} from './environments/fungalCavern';
import {IceFortressStager} from './environments/iceFortress';
import {MousoleumStager} from './environments/mousoleum';
import {SuperBrieFactoryStager} from './environments/superBrieFactory';

const stageModules: IStager[] = [
Expand All @@ -12,6 +13,7 @@ const stageModules: IStager[] = [
new ForbiddenGroveStager(),
new FungalCavernStager(),
new IceFortressStager(),
new MousoleumStager(),
new SuperBrieFactoryStager(),
];

Expand Down
11 changes: 0 additions & 11 deletions src/scripts/modules/stages/legacy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/**
* Add the "wall state" for Mousoleum hunts.
* @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 addMousoleumStage(message, user, user_post, hunt) {
message.stage = (user.quests.QuestMousoleum.has_wall) ? "Has Wall" : "No Wall";
}

/**
* Separate hunts with certain mice available from those without.
* @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 @@ -52,7 +52,7 @@ export interface Quests {
QuestLabyrinth?: unknown
QuestLivingGarden?: unknown
QuestLostCity?: unknown
QuestMousoleum?: unknown
QuestMousoleum?: quests.QuestMousoleum
QuestMoussuPicchu?: unknown
QuestPollutionOutbreak?: unknown
QuestQuesoGeyser?: 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 @@ -4,6 +4,7 @@ export * from '@scripts/types/quests/floatingIslands';
export * from '@scripts/types/quests/forbiddenGrove';
export * from '@scripts/types/quests/iceberg';
export * from '@scripts/types/quests/iceFortress';
export * from '@scripts/types/quests/mousoleum';
export * from '@scripts/types/quests/superBrieFactory';
export * from '@scripts/types/quests/tableOfContents';
export * from '@scripts/types/quests/springHunt';
3 changes: 3 additions & 0 deletions src/scripts/types/quests/mousoleum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface QuestMousoleum {
has_wall: boolean;
}
39 changes: 39 additions & 0 deletions tests/scripts/modules/stages/environments/mousoleum.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {MousoleumStager} from '@scripts/modules/stages/environments/mousoleum';
import {User} from '@scripts/types/hg';
import {IntakeMessage} from '@scripts/types/mhct';

describe('MousoleumStager', () => {
it('sets stage to "Has Wall" if user has Mousoleum wall', () => {
const stager = new MousoleumStager();

const message = {stage: null} as IntakeMessage;
const userPre = {quests: {QuestMousoleum: {has_wall: true}}} as User;
const userPost = {} as User;
const journal = {};
stager.addStage(message, userPre, userPost, journal);
expect(message.stage).toBe('Has Wall');
});

it('sets stage to "No Wall" if user does not have Mousoleum wall', () => {
const stager = new MousoleumStager();

const message = {stage: null} as IntakeMessage;
const userPre = {quests: {QuestMousoleum: {has_wall: false}}} as User;
const userPost = {} as User;
const journal = {};
stager.addStage(message, userPre, userPost, journal);
expect(message.stage).toBe('No Wall');
});

it('throws an error if QuestMousoleum is undefined', () => {
const stager = new MousoleumStager();

const message = {stage: null} as IntakeMessage;
const userPre = {quests: {}} as User;
const userPost = {} as User;
const journal = {};
expect(() => {
stager.addStage(message, userPre, userPost, journal);
}).toThrowError('QuestMousoleum is undefined');
});
});

0 comments on commit 7c25656

Please sign in to comment.