import { describe, expect, it } from "vitest"; import { applyAura } from "./combatAuras"; import { ROM_PRIEST_HOLY_BLESSING, ROM_PRIEST_HOLY_BLESSING_PASSIVE_EFFECT, ROM_PRIEST_HOLY_BLESSING_TAG, romPriestHolyBlessingEffects, romPriestHolyBlessingStats, romPriestHolyBlessingWisdom, } from "./romPriestHolyBlessingRuntime"; const holyBlessing = { classId: "rom-priest", sourceSkillId: 490_274, name: "Holy Blessing", description: "Current CoA Wisdom and Light damage passive.", passive: true, }; describe("RoM Priest Holy Blessing", () => { it("applies the current-Wisdom formula as one flat-then-percent stat stage", () => { expect(ROM_PRIEST_HOLY_BLESSING).toEqual({ spellId: 490_274, wisdomFlat: 115, wisdomPercent: 10.5, lightDamagePercent: 100.9, }); expect(romPriestHolyBlessingWisdom(0)).toBeCloseTo((0 + 115) * 1.105); expect(romPriestHolyBlessingWisdom(320)).toBeCloseTo((320 + 115) * 1.105); expect(romPriestHolyBlessingWisdom(-20)).toBeCloseTo(115 * 1.105); expect(romPriestHolyBlessingWisdom(Number.NaN)).toBeCloseTo(115 * 1.105); }); it("resolves other Wisdom buffs first and returns only the incremental derived spell power", () => { const blessingAura = ROM_PRIEST_HOLY_BLESSING_PASSIVE_EFFECT.aura; const existingWisdomAura = { id: "test:wisdom-buff", name: "Existing Wisdom buff", disposition: "buff" as const, durationMs: null, modifiers: [{ kind: "stat" as const, stat: "wisdom", operation: "percent" as const, value: 0.12 }], }; const spellPowerAura = { id: "test:spell-power-buff", name: "Existing spell power buff", disposition: "buff" as const, durationMs: null, modifiers: [{ kind: "stat" as const, stat: "spell-power", operation: "percent" as const, value: 0.5 }], }; const auraFor = (definition: typeof blessingAura | typeof existingWisdomAura | typeof spellPowerAura) => ( applyAura([], { definition, sourceId: "priest", targetId: "priest", now: 0 }).aura ); const blessing = auraFor(blessingAura); const wisdomBuff = auraFor(existingWisdomAura); const spellPowerBuff = auraFor(spellPowerAura); const withoutSpellPowerAura = romPriestHolyBlessingStats( { intellect: 200, spirit: 100 }, [blessing, wisdomBuff], ); const withSpellPowerAura = romPriestHolyBlessingStats( { intellect: 200, spirit: 100 }, [blessing, wisdomBuff, spellPowerBuff], ); expect(withSpellPowerAura.currentWisdom).toBeCloseTo(100 * 1.12); expect(withSpellPowerAura.wisdom).toBeCloseTo((100 * 1.12 + 115) * 1.105); expect(withSpellPowerAura.spellPowerBonus).toBe( Math.round(200 * 0.35 + withSpellPowerAura.wisdom * 0.15) - Math.round(200 * 0.35 + withSpellPowerAura.currentWisdom * 0.15), ); expect(withSpellPowerAura.spellPowerBonus).toBe(withoutSpellPowerAura.spellPowerBonus); }); it("defines a permanent caster aura with Wisdom and Light-only damage modifiers", () => { const effect = ROM_PRIEST_HOLY_BLESSING_PASSIVE_EFFECT; expect(effect).toMatchObject({ kind: "apply-aura", recipient: "caster", triggerSpellId: 490_274, aura: { id: ROM_PRIEST_HOLY_BLESSING_TAG, durationMs: null, maxStacks: 1, utilityTags: [ROM_PRIEST_HOLY_BLESSING_TAG], modifiers: [ { kind: "stat", stat: "wisdom", operation: "flat", value: 115 }, { kind: "stat", stat: "wisdom", operation: "percent", value: 0.105 }, { kind: "damage", direction: "dealt", school: "holy", operation: "percent" }, ], }, }); const lightDamage = effect.aura.modifiers?.find((modifier) => modifier.kind === "damage"); if (lightDamage?.kind !== "damage") throw new Error("Missing Holy Blessing Light damage modifier"); expect(lightDamage.value).toBeCloseTo(1.009); }); it("only replaces the Priest primary spell's generated effects", () => { expect(romPriestHolyBlessingEffects(holyBlessing)).toEqual([ROM_PRIEST_HOLY_BLESSING_PASSIVE_EFFECT]); expect(romPriestHolyBlessingEffects({ ...holyBlessing, secondaryClassId: "rom-mage" })).toBeNull(); expect(romPriestHolyBlessingEffects({ ...holyBlessing, classId: "rom-mage" })).toBeNull(); expect(romPriestHolyBlessingEffects({ ...holyBlessing, sourceSkillId: 490_275 })).toBeNull(); }); });