-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #517 from hymccord/bwrift-stager
Add Bristle Woods Rift stager
- Loading branch information
Showing
9 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/scripts/modules/stages/environments/bristleWoodsRift.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface QuestRiftBristleWoods { | ||
chamber_name: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/scripts/modules/stages/environments/bristleWoodsRift.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '', | ||
}; | ||
} | ||
}); |