-
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 #501 from hymccord/lost-city-stager
Lost City stager
- Loading branch information
Showing
9 changed files
with
147 additions
and
15 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,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"; | ||
} | ||
} |
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,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"; | ||
} | ||
} |
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,5 @@ | ||
export interface QuestLostCity { | ||
minigame: { | ||
is_cursed: boolean | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
tests/scripts/modules/stages/environments/lostCity.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,96 @@ | ||
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 City stages', () => { | ||
it('should be for the "Lost City" 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 = {}; | ||
|
||
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 = {}; | ||
|
||
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 "Cursed City" 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'); | ||
}); | ||
}); |