diablo2-web/tests/skills/ama/skill-032-valkyrie.test.ts

160 lines
5.9 KiB
TypeScript

/**
* 1.13c Numerical & Runtime Verification Suite — Skill #032: Valkyrie (AMA)
* Gitea Tracking Issue: #186
*/
import { describe, expect, it } from 'vitest'
import { getSharedDataRegistry } from '../../../src/game/engine/data-registry.ts'
import { UnitStatList } from '../../../src/game/engine/stat-list.ts'
import { WorldArena } from '../../../src/game/engine/world-arena.ts'
import { skillModule } from '../../../src/game/skills/impl/ama/skill-032-valkyrie.ts'
import { calculateValkyrieStats } from '../../../src/game/skills/amazon-passive.ts'
describe('[Skill #032] Valkyrie (AMA) — 1.13c Parity (Issue #186)', () => {
it('evaluates exact 1.13c Skills.txt / Missiles.txt formulas at slvl 1, 10, and 20', async () => {
const registry = await getSharedDataRegistry()
const skillRec = registry.getSkillById(32)!
expect(skillRec).toBeDefined()
expect(skillModule.skillId).toBe(32)
expect(skillModule.name).toBe("Valkyrie")
expect(skillModule.charClass).toBe("ama")
const stats1 = new UnitStatList()
stats1.setBaseSkillLevel(32, 1)
const r1 = skillModule.evaluate!({ registry, skill: skillRec, slvl: 1, blvl: 1, statList: stats1 })
expect(r1.manaCost).toBe(25)
expect(r1.manaCost256).toBe(6400)
expect(r1.minPhysDmg).toBe(0)
expect(r1.maxPhysDmg).toBe(0)
expect(r1.minElemDmg256).toBe(0)
expect(r1.maxElemDmg256).toBe(0)
const stats10 = new UnitStatList()
stats10.setBaseSkillLevel(32, 10)
const r10 = skillModule.evaluate!({ registry, skill: skillRec, slvl: 10, blvl: 10, statList: stats10 })
expect(r10.manaCost).toBe(34)
expect(r10.manaCost256).toBe(8704)
expect(r10.minPhysDmg).toBe(0)
expect(r10.maxPhysDmg).toBe(0)
expect(r10.minElemDmg256).toBe(0)
expect(r10.maxElemDmg256).toBe(0)
const stats20 = new UnitStatList()
stats20.setBaseSkillLevel(32, 20)
const r20 = skillModule.evaluate!({ registry, skill: skillRec, slvl: 20, blvl: 20, statList: stats20 })
expect(r20.manaCost).toBe(44)
expect(r20.manaCost256).toBe(11264)
expect(r20.minPhysDmg).toBe(0)
expect(r20.maxPhysDmg).toBe(0)
expect(r20.minElemDmg256).toBe(0)
expect(r20.maxElemDmg256).toBe(0)
expect(r20.durationFrames).toBe(0)
expect(r20.radiusSubtiles).toBe(495)
expect(r20.petMax).toBe(1)
expect(r20.cooldownFrames).toBe(150)
})
it('enforces 1.13c blvl synergy rule (hard points boost synergy; +skills and item charges do NOT)', async () => {
const registry = await getSharedDataRegistry()
const skillRec = registry.getSkillById(32)!
const synId = null
const statsBase = new UnitStatList()
statsBase.setBaseSkillLevel(32, 20)
if (synId !== null) {
statsBase.setBaseSkillLevel(synId, 20)
}
const withHardPoints = skillModule.evaluate!({
registry,
skill: skillRec,
slvl: 20,
blvl: 20,
statList: statsBase,
})
expect(withHardPoints.synergyBonusPct).toBe(0)
// +20 allskills and +33 Marrowwalk charges without hard points must yield 0 synergy
const statsSoftOnly = new UnitStatList()
statsSoftOnly.setBaseSkillLevel(32, 20)
statsSoftOnly.addStat('item_allskills', 20)
if (synId !== null) {
statsSoftOnly.setChargedSkillLevel(synId, 33)
}
const withSoftOnly = skillModule.evaluate!({
registry,
skill: skillRec,
slvl: 20,
blvl: 20,
statList: statsSoftOnly,
})
expect(withSoftOnly.synergyBonusPct).toBe(0)
})
it('executes runtime skill effect in WorldArena (castCount, action frame, and combat/state/missile/summon outcome)', async () => {
const registry = await getSharedDataRegistry()
const arena = new WorldArena({
registry,
classCode: "ama",
skillId: 32,
slvl: 20,
})
const outcome = arena.triggerCast()
arena.stepTicks(15)
const dbg = arena.getDebugState()
expect(dbg.ready).toBe(true)
expect(dbg.skillId).toBe(32)
expect(dbg.castCount).toBeGreaterThanOrEqual(1)
expect(dbg.actionFrameTriggered).toBe(true)
expect(outcome?.executed).toBe(true)
})
it('validates 1.13c calculateValkyrieStats pure calculations, synergies, and equipment tiers', () => {
// slvl 1: base HP 440, cooldown 150 frames (6.0s), mana 25 (6400), tier 1 basic
const stats1 = calculateValkyrieStats(1, {
decoyHardPoints: 0,
csLvl: 1,
dodgeLvl: 1,
avoidLvl: 1,
evadeLvl: 1,
penetrateLvl: 1,
})
expect(stats1.baseHp).toBe(440)
expect(stats1.finalHp).toBe(440)
expect(stats1.decoySynergyBonusPct).toBe(0)
expect(stats1.allResistancesPct).toBe(2)
expect(stats1.cooldownFrames).toBe(150)
expect(stats1.cooldownSeconds).toBe(6.0)
expect(stats1.equipmentTier).toBe('tier1_basic')
expect(stats1.inheritedCriticalStrikeLvl).toBe(1)
expect(stats1.manaCost).toBe(25)
expect(stats1.manaCost256).toBe(6400)
// Decoy Synergy: +20% HP per hard point (e.g. 5 Decoy hard points -> +100% life -> 880 HP)
const stats1WithDecoy = calculateValkyrieStats(1, { decoyHardPoints: 5 })
expect(stats1WithDecoy.decoySynergyBonusPct).toBe(100)
expect(stats1WithDecoy.finalHp).toBe(880)
// slvl 7: Boots tier
const stats7 = calculateValkyrieStats(7)
expect(stats7.equipmentTier).toBe('tier2_boots')
// slvl 11: Gloves tier
const stats11 = calculateValkyrieStats(11)
expect(stats11.equipmentTier).toBe('tier3_gloves')
// slvl 17: Rare War Pike tier
const stats17 = calculateValkyrieStats(17)
expect(stats17.equipmentTier).toBe('tier4_war_pike')
// slvl 27+: Tiara & Sacred Armor tier
const stats27 = calculateValkyrieStats(27)
expect(stats27.equipmentTier).toBe('tier5_rare_tiara')
// slvl 20: 440 * (1 + 0.2*19) = 440 * 4.8 = 2112 HP, 40% res, 44 mana
const stats20 = calculateValkyrieStats(20)
expect(stats20.baseHp).toBe(2112)
expect(stats20.allResistancesPct).toBe(40)
expect(stats20.manaCost).toBe(44)
})
})