-
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 #430 from m-h-c-t/fi-stage-rework
Rework Floating Island stages
- Loading branch information
Showing
8 changed files
with
382 additions
and
46 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
93 changes: 93 additions & 0 deletions
93
src/scripts/modules/stages/environments/floatingIslands.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,93 @@ | ||
import {type User} from '@scripts/types/hg'; | ||
import {type IntakeMessage} from '@scripts/types/mhct'; | ||
import {type IslandModType} from '@scripts/types/quests/floatingIslands'; | ||
import {type IStager} from '../stages.types'; | ||
|
||
// See floatingIslands.spec.ts for docs about all stage names | ||
|
||
export class FloatingIslandsStager implements IStager { | ||
readonly environment: string = 'Floating Islands'; | ||
|
||
addStage(message: IntakeMessage, userPre: User, userPost: User, journal: unknown): void { | ||
const quest = userPre.quests.QuestFloatingIslands; | ||
|
||
if (!quest) { | ||
throw new Error('QuestFloatingIslands is undefined'); | ||
} | ||
|
||
const hsa = quest.hunting_site_atts; | ||
const getCountOfActiveModType = (type: IslandModType): number => { | ||
return hsa.activated_island_mod_types.filter(t => t == type).length; | ||
}; | ||
|
||
const matcher = hsa.island_name.match(/^(\w+) .*$/); | ||
if (!matcher) { | ||
throw new Error('Failed to match Floating Island\'s island name.'); | ||
} | ||
|
||
const powerType = matcher[1]; | ||
|
||
if (hsa.is_low_tier_island) { | ||
message.stage = `${powerType} Low`; | ||
} else if (hsa.is_high_tier_island) { | ||
message.stage = `${powerType} High`; | ||
} else if (hsa.is_vault_island) { | ||
message.stage = `${powerType} Palace`; | ||
} else { | ||
throw new Error('Unknown Floating Island stage'); | ||
} | ||
|
||
const numActiveLootCaches = getCountOfActiveModType('loot_cache'); | ||
|
||
if (hsa.is_enemy_encounter) { | ||
if (hsa.is_low_tier_island) | ||
message.stage = "Warden"; | ||
else if (hsa.is_high_tier_island) | ||
message.stage = `${powerType} Paragon`; | ||
else if (hsa.is_vault_island) | ||
message.stage = "Empress"; | ||
else | ||
message.stage += " Enemy Encounter"; | ||
} | ||
else if (userPre.bait_name === "Sky Pirate Swiss Cheese") { | ||
const numActivePirates = getCountOfActiveModType('sky_pirates'); | ||
message.stage = hsa.is_vault_island ? "Palace" : "Low|High"; | ||
message.stage += ` - ${numActivePirates}x Pirates`; | ||
} | ||
else if (userPre.bait_name?.endsWith("Cloud Cheesecake") && numActiveLootCaches >= 2) { | ||
message.stage += ` - ${numActiveLootCaches}x Loot`; | ||
} | ||
// If a vault run has 3 or more active mods of the same type, add it to the stage name | ||
else if (hsa.is_vault_island && Array.isArray(hsa.activated_island_mod_types)) { | ||
// Takes an array of items, and returns a Map with the | ||
// counts of each item in the array. | ||
const panels: Record<string, number> = {}; | ||
hsa.activated_island_mod_types.forEach(t => t in panels ? panels[t]++ : panels[t] = 1); | ||
|
||
for (const [islandType, count] of Object.entries(panels)) { | ||
if (count < 3) { | ||
continue; | ||
} | ||
|
||
let mod_type = hsa.island_mod_panels.find(p => p.type === islandType)?.name; | ||
|
||
if (mod_type == null) { | ||
throw new Error('The active island type could not be found in current island panels (this shouldn\'t be possible).'); | ||
} | ||
|
||
const shortMod: Record<string, string> = { | ||
'Ancient Jade Stockpile': 'Jade', | ||
'Empyrean Seal Stowage': 'Emp Seal', | ||
'Ore and Glass Deposit': 'Glass + Ore', | ||
'Sky Pirate Den': 'Pirates', | ||
}; | ||
|
||
if (shortMod[mod_type]) { | ||
mod_type = shortMod[mod_type]; | ||
} | ||
|
||
message.stage += ` - ${count}x ${mod_type}`; | ||
} | ||
} | ||
} | ||
} |
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,40 @@ | ||
export interface QuestFloatingIslands { | ||
hunting_site_atts: FloatingIslandHuntingSiteAtts | ||
} | ||
|
||
export interface FloatingIslandHuntingSiteAtts { | ||
island_name: string; | ||
is_enemy_encounter: boolean | null; | ||
is_low_tier_island: boolean | null; | ||
is_high_tier_island: boolean | null; | ||
is_vault_island: boolean | null; | ||
activated_island_mod_types: IslandModType[]; | ||
island_mod_panels: IslandModPanel[]; | ||
} | ||
|
||
interface IslandModPanel { | ||
type: IslandModType; | ||
name: string; | ||
} | ||
|
||
export const IslandModTypes = [ | ||
'empty', | ||
'empty_sky', | ||
'gem_bonus', | ||
'ore_bonus', | ||
'sky_cheese', | ||
'sky_pirates', | ||
'loot_cache', | ||
'wind_shrine', | ||
'rain_shrine', | ||
'frost_shrine', | ||
'fog_shrine', | ||
'paragon_cache_a', | ||
'paragon_cache_d', | ||
'paragon_cache_c', | ||
'paragon_cache_b', | ||
'ore_gem_bonus', | ||
'cloudstone_bonus', | ||
'charm_bonus', | ||
] as const; | ||
export type IslandModType = typeof IslandModTypes[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
Oops, something went wrong.