forked from phenom/healer-man
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
export type Wow335HunterPetHappinessState = "unhappy" | "content" | "happy";
|
|
|
|
/** TrinityCore 3.3.5 stores each happiness band as 333,000 POWER_HAPPINESS. */
|
|
export const WOW335_HUNTER_PET_HAPPINESS_LEVEL_SIZE = 333_000;
|
|
|
|
/**
|
|
* Resolve the stock 3.3.5 happiness band from the pet's POWER_HAPPINESS value.
|
|
* Invalid values safely fall back to zero, which is the Unhappy band.
|
|
*/
|
|
export function wow335HunterPetHappinessState(
|
|
happinessPower: number,
|
|
): Wow335HunterPetHappinessState {
|
|
const value = Number.isFinite(happinessPower)
|
|
? Math.max(0, Math.trunc(happinessPower))
|
|
: 0;
|
|
if (value < WOW335_HUNTER_PET_HAPPINESS_LEVEL_SIZE) return "unhappy";
|
|
if (value >= WOW335_HUNTER_PET_HAPPINESS_LEVEL_SIZE * 2) return "happy";
|
|
return "content";
|
|
}
|
|
|
|
/**
|
|
* Stock 3.3.5 Hunter-pet main-hand base-damage multiplier by happiness band.
|
|
* This is deliberately scoped to base auto-attack damage; it does not assert
|
|
* that every special-attack formula consumes the modified weapon damage.
|
|
*/
|
|
export function wow335HunterPetAutoAttackDamageMultiplier(
|
|
happinessPower: number,
|
|
): number {
|
|
const state = wow335HunterPetHappinessState(happinessPower);
|
|
if (state === "happy") return 1.25;
|
|
if (state === "unhappy") return 0.75;
|
|
return 1;
|
|
}
|