-
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.
- Loading branch information
Showing
8 changed files
with
47 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as hg from '@scripts/types/hg'; | ||
import * as mhct from '@scripts/types/mhct'; | ||
import {type IStager} from '../stages.types'; | ||
|
||
export class SandDunesStager implements IStager { | ||
readonly environment: string = 'Sand Dunes'; | ||
|
||
addStage(message: mhct.IntakeMessage, userPre: hg.User, userPost: hg.User, journal: unknown): void { | ||
const quest = userPre.quests.QuestSandDunes; | ||
if (!quest) { | ||
throw new Error('QuestSandDunes is undefined'); | ||
} | ||
|
||
message.stage = (quest.minigame.has_stampede) ? "Stampede" : "No Stampede"; | ||
} | ||
} |
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
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,6 @@ | ||
export interface QuestSandDunes { | ||
// this is for Sand Dunes only. Not currently needed for Sand Crypts. See QuestLivingGarden for example of both | ||
minigame: { | ||
has_stampede: boolean | ||
} | ||
} |
24 changes: 21 additions & 3 deletions
24
tests/scripts/modules/stages/environments/sandDunes.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 |
---|---|---|
@@ -1,31 +1,49 @@ | ||
import {addSandDunesStage} from "@scripts/modules/stages/legacy"; | ||
import {SandDunesStager} from "@scripts/modules/stages/environments/sandDunes"; | ||
import {User} from "@scripts/types/hg"; | ||
import {IntakeMessage} from "@scripts/types/mhct"; | ||
|
||
describe('Sand Dunes stages', () => { | ||
it('should be for the "Sand Dunes" environment', () => { | ||
const stager = new SandDunesStager(); | ||
expect(stager.environment).toBe('Sand Dunes'); | ||
}); | ||
|
||
it('should set stage to "Stampede" when there is a stampede', () => { | ||
const stager = new SandDunesStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestSandDunes: {minigame: { | ||
has_stampede: true, | ||
}}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
addSandDunesStage(message, preUser, postUser, journal); | ||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('Stampede'); | ||
}); | ||
|
||
it('should set stage to "No Stampede" when there is not a stampede', () => { | ||
const stager = new SandDunesStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestSandDunes: {minigame: { | ||
has_stampede: false, | ||
}}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
addSandDunesStage(message, preUser, postUser, journal); | ||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('No Stampede'); | ||
}); | ||
|
||
it.each([undefined, null])('should throw if quest is %p', (quest) => { | ||
const stager = new SandDunesStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestSandDunes: quest}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
expect(() => stager.addStage(message, preUser, postUser, journal)) | ||
.toThrow('QuestSandDunes is undefined'); | ||
}); | ||
}); |