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

96 lines
3.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
wow335HunterPetArmorForLevel,
wow335HunterPetArmorForProfile,
wow335HunterPetBaseDefenseForLevel,
wow335HunterPetInheritedDefenses,
} from "./wow335HunterPetInheritedDefenseRuntime";
import {
WOW335_HUNTER_PET_AGILITY_BY_LEVEL,
WOW335_HUNTER_PET_ARMOR_BY_LEVEL,
} from "./wow335HunterPetDefenseData";
describe("WoW 3.3.5 Hunter pet defensive inheritance source profile", () => {
it("inherits integer-truncated 35% of owner armor and 40% of each magical-school resistance", () => {
expect(wow335HunterPetInheritedDefenses(2_001, {
holy: 10,
fire: 20,
nature: 30,
frost: 40,
shadow: 50,
arcane: 60,
})).toEqual({
armor: 700,
resistances: {
holy: 4,
fire: 8,
nature: 12,
frost: 16,
shadow: 20,
arcane: 24,
},
});
});
it("truncates signed synthetic inputs toward zero and treats non-finite inputs as zero", () => {
expect(wow335HunterPetInheritedDefenses(Number.NaN, {
holy: Number.POSITIVE_INFINITY,
fire: -25,
nature: 0,
frost: 0,
shadow: 0,
arcane: 0,
})).toEqual({
armor: 0,
resistances: {
holy: 0,
fire: -10,
nature: 0,
frost: 0,
shadow: 0,
arcane: 0,
},
});
});
it("loads the pinned entry-1 armor and Agility data for levels 1 through 80", () => {
expect(WOW335_HUNTER_PET_ARMOR_BY_LEVEL).toHaveLength(80);
expect(WOW335_HUNTER_PET_AGILITY_BY_LEVEL).toHaveLength(80);
expect(wow335HunterPetBaseDefenseForLevel(1)).toEqual({ level: 1, armor: 20, agility: 20 });
expect(wow335HunterPetBaseDefenseForLevel(60)).toEqual({ level: 60, armor: 3_814, agility: 100 });
expect(wow335HunterPetBaseDefenseForLevel(80)).toEqual({ level: 80, armor: 9_784, agility: 158 });
});
it("clamps pet level lookup to the supported entry-1 range", () => {
expect(wow335HunterPetBaseDefenseForLevel(0)).toEqual({ level: 1, armor: 20, agility: 20 });
expect(wow335HunterPetBaseDefenseForLevel(81)).toEqual({ level: 80, armor: 9_784, agility: 158 });
expect(wow335HunterPetBaseDefenseForLevel(Number.NaN)).toEqual({ level: 1, armor: 20, agility: 20 });
});
it("composes armor with CalculatePct integer conversion and final int32 truncation", () => {
// Owner armor 1 gives CalculatePct<uint32>(1, 35) == 0. Pet armor is
// 20 * 1.25 + (20 Agility * 2) + 0.75 flat = 65.75; * 1.01 is
// truncated by SetArmor(int32(value)) to 66.
expect(wow335HunterPetArmorForLevel(1, 1, {
baseArmorMultiplier: 1.25,
petFlatArmor: 0.75,
totalArmorMultiplier: 1.01,
})).toBe(66);
// The two conversion points remain independently observable when the
// caller supplies a custom profile instead of entry-1 baseline stats.
expect(wow335HunterPetArmorForProfile({
petBaseArmor: 0,
petAgility: 0,
ownerArmor: 1,
petFlatArmor: 0.8,
})).toBe(0);
expect(wow335HunterPetArmorForProfile({
petBaseArmor: 1.25,
petAgility: 0,
ownerArmor: 0,
baseArmorMultiplier: 1,
})).toBe(1);
});
});