import { beforeEach, describe, expect, it } from "vitest"; import { applyAura } from "./combatAuras"; import { clearMobRuntimeRegistry, setMobPosition } from "./mobRuntimeRegistry"; import { clearPartyRuntimeRegistry } from "./partyRuntimeRegistry"; import { preloadAbilityCatalogsForClasses } from "./abilityCatalog"; import { PLAYER_AURA_ENTITY_ID, useCombatStore } from "./combatStore"; import { usePartyStore } from "./partyStore"; import { WOW335_DRUID_MASTER_SHAPESHIFTER_TALENT_ID } from "./wow335DruidMasterShapeshifterRuntime"; const TARGET_ID = "druid-master-shapeshifter-target"; function playerAbilityId(name: string): string { const ability = useCombatStore.getState().abilities.find((candidate) => candidate.name === name); expect(ability, name).toBeDefined(); return ability!.id; } describe("WoW Druid Master Shapeshifter integration", () => { beforeEach(async () => { clearMobRuntimeRegistry(); clearPartyRuntimeRegistry(); await preloadAbilityCatalogsForClasses(["druid"]); useCombatStore.getState().initializeCharacter({ classId: "druid", level: 80, xp: 0 }); useCombatStore.getState().resetSettings(); usePartyStore.getState().initializeParty("wow335-master-shapeshifter-tests", 1, useCombatStore.getState().health); useCombatStore.setState((state) => ({ resource: state.maxResource, resourcePools: { ...state.resourcePools, mana: state.maxResourcePools.mana }, })); useCombatStore.getState().registerMob(TARGET_ID, { name: "Target", maxHealth: 1_000_000 }); useCombatStore.setState((state) => ({ mobs: { ...state.mobs, [TARGET_ID]: { ...state.mobs[TARGET_ID]!, characterDefender: { level: 80, armor: 0, dodgePercent: 0, parryPercent: 0, blockPercent: 0, blockValue: 0, }, }, }, })); setMobPosition(TARGET_ID, [4, 0, 0]); }); it("adds Bear Form physical damage to a player melee hit", () => { useCombatStore.setState((state) => ({ talentRanks: { ...state.talentRanks, [WOW335_DRUID_MASTER_SHAPESHIFTER_TALENT_ID]: 2 }, })); const form = useCombatStore.getState().castAbility(playerAbilityId("Bear Form"), { targetActorId: null, now: 1_000, }); expect(form.ok).toBe(true); const result = useCombatStore.getState().damageMob( TARGET_ID, 100, 2_000, undefined, "physical", { attackKind: "melee", seed: "master-shapeshifter-player-bear-hit", rules: { canMiss: false, canCrit: false, canDodge: false, canParry: false, canBlock: false }, }, ); expect(result.amount).toBe(104); }); it("adds Tree of Life healing to a party Druid's direct heal", () => { usePartyStore.setState((state) => ({ members: state.members.map((member, index) => index === 0 ? { ...member, classId: "druid", talentRanks: { ...member.talentRanks, [WOW335_DRUID_MASTER_SHAPESHIFTER_TALENT_ID]: 2 }, } : member), })); const druid = usePartyStore.getState().members[0]!; useCombatStore.setState((state) => ({ health: Math.round(state.maxHealth / 2), auras: [...applyAura(state.auras, { definition: { id: "wow335:33891:effect:0:aura:36", name: "Tree of Life", disposition: "buff", durationMs: null, }, sourceId: druid.id, targetId: druid.id, now: 1_000, }).auras], })); const result = useCombatStore.getState().healActor(PLAYER_AURA_ENTITY_ID, 100, { sourceActorId: druid.id, abilityId: "test-druid-heal", now: 2_000, }); expect(result.rawAmount).toBe(104); }); });