-
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
70 additions
and
32 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,35 @@ | ||
import {type User} from '@scripts/types/hg'; | ||
import {type IntakeMessage} from '@scripts/types/mhct'; | ||
import {type IStager} from '../stages.types'; | ||
|
||
export class BalacksCoveStager implements IStager { | ||
readonly environment: string = 'Balack\'s Cove'; | ||
|
||
/** | ||
* Set the stage based on the tide. Reject hunts near tide intensity changes. | ||
*/ | ||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
const quest = userPre.quests.QuestBalacksCove; | ||
|
||
if (!quest) { | ||
throw new Error('QuestBalacksCove is undefined'); | ||
} | ||
|
||
const tide = quest.tide.level; | ||
const direction = quest.tide.direction; | ||
const progress = quest.tide.percent; | ||
const imminent_state_change = (progress >= 99 | ||
// Certain transitions do not change the tide intensity, and are OK to track. | ||
&& !(tide === "low" && direction === "in") | ||
&& !(tide === "high" && direction === "out")); | ||
if (!imminent_state_change && tide) { | ||
message.stage = tide.charAt(0).toUpperCase() + tide.substr(1); | ||
if (message.stage === "Med") { | ||
message.stage = "Medium"; | ||
} | ||
message.stage += " Tide"; | ||
} else { | ||
throw new Error('Skipping hunt due to imminent tide change'); | ||
} | ||
} | ||
} |
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,7 @@ | ||
export interface QuestBalacksCove { | ||
tide: { | ||
level: 'low' | 'med' | 'high' | ||
direction: 'in' | 'out' | ||
percent: number | ||
} | ||
} |
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