Files
healer-man/src/game/wow335ShamanElementalFocusRuntime.ts
T
2026-10-02 10:38:12 -04:00

55 lines
2.0 KiB
TypeScript

import { WOW335_TALENT_NODES } from "./wow335Talents.generated";
export const WOW335_SHAMAN_ELEMENTAL_FOCUS_TALENT_ID = "talent-574";
export const WOW335_SHAMAN_ELEMENTAL_FOCUS_AURA_TAG = "wow335-shaman-elemental-focus-clearcasting";
export const WOW335_SHAMAN_ELEMENTAL_FOCUS_DURATION_MS = 15_000;
const ELEMENTAL_FOCUS_SOURCE = WOW335_TALENT_NODES.find((node) => (
node.id === WOW335_SHAMAN_ELEMENTAL_FOCUS_TALENT_ID
));
export interface Wow335ShamanElementalFocusProfile {
readonly procChancePercent: number;
readonly costReductionPercent: number;
readonly charges: 2;
readonly durationMs: number;
}
/** Reads the proc chance and discount from the generated local talent tooltip. */
export function wow335ShamanElementalFocusProfileForRank(
rank: number,
): Wow335ShamanElementalFocusProfile | null {
const safeRank = Math.max(0, Math.min(2, Math.trunc(Number.isFinite(rank) ? rank : 0)));
const description = safeRank > 0
? ELEMENTAL_FOCUS_SOURCE?.rankDescriptions[safeRank - 1]
: undefined;
const match = description?.match(/you have a (\d+(?:\.\d+)?)% chance.*?next two .*? by (\d+(?:\.\d+)?)%/i);
if (!match) return null;
const procChancePercent = Number(match[1]);
const costReductionPercent = Number(match[2]);
if (!Number.isFinite(procChancePercent) || !Number.isFinite(costReductionPercent)) return null;
return {
procChancePercent,
costReductionPercent,
charges: 2,
// The local triggered Clearcasting effect is 15 seconds (SpellDuration row 8).
durationMs: WOW335_SHAMAN_ELEMENTAL_FOCUS_DURATION_MS,
};
}
export function wow335ShamanElementalFocusShouldProc(
profile: Wow335ShamanElementalFocusProfile | null,
school: string,
critical: boolean,
periodic: boolean,
roll: number,
): boolean {
return profile !== null
&& critical
&& !periodic
&& ["fire", "frost", "nature"].includes(school.toLowerCase())
&& Number.isFinite(roll)
&& roll >= 0
&& roll < profile.procChancePercent / 100;
}