-
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 #309 from hymccord/sbfactory-stager
SB+ Factory Stager
- Loading branch information
Showing
9 changed files
with
185 additions
and
29 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
2 changes: 1 addition & 1 deletion
2
src/scripts/modules/stages/iceFortress.ts → ...odules/stages/environments/iceFortress.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
31 changes: 31 additions & 0 deletions
31
src/scripts/modules/stages/environments/superBrieFactory.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,31 @@ | ||
import type { IStager } from '../stages.types'; | ||
import type { User } from '@scripts/types/hg'; | ||
import type { RoomType } from '@scripts/types/quests'; | ||
|
||
export class SuperBrieFactoryStager implements IStager { | ||
readonly environment: string = 'SUPER|brie+ Factory'; | ||
|
||
readonly roomTypeToStage: Record<RoomType, string> = { | ||
"pumping_room": "Pump Room", | ||
"mixing_room": "Mixing Room", | ||
"break_room": "Break Room", | ||
"quality_assurance_room": "QA Room", | ||
} | ||
|
||
addStage(message: any, userPre: User, userPost: User, journal: any): void { | ||
const quest = userPre.quests.QuestSuperBrieFactory; | ||
|
||
if (quest == null) { | ||
throw new Error('User is in SB+ factory but quest wasn\'t found.'); | ||
} | ||
|
||
if (message.mouse === "Vincent, The Magnificent" || quest.factory_atts.boss_warning === true) { | ||
message.stage = "Boss"; | ||
} else { | ||
message.stage = this.roomTypeToStage[quest.factory_atts.current_room]; | ||
if (!message.stage || !/Coggy Colby/.test(userPre.bait_name) ) { | ||
message.stage = "Any Room"; | ||
} | ||
} | ||
} | ||
} |
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,8 +1,10 @@ | ||
import { type IStager } from './stages.types'; | ||
import { IceFortressStager } from './iceFortress'; | ||
import { IceFortressStager } from './environments/iceFortress'; | ||
import { SuperBrieFactoryStager } from './environments/superBrieFactory'; | ||
|
||
const stageModules: IStager[] = [ | ||
new IceFortressStager() | ||
new IceFortressStager(), | ||
new SuperBrieFactoryStager(), | ||
]; | ||
|
||
export { stageModules } |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from '@scripts/types/quests/iceFortress'; | ||
export * from '@scripts/types/quests/superBrieFactory'; | ||
export * from '@scripts/types/quests/tableOfContents'; |
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,15 @@ | ||
|
||
export interface QuestSuperBrieFactory { | ||
factory_atts: FactoryAtts; | ||
} | ||
|
||
interface FactoryAtts { | ||
current_room: RoomType; | ||
boss_warning: boolean | null; | ||
} | ||
|
||
export type RoomType = | ||
| "mixing_room" | ||
| "break_room" | ||
| "pumping_room" | ||
| "quality_assurance_room"; |
2 changes: 1 addition & 1 deletion
2
...cripts/modules/stages/iceFortress.spec.ts → ...s/stages/environments/iceFortress.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
131 changes: 131 additions & 0 deletions
131
tests/scripts/modules/stages/environments/superBrieFactory.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,131 @@ | ||
import { SuperBrieFactoryStager } from "@scripts/modules/stages/environments/superBrieFactory"; | ||
import type { User } from "@scripts/types/hg"; | ||
import type { IntakeMessage } from "@scripts/types/mhct"; | ||
import type { QuestSuperBrieFactory } from "@scripts/types/quests"; | ||
|
||
describe("SuperBrieFactoryStager", () => { | ||
const defaultJournal = {}; | ||
const defaultQuest: QuestSuperBrieFactory = { | ||
factory_atts: { | ||
current_room: "pumping_room", | ||
boss_warning: null, | ||
} | ||
}; | ||
const defaultUser = { | ||
quests: { | ||
QuestSuperBrieFactory: defaultQuest, | ||
}, | ||
} as User; | ||
|
||
it("is for the SUPER|brie+ Factory environment", () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
|
||
expect(stager.environment).toBe("SUPER|brie+ Factory"); | ||
}); | ||
|
||
it("throws when the quest is undefined", () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
const user = changeFactoryQuest(defaultUser, undefined!); | ||
|
||
expect(() => { | ||
stager.addStage({} as any, user, user, defaultJournal); | ||
}).toThrowError("User is in SB+ factory but quest wasn't found."); | ||
}); | ||
|
||
describe("boss", () => { | ||
it("is Boss stage when pre mouse is Vincent", () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
const message = { | ||
mouse: "Vincent, The Magnificent", | ||
} as IntakeMessage; | ||
const preUser = changeFactoryQuest(defaultUser, defaultQuest); | ||
|
||
stager.addStage(message, preUser, defaultUser, defaultJournal); | ||
|
||
expect(message.stage).toBe("Boss"); | ||
}); | ||
|
||
it("is Boss stage when there is boss_warning", () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = { | ||
...defaultUser, | ||
quests: { | ||
QuestSuperBrieFactory: { | ||
factory_atts: { boss_warning: true }, | ||
}, | ||
}, | ||
} as User; | ||
|
||
stager.addStage(message, preUser, defaultUser, defaultJournal); | ||
|
||
expect(message.stage).toBe("Boss"); | ||
}); | ||
}); | ||
|
||
describe('rooms', () => { | ||
it.each([ | ||
{ room: "pumping_room", expected: "Pump Room" }, | ||
{ room: "mixing_room", expected: "Mixing Room" }, | ||
{ room: "break_room", expected: "Break Room" }, | ||
{ room: "quality_assurance_room", expected: "QA Room" }, | ||
])('sets room with Coggy Colby', ({room, expected}) => { | ||
|
||
const stager = new SuperBrieFactoryStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = { | ||
...defaultUser, | ||
bait_name: 'Coggy Colby Cheese', | ||
quests: { | ||
QuestSuperBrieFactory: { | ||
factory_atts: { current_room: room }, | ||
}, | ||
}, | ||
} as User; | ||
|
||
stager.addStage(message, preUser, defaultUser, defaultJournal); | ||
expect(message.stage).toBe(expected); | ||
}); | ||
|
||
it('is any room with non-coggy colby', () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
const message = {} as IntakeMessage; | ||
const preUser = { | ||
...defaultUser, | ||
bait_name: 'Gouda Cheese', | ||
quests: { | ||
QuestSuperBrieFactory: { | ||
factory_atts: { current_room: 'pumping_room' }, | ||
}, | ||
}, | ||
} as User; | ||
|
||
stager.addStage(message, preUser, defaultUser, defaultJournal); | ||
expect(message.stage).toBe('Any Room'); | ||
}) | ||
}); | ||
|
||
describe('other rooms', () => { | ||
it('defaults to Any Room for unsupported room type', () => { | ||
const stager = new SuperBrieFactoryStager(); | ||
const message = {} as IntakeMessage; | ||
const user = { | ||
...defaultUser, | ||
quests: { | ||
QuestSuperBrieFactory: { | ||
factory_atts: { current_room: 'secret_room' } | ||
} | ||
} | ||
} as unknown as User; | ||
|
||
stager.addStage(message, user, defaultUser, defaultJournal) | ||
|
||
expect(message.stage).toBe('Any Room'); | ||
}) | ||
}); | ||
|
||
function changeFactoryQuest(user: User, quest: QuestSuperBrieFactory): User { | ||
user.quests.QuestSuperBrieFactory = quest; | ||
return user; | ||
} | ||
}); |