Skip to content

Commit

Permalink
Merge pull request #517 from hymccord/bwrift-stager
Browse files Browse the repository at this point in the history
Add Bristle Woods Rift stager
  • Loading branch information
AardWolf authored Jan 19, 2024
2 parents 0aa007e + 78f10de commit 5d2af01
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,13 @@ module.exports = {
},
plugins: ['jest'],
},
{
files: [
'**/*.{test,spec}.ts',
],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
};
1 change: 0 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,6 @@ import * as detailingFuncs from './modules/details/legacy';

/** @type {Object <string, Function>} */
const location_stage_lookup = {
"Bristle Woods Rift": stagingFuncs.addBristleWoodsRiftStage,
"Burroughs Rift": stagingFuncs.addBurroughsRiftStage,
"Festive Comet": stagingFuncs.addFestiveCometStage,
"Frozen Vacant Lot": stagingFuncs.addFestiveCometStage,
Expand Down
23 changes: 23 additions & 0 deletions src/scripts/modules/stages/environments/bristleWoodsRift.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {type User} from '@scripts/types/hg';
import {type IntakeMessage} from '@scripts/types/mhct';
import {type IStager} from '../stages.types';

export class BristleWoodsRiftStager implements IStager {
readonly environment: string = 'Bristle Woods Rift';

/**
* Report the current chamber name.
*/
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void {
const quest = userPre.quests.QuestRiftBristleWoods;

if (!quest) {
throw new Error('QuestRiftBristleWoods is undefined');
}

message.stage = quest.chamber_name;
if (message.stage === "Rift Acolyte Tower") {
message.stage = "Entrance";
}
}
}
2 changes: 2 additions & 0 deletions src/scripts/modules/stages/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {type IStager} from './stages.types';
import {BalacksCoveStager} from './environments/balacksCove';
import {BountifulBeanstalkStager} from './environments/bountifulBeanstalk';
import {BristleWoodsRiftStager} from './environments/bristleWoodsRift';
import {ClawShotCityStager} from './environments/clawShotCity';
import {CursedCityStager} from './environments/cursedCity';
import {FieryWarpathStager} from './environments/fieryWarpath';
Expand All @@ -23,6 +24,7 @@ import {TwistedGardenStager} from './environments/twistedGarden';
const stageModules: IStager[] = [
new BalacksCoveStager(),
new BountifulBeanstalkStager(),
new BristleWoodsRiftStager(),
new ClawShotCityStager(),
new CursedCityStager(),
new FieryWarpathStager(),
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 @@ -423,21 +423,6 @@ export function addFortRoxStage(message, user, user_post, hunt) {
}
}

/**
* Report the current chamber name.
* @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 addBristleWoodsRiftStage(message, user, user_post, hunt) {
message.stage = user.quests.QuestRiftBristleWoods.chamber_name;
if (message.stage === "Rift Acolyte Tower") {
message.stage = "Entrance";
}
}


/**
* Report the state of corks and eruptions
* @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 @@ -58,7 +58,7 @@ export interface Quests {
QuestPollutionOutbreak?: unknown
QuestQuesoGeyser?: unknown
QuestRelicHunter?: unknown
QuestRiftBristleWoods?: unknown
QuestRiftBristleWoods?: quests.QuestRiftBristleWoods
QuestRiftBurroughs?: unknown
QuestRiftFuroma?: unknown
QuestRiftWhiskerWoods?: unknown
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/types/quests/bristleWoodsRift.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface QuestRiftBristleWoods {
chamber_name: string
}
1 change: 1 addition & 0 deletions src/scripts/types/quests/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from '@scripts/types/quests/balacksCove';
export * from '@scripts/types/quests/bountifulBeanstalk';
export * from '@scripts/types/quests/bristleWoodsRift';
export * from '@scripts/types/quests/clawShotCity';
export * from '@scripts/types/quests/floatingIslands';
export * from '@scripts/types/quests/forbiddenGrove';
Expand Down
67 changes: 67 additions & 0 deletions tests/scripts/modules/stages/environments/bristleWoodsRift.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {BristleWoodsRiftStager} from "@scripts/modules/stages/environments/bristleWoodsRift";
import {IStager} from "@scripts/modules/stages/stages.types";
import {User} from "@scripts/types/hg";
import {IntakeMessage} from "@scripts/types/mhct";
import {QuestRiftBristleWoods} from "@scripts/types/quests";

describe('Bristle Woods Rift stages', () => {
let stager: IStager;
let message: IntakeMessage;
let preUser: User;
let postUser: User;
const journal = {};

const ChamberNames = [
"Acolyte",
"Ancient Lab",
"Frozen Alcove",
"Furnace Room",
"Gearworks",
"Guard Barracks",
"Hidden Treasury",
"Ingress",
"Lucky Tower",
"Pursuer Mousoleum",
"Runic Laboratory",
"Rift Acolyte Tower", // Entrance
"Security",
"Timewarp",
];

beforeEach(() => {
stager = new BristleWoodsRiftStager();
message = {} as IntakeMessage;
preUser = {quests: {
QuestRiftBristleWoods: getDefaultQuest(),
}} as User;
postUser = {quests: {
QuestRiftBristleWoods: getDefaultQuest(),
}} as User;
});

it('should be for the Bristle Woods Rift environment', () => {
expect(stager.environment).toBe('Bristle Woods Rift');
});

it('should throw when QuestRiftBristleWoods is undefined', () => {
preUser.quests.QuestRiftBristleWoods = undefined;

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

it.each(ChamberNames)('should set stage name to chamber name', (chamberName) => {
preUser.quests.QuestRiftBristleWoods!.chamber_name = chamberName;

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

const expected = chamberName === "Rift Acolyte Tower" ? "Entrance" : chamberName;
expect(message.stage).toBe(expected);
});

function getDefaultQuest(): QuestRiftBristleWoods {
return {
chamber_name: '',
};
}
});

0 comments on commit 5d2af01

Please sign in to comment.