Skip to content

Commit

Permalink
Add Lost/Cursed City stager
Browse files Browse the repository at this point in the history
  • Loading branch information
hymccord committed Nov 30, 2023
1 parent 583f3f2 commit 8871f58
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,6 @@ import * as detailingFuncs from './modules/details/legacy';
const location_stage_lookup = {
"Bristle Woods Rift": stagingFuncs.addBristleWoodsRiftStage,
"Burroughs Rift": stagingFuncs.addBurroughsRiftStage,
"Cursed City": stagingFuncs.addLostCityStage,
"Festive Comet": stagingFuncs.addFestiveCometStage,
"Frozen Vacant Lot": stagingFuncs.addFestiveCometStage,
"Fiery Warpath": stagingFuncs.addFieryWarpathStage,
Expand All @@ -1186,7 +1185,6 @@ import * as detailingFuncs from './modules/details/legacy';
"Gnawnian Express Station": stagingFuncs.addTrainStage,
"Iceberg": stagingFuncs.addIcebergStage,
"Living Garden": stagingFuncs.addGardenStage,
"Lost City": stagingFuncs.addLostCityStage,
"Muridae Market": stagingFuncs.addMuridaeMarketStage,
"Queso Geyser": stagingFuncs.addQuesoGeyserStage,
"Sand Dunes": stagingFuncs.addSandDunesStage,
Expand Down
20 changes: 20 additions & 0 deletions src/scripts/modules/stages/environments/cursedCity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {type User} from '@scripts/types/hg';
import {type IntakeMessage} from '@scripts/types/mhct';
import {type IStager} from '../stages.types';

export class CursedCityStager implements IStager {
readonly environment: string = 'Cursed City';

/**
* Indicate whether or not the Cursed / Corrupt mouse is present
*/
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void {
// TODO: Partially cursed, for Cursed City?
const quest = userPre.quests.QuestLostCity;
if (!quest) {
throw new Error('QuestLostCity is undefined');
}

message.stage = (quest.minigame.is_cursed) ? "Cursed" : "Not Cursed";
}
}
20 changes: 20 additions & 0 deletions src/scripts/modules/stages/environments/lostCity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {type User} from '@scripts/types/hg';
import {type IntakeMessage} from '@scripts/types/mhct';
import {type IStager} from '../stages.types';

export class LostCityStager implements IStager {
readonly environment: string = 'Lost City';

/**
* Indicate whether or not the Cursed / Corrupt mouse is present
*/
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void {
// TODO: Partially cursed, for Cursed City?
const quest = userPre.quests.QuestLostCity;
if (!quest) {
throw new Error('QuestLostCity is undefined');
}

message.stage = (quest.minigame.is_cursed) ? "Cursed" : "Not Cursed";
}
}
4 changes: 4 additions & 0 deletions src/scripts/modules/stages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import {type IStager} from './stages.types';
import {BalacksCoveStager} from './environments/balacksCove';
import {BountifulBeanstalkStager} from './environments/bountifulBeanstalk';
import {ClawShotCityStager} from './environments/clawShotCity';
import {CursedCityStager} from './environments/cursedCity';
import {FloatingIslandsStager} from './environments/floatingIslands';
import {ForbiddenGroveStager} from './environments/forbiddenGrove';
import {FungalCavernStager} from './environments/fungalCavern';
import {HarbourStager} from './environments/harbour';
import {IceFortressStager} from './environments/iceFortress';
import {LabyrinthStager} from './environments/labyrinth';
import {LostCityStager} from './environments/lostCity';
import {MoussuPicchuStager} from './environments/moussuPicchu';
import {MousoleumStager} from './environments/mousoleum';
import {SlushyShorelineStager} from './environments/slushyShoreline';
Expand All @@ -17,12 +19,14 @@ const stageModules: IStager[] = [
new BalacksCoveStager(),
new BountifulBeanstalkStager(),
new ClawShotCityStager(),
new CursedCityStager(),
new FloatingIslandsStager(),
new ForbiddenGroveStager(),
new FungalCavernStager(),
new HarbourStager(),
new IceFortressStager(),
new LabyrinthStager(),
new LostCityStager(),
new MoussuPicchuStager(),
new MousoleumStager(),
new SlushyShorelineStager(),
Expand Down
12 changes: 0 additions & 12 deletions src/scripts/modules/stages/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,6 @@ export function addSandDunesStage(message, user, user_post, hunt) {
message.stage = (user.quests.QuestSandDunes.minigame.has_stampede) ? "Stampede" : "No Stampede";
}

/**
* Indicate whether or not the Cursed / Corrupt mouse is present
* @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 addLostCityStage(message, user, user_post, hunt) {
// TODO: Partially cursed, for Cursed City?
message.stage = (user.quests.QuestLostCity.minigame.is_cursed) ? "Cursed" : "Not Cursed";
}

/**
* Report the current distance / obstacle.
* TODO: Stage / hunt details for first & second icewing hunting?
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 {
QuestIceFortress?: quests.QuestIceFortress;
QuestLabyrinth?: quests.QuestLabyrinth
QuestLivingGarden?: unknown
QuestLostCity?: unknown
QuestLostCity?: quests.QuestLostCity
QuestMousoleum?: quests.QuestMousoleum
QuestMoussuPicchu?: quests.QuestMoussuPicchu
QuestPollutionOutbreak?: 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 @@ -8,6 +8,7 @@ export * from '@scripts/types/quests/harbour';
export * from '@scripts/types/quests/iceberg';
export * from '@scripts/types/quests/iceFortress';
export * from '@scripts/types/quests/labyrinth';
export * from '@scripts/types/quests/lostCity';
export * from '@scripts/types/quests/mousoleum';
export * from '@scripts/types/quests/moussuPicchu';
export * from '@scripts/types/quests/superBrieFactory';
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/types/quests/lostCity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface QuestLostCity {
minigame: {
is_cursed: boolean
}
}
73 changes: 69 additions & 4 deletions tests/scripts/modules/stages/environments/lostCity.spec.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,96 @@
import {addLostCityStage} from "@scripts/modules/stages/legacy";
import {CursedCityStager} from "@scripts/modules/stages/environments/cursedCity";
import {LostCityStager} from "@scripts/modules/stages/environments/lostCity";
import {User} from "@scripts/types/hg";
import {IntakeMessage} from "@scripts/types/mhct";

describe('Lost/Cursed City stages', () => {
describe('Lost City stages', () => {
it('should be for the "" environment', () => {
const stager = new LostCityStager();
expect(stager.environment).toBe('Lost City');
});

it('should set stage to "Cursed" when user is cursed', () => {
const stager = new LostCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: {minigame: {
is_cursed: true,
}}}} as User;
const postUser = {} as User;
const journal = {};

addLostCityStage(message, preUser, postUser, journal);
stager.addStage(message, preUser, postUser, journal);

expect(message.stage).toBe('Cursed');
});

it('should set stage to "Cursed" when user is not cursed', () => {
const stager = new LostCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: {minigame: {
is_cursed: false,
}}}} as User;
const postUser = {} as User;
const journal = {};

addLostCityStage(message, preUser, postUser, journal);
stager.addStage(message, preUser, postUser, journal);

expect(message.stage).toBe('Not Cursed');
});

it.each([undefined, null])('should throw when QuestLostCity is %p', (state) => {
const stager = new LostCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: state}} as User;
const postUser = {} as User;
const journal = {};

expect(() => stager.addStage(message, preUser, postUser, journal))
.toThrow('QuestLostCity is undefined');
});
});

describe('Cursed City stages', () => {
it('should be for the "" environment', () => {
const stager = new CursedCityStager();
expect(stager.environment).toBe('Cursed City');
});

it('should set stage to "Cursed" when user is cursed', () => {
const stager = new CursedCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: {minigame: {
is_cursed: true,
}}}} as User;
const postUser = {} as User;
const journal = {};

stager.addStage(message, preUser, postUser, journal);

expect(message.stage).toBe('Cursed');
});

it('should set stage to "Cursed" when user is not cursed', () => {
const stager = new CursedCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: {minigame: {
is_cursed: false,
}}}} as User;
const postUser = {} as User;
const journal = {};

stager.addStage(message, preUser, postUser, journal);

expect(message.stage).toBe('Not Cursed');
});

it.each([undefined, null])('should throw when QuestLostCity is %p', (state) => {
const stager = new CursedCityStager();
const message = {} as IntakeMessage;
const preUser = {quests: {QuestLostCity: state}} as User;
const postUser = {} as User;
const journal = {};

expect(() => stager.addStage(message, preUser, postUser, journal))
.toThrow('QuestLostCity is undefined');
});
});

0 comments on commit 8871f58

Please sign in to comment.