-
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 branch 'main' into lost-city-stager
- Loading branch information
Showing
11 changed files
with
229 additions
and
31 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 LivingGardenStager implements IStager { | ||
readonly environment: string = 'Living Garden'; | ||
|
||
/** | ||
* Read the bucket / vial state to determine the stage for Living & Twisted garden. | ||
*/ | ||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
const quest = userPre.quests.QuestLivingGarden; | ||
if (!quest) { | ||
throw new Error('QuestLivingGarden is undefined'); | ||
} | ||
|
||
const container_status = (quest.is_normal) ? quest.minigame.bucket_state : quest.minigame.vials_state; | ||
message.stage = (container_status === "dumped") ? "Pouring" : "Not Pouring"; | ||
} | ||
} |
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,18 @@ | ||
import {type User} from '@scripts/types/hg'; | ||
import {type IntakeMessage} from '@scripts/types/mhct'; | ||
import {type IStager} from '../stages.types'; | ||
|
||
export class MuridaeMarketStager implements IStager { | ||
readonly environment: string = 'Muridae Market'; | ||
|
||
/** | ||
* Report the Artisan Charm status. | ||
*/ | ||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
const charm = userPre.trinket_name; | ||
|
||
message.stage = charm === "Artisan Charm" | ||
? "Artisan" | ||
: "Not Artisan"; | ||
} | ||
} |
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 TwistedGardenStager implements IStager { | ||
readonly environment: string = 'Twisted Garden'; | ||
|
||
/** | ||
* Read the bucket / vial state to determine the stage for Living & Twisted garden. | ||
*/ | ||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
const quest = userPre.quests.QuestLivingGarden; | ||
if (!quest) { | ||
throw new Error('QuestLivingGarden is undefined'); | ||
} | ||
|
||
const container_status = (quest.is_normal) ? quest.minigame.bucket_state : quest.minigame.vials_state; | ||
message.stage = (container_status === "dumped") ? "Pouring" : "Not Pouring"; | ||
} | ||
} |
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,17 @@ | ||
export type QuestLivingGarden = LivingGardenState | TwistedGardenState | ||
|
||
interface LivingGardenState { | ||
is_normal: true | ||
minigame: { | ||
bucket_state: PourStatus | ||
} | ||
} | ||
|
||
interface TwistedGardenState { | ||
is_normal: false | ||
minigame: { | ||
vials_state: PourStatus | ||
} | ||
} | ||
|
||
type PourStatus = 'filling' | 'dumped'; |
112 changes: 112 additions & 0 deletions
112
tests/scripts/modules/stages/environments/livingGarden.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,112 @@ | ||
import {LivingGardenStager} from "@scripts/modules/stages/environments/livingGarden"; | ||
import {TwistedGardenStager} from "@scripts/modules/stages/environments/twistedGarden"; | ||
import {User} from "@scripts/types/hg"; | ||
import {IntakeMessage} from "@scripts/types/mhct"; | ||
|
||
describe('Living/Twisted Garden stages', () => { | ||
describe('Living', () => { | ||
it('should be for the "Living Garden" environment', () => { | ||
const stager = new LivingGardenStager(); | ||
expect(stager.environment).toBe('Living Garden'); | ||
}); | ||
|
||
it('should set stage to "Pouring" if bucket dumped', () => { | ||
const stager = new LivingGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: { | ||
is_normal: true, | ||
minigame: { | ||
bucket_state: 'dumped', | ||
}, | ||
}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('Pouring'); | ||
}); | ||
|
||
it('should set stage to "Not Pouring" if bucket not dumped', () => { | ||
const stager = new LivingGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: { | ||
is_normal: true, | ||
minigame: { | ||
bucket_state: 'filling', | ||
}, | ||
}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
}); | ||
|
||
it.each([undefined, null])('should throw if quest is %p', (quest) => { | ||
const stager = new LivingGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: quest}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
expect(() => stager.addStage(message, preUser, postUser, journal)) | ||
.toThrow('QuestLivingGarden is undefined'); | ||
}); | ||
}); | ||
|
||
describe('Twisted', () => { | ||
it('should be for the "Twisted Garden" environment', () => { | ||
const stager = new TwistedGardenStager(); | ||
expect(stager.environment).toBe('Twisted Garden'); | ||
}); | ||
|
||
it('should set stage to "Pouring" if bucket dumped', () => { | ||
const stager = new TwistedGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: { | ||
is_normal: false, | ||
minigame: { | ||
vials_state: 'dumped', | ||
}, | ||
}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('Pouring'); | ||
}); | ||
|
||
it('should set stage to "Not Pouring" if bucket not dumped', () => { | ||
const stager = new TwistedGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: { | ||
is_normal: false, | ||
minigame: { | ||
vials_state: 'filling', | ||
}, | ||
}}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
}); | ||
|
||
it.each([undefined, null])('should throw if quest is %p', (quest) => { | ||
const stager = new TwistedGardenStager(); | ||
|
||
const message = {} as IntakeMessage; | ||
const preUser = {quests: {QuestLivingGarden: quest}} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
expect(() => stager.addStage(message, preUser, postUser, journal)) | ||
.toThrow('QuestLivingGarden is undefined'); | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
tests/scripts/modules/stages/environments/muridaeMarket.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,34 @@ | ||
import {MuridaeMarketStager} from "@scripts/modules/stages/environments/muridaeMarket"; | ||
import {User} from "@scripts/types/hg"; | ||
import {IntakeMessage} from "@scripts/types/mhct"; | ||
|
||
describe('Muridae Market stages', () => { | ||
it('should be for the "Muridae Market" environment', () => { | ||
const stager = new MuridaeMarketStager(); | ||
expect(stager.environment).toBe('Muridae Market'); | ||
}); | ||
|
||
it('should set stage to "Artisan" if user has artisan charm equipped', () => { | ||
const stager = new MuridaeMarketStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = {trinket_name: 'Artisan Charm'} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('Artisan'); | ||
}); | ||
|
||
it('should set stage to "Not Artisan" if user does not has artisan charm equipped', () => { | ||
const stager = new MuridaeMarketStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = {trinket_name: 'Power Charm'} as User; | ||
const postUser = {} as User; | ||
const journal = {}; | ||
|
||
stager.addStage(message, preUser, postUser, journal); | ||
|
||
expect(message.stage).toBe('Not Artisan'); | ||
}); | ||
}); |