110 lines
4.5 KiB
TypeScript
110 lines
4.5 KiB
TypeScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { abilityById } from "./abilityCatalog";
|
|
import { PLAYER_AGGRO_ID } from "./aggro";
|
|
import { useCombatStore } from "./combatStore";
|
|
import { clearMobRuntimeRegistry } from "./mobRuntimeRegistry";
|
|
import { advanceDungeonPartyCombat, resetPartyRuntimeClock } from "./partyRuntime";
|
|
import { clearPartyRuntimeRegistry, registerPartyRuntimePosition } from "./partyRuntimeRegistry";
|
|
import { createConfiguredPartyMember, usePartyStore } from "./partyStore";
|
|
import { ROM_PRIEST_MAGE_ENLIGHTENMENT_PASSIVE_TAG } from "./romPriestMageRuntime";
|
|
|
|
const PASSIVE_TAG = ROM_PRIEST_MAGE_ENLIGHTENMENT_PASSIVE_TAG;
|
|
|
|
function initializePriestMage(): void {
|
|
useCombatStore.getState().initializeCharacter({
|
|
classId: "rom-priest",
|
|
secondaryClassId: "rom-mage",
|
|
raceId: "rom-human",
|
|
level: 45,
|
|
role: "healer",
|
|
});
|
|
}
|
|
|
|
function aura(actorId: string, tag: string, now: number) {
|
|
return useCombatStore.getState().auras.find((entry) => entry.targetId === actorId
|
|
&& (entry.expiresAt === null || entry.expiresAt > now)
|
|
&& entry.definition.utilityTags?.includes(tag));
|
|
}
|
|
|
|
describe("RoM Priest/Mage Enlightenment integration", () => {
|
|
beforeEach(() => {
|
|
clearMobRuntimeRegistry();
|
|
clearPartyRuntimeRegistry();
|
|
resetPartyRuntimeClock();
|
|
initializePriestMage();
|
|
usePartyStore.getState().initializeParty(
|
|
"priest-mage-enlightenment-test", 45, useCombatStore.getState().health, "healer", 2, "rom",
|
|
);
|
|
});
|
|
|
|
it("activates as a permanent +12% Wisdom passive for the player", () => {
|
|
const heal = abilityById("rom-priest-primary-2");
|
|
const passive = abilityById("rom-priest-rom-mage-elite-40");
|
|
if (!heal || !passive) throw new Error("Missing local Priest/Mage Heal or Enlightenment rows");
|
|
expect([heal.dbcSpellId, passive.dbcSpellId]).toEqual([490_261, 492_933]);
|
|
expect(passive.passive).toBe(true);
|
|
expect(passive.description).toBe("Passive: Increases Wisdom by 12%.");
|
|
expect(passive.effects).toHaveLength(1);
|
|
expect(passive.effects[0]).toMatchObject({
|
|
kind: "apply-aura",
|
|
aura: {
|
|
durationMs: null,
|
|
modifiers: [{ kind: "stat", stat: "wisdom", operation: "percent", value: 0.12 }],
|
|
},
|
|
});
|
|
expect(aura(PLAYER_AGGRO_ID, PASSIVE_TAG, 1_000)?.expiresAt).toBeNull();
|
|
|
|
useCombatStore.getState().damagePlayer(100);
|
|
expect(useCombatStore.getState().castAbility(heal.id, undefined, 1_000)).toMatchObject({ ok: true });
|
|
useCombatStore.getState().tick(0.1, 3_100);
|
|
expect(aura(PLAYER_AGGRO_ID, PASSIVE_TAG, 3_100)?.expiresAt).toBeNull();
|
|
expect(aura(PLAYER_AGGRO_ID, "rom-priest-mage-enlightenment-cooldown", 3_100)).toBeUndefined();
|
|
});
|
|
|
|
it("activates as a permanent +12% Wisdom passive for a generated companion", () => {
|
|
const seed = "priest-mage-enlightenment-party";
|
|
const healer = createConfiguredPartyMember({
|
|
name: "Enlightenment Priest",
|
|
classId: "rom-priest",
|
|
secondaryClassId: "rom-mage",
|
|
specialization: "Primary",
|
|
role: "healer",
|
|
}, 45, 0, seed);
|
|
const heal = abilityById("rom-priest-primary-2");
|
|
const passive = abilityById("rom-priest-rom-mage-elite-40");
|
|
if (!heal || !passive) throw new Error("Missing local Priest/Mage Heal or Enlightenment rows");
|
|
usePartyStore.getState().initializeParty(seed, 45, useCombatStore.getState().health, "healer", 2, "rom");
|
|
usePartyStore.setState({ members: [{
|
|
...healer,
|
|
resource: 10_000,
|
|
maxResource: 10_000,
|
|
resourcePools: { ...healer.resourcePools, mana: 10_000 },
|
|
activeCast: {
|
|
abilityId: heal.id,
|
|
school: "holy",
|
|
mode: "cast",
|
|
startedAt: 500,
|
|
completesAt: 2_500,
|
|
originalDurationMs: 2_000,
|
|
pushbackHits: 0,
|
|
origin: [0, 0, 0],
|
|
targetId: healer.id,
|
|
},
|
|
activeCastTargetId: healer.id,
|
|
status: "healing",
|
|
}] });
|
|
registerPartyRuntimePosition(healer.id, [0, 0, 0]);
|
|
useCombatStore.getState().synchronizeActors();
|
|
expect(passive.effects).toHaveLength(1);
|
|
expect(aura(healer.id, PASSIVE_TAG, 1_000)).toBeUndefined();
|
|
|
|
advanceDungeonPartyCombat(2_500);
|
|
|
|
expect(useCombatStore.getState().combatEvents.some((event) => event.sourceActorId === healer.id
|
|
&& event.abilityId === heal.id && event.kind === "healing")).toBe(true);
|
|
expect(aura(healer.id, PASSIVE_TAG, 2_500)?.expiresAt).toBeNull();
|
|
expect(aura(healer.id, "rom-priest-mage-enlightenment-cooldown", 2_500)).toBeUndefined();
|
|
expect(aura(PLAYER_AGGRO_ID, PASSIVE_TAG, 2_500)?.expiresAt).toBeNull();
|
|
});
|
|
});
|