Files
dfj b66491c5be Tailor stat comparison and scoring to each spec
Replace the flat per-spec key list with SPEC_STAT_PROFILES: an ordered
{ stat, weight } table for every class/spec. The panel now shows what
matters to the selected spec instead of falling back to spell stats for
physical specs: casters get spell damage/hit/crit/haste, melee get
strength/AP/hit/expertise/armor pen, tanks get stamina/armor/defense/
dodge/parry/block, healers get healing/spirit/MP5.

The same weights drive upgrade ranking, the completion ratio, and which
two gains are shown in the top-upgrades line, so e.g. spell damage
outweighs spirit for Shadow while stamina outweighs expertise for a
Protection tank.

Add GetItemStats mappings for physical stats (attack power, ranged/feral
AP, strength, agility, hit, expertise, armor pen, defense, dodge, parry,
block, block value, armor). TBC per-school hit/crit/haste keys fold into
one stat. Drop the unused spellPower row from TBC profiles.

Tests: weighted scoring expectations, physical/tank mappings, profile
coverage and 8-row panel limit, weighted ratios. 104 passing.
2026-10-24 01:00:24 +02:00

216 lines
7.3 KiB
Lua

-- Unit tests for Amibis:ScanItemStats — alias aggregation behavior.
local _, ns = ...
describe("ScanItemStats", function()
before_each(function()
MockItems = {}
end)
it("takes MAX across aliased spell damage keys", function()
MockItems[1] = {
name = "Aliased Item",
stats = {
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 28,
["ITEM_MOD_DAMAGE_DONE_SHORT"] = 28,
["ITEM_MOD_SPELL_DMG_SHORT"] = 40,
},
}
local stats = ns.Amibis:ScanItemStats(1)
expect(stats.spellDamage).toEqual(40)
end)
it("does not double count school spell damage", function()
MockItems[21870] = {
name = "Frozen Shadoweave Boots",
stats = {
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 28,
["ITEM_MOD_DAMAGE_DONE_SHORT"] = 28,
},
}
local stats = ns.Amibis:ScanItemStats(21870)
expect(stats.spellDamage).toEqual(28)
end)
it("takes MAX across aliased healing keys", function()
MockItems[2] = {
name = "Healing Item",
stats = {
["ITEM_MOD_HEALING_DONE_SHORT"] = 40,
["ITEM_MOD_SPELL_HEALING_DONE_SHORT"] = 40,
["ITEM_MOD_HEALING_SHORT"] = 55,
},
}
expect(ns.Amibis:ScanItemStats(2).healing).toEqual(55)
end)
it("takes MAX across aliased rating keys", function()
MockItems[3] = {
name = "Rating Item",
stats = {
["ITEM_MOD_HASTE_RATING_SHORT"] = 21,
["ITEM_MOD_SPELL_HASTE_RATING_SHORT"] = 21,
["ITEM_MOD_CRIT_RATING_SHORT"] = 14,
["ITEM_MOD_SPELL_CRIT_RATING_SHORT"] = 14,
["ITEM_MOD_MANA_REGENERATION_SHORT"] = 10,
["ITEM_MOD_POWER_REGEN0_SHORT"] = 10,
},
}
local stats = ns.Amibis:ScanItemStats(3)
expect(stats.haste).toEqual(21)
expect(stats.crit).toEqual(14)
expect(stats.mp5).toEqual(10)
end)
it("reads TBC school-specific spell haste and crit keys", function()
MockItems[8] = {
name = "Sunfire Robe",
stats = {
["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = 40,
["ITEM_MOD_CRIT_SPELL_RATING_SHORT"] = 23,
["ITEM_MOD_SPELL_POWER_SHORT"] = 54,
},
}
local stats = ns.Amibis:ScanItemStats(8)
expect(stats.haste).toEqual(40)
expect(stats.crit).toEqual(23)
expect(stats.spellPower).toEqual(54)
end)
it("reads TBC melee and ranged haste keys", function()
MockItems[9] = {
name = "Physical Haste Item",
stats = {
["ITEM_MOD_HASTE_MELEE_RATING_SHORT"] = 30,
["ITEM_MOD_HASTE_RANGED_RATING_SHORT"] = 30,
["ITEM_MOD_CRIT_MELEE_RATING_SHORT"] = 15,
},
}
local stats = ns.Amibis:ScanItemStats(9)
expect(stats.haste).toEqual(30)
expect(stats.crit).toEqual(15)
end)
it("does not add generic and school-specific haste together", function()
MockItems[10] = {
name = "Double Reported Haste",
stats = {
["ITEM_MOD_HASTE_RATING_SHORT"] = 20,
["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = 20,
},
}
expect(ns.Amibis:ScanItemStats(10).haste).toEqual(20)
end)
it("keeps the highest school value", function()
MockItems[4] = {
name = "Mixed School Item",
stats = {
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 28,
["ITEM_MOD_DAMAGE_DONE_SHORT"] = 31,
},
}
expect(ns.Amibis:ScanItemStats(4).spellDamage).toEqual(31)
end)
it("passes through single-mapping stats", function()
MockItems[5] = {
name = "Plain Item",
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 30,
["ITEM_MOD_SPIRIT_SHORT"] = 12,
["ITEM_MOD_STAMINA_SHORT"] = 21,
["ITEM_MOD_SPELL_POWER_SHORT"] = 33,
},
}
local stats = ns.Amibis:ScanItemStats(5)
expect(stats.intellect).toEqual(30)
expect(stats.spirit).toEqual(12)
expect(stats.stamina).toEqual(21)
expect(stats.spellPower).toEqual(33)
end)
it("ignores unmapped stat keys", function()
MockItems[6] = {
name = "Resist Item",
stats = {
["ITEM_MOD_FIRE_RESISTANCE_SHORT"] = 15,
["ITEM_MOD_ARCANE_RESISTANCE_SHORT"] = 8,
["ITEM_MOD_INTELLECT_SHORT"] = 4,
},
}
local stats = ns.Amibis:ScanItemStats(6)
expect(stats.intellect).toEqual(4)
local keyCount = 0
for _ in pairs(stats) do keyCount = keyCount + 1 end
expect(keyCount).toEqual(1)
end)
it("reads physical stats", function()
MockItems[11] = {
name = "Melee Item",
stats = {
["ITEM_MOD_STRENGTH_SHORT"] = 40,
["ITEM_MOD_AGILITY_SHORT"] = 25,
["ITEM_MOD_ATTACK_POWER_SHORT"] = 80,
["ITEM_MOD_HIT_RATING_SHORT"] = 10,
["ITEM_MOD_EXPERTISE_RATING_SHORT"] = 12,
["ITEM_MOD_ARMOR_PENETRATION_RATING_SHORT"] = 15,
["ITEM_MOD_CRIT_RATING_SHORT"] = 20,
},
}
local stats = ns.Amibis:ScanItemStats(11)
expect(stats.strength).toEqual(40)
expect(stats.agility).toEqual(25)
expect(stats.attackPower).toEqual(80)
expect(stats.hit).toEqual(10)
expect(stats.expertise).toEqual(12)
expect(stats.armorPen).toEqual(15)
expect(stats.crit).toEqual(20)
end)
it("reads tank and armor stats", function()
MockItems[12] = {
name = "Tank Item",
stats = {
["ITEM_MOD_STAMINA_SHORT"] = 60,
["ITEM_MOD_DEFENSE_SKILL_RATING_SHORT"] = 20,
["ITEM_MOD_DODGE_RATING_SHORT"] = 18,
["ITEM_MOD_PARRY_RATING_SHORT"] = 17,
["ITEM_MOD_BLOCK_RATING_SHORT"] = 16,
["ITEM_MOD_BLOCK_VALUE_SHORT"] = 40,
["RESISTANCE0_NAME"] = 1200,
},
}
local stats = ns.Amibis:ScanItemStats(12)
expect(stats.stamina).toEqual(60)
expect(stats.defense).toEqual(20)
expect(stats.dodge).toEqual(18)
expect(stats.parry).toEqual(17)
expect(stats.block).toEqual(16)
expect(stats.blockValue).toEqual(40)
expect(stats.armor).toEqual(1200)
end)
it("takes MAX across TBC hit rating keys", function()
MockItems[13] = {
name = "Hit Item",
stats = {
["ITEM_MOD_HIT_SPELL_RATING_SHORT"] = 14,
["ITEM_MOD_HIT_RATING_SHORT"] = 14,
},
}
expect(ns.Amibis:ScanItemStats(13).hit).toEqual(14)
end)
it("returns nil for unknown items", function()
expect(ns.Amibis:ScanItemStats(999999)).toBeNil()
end)
it("returns an empty table for items with no mapped stats", function()
MockItems[7] = { name = "Empty Item", stats = {} }
local stats = ns.Amibis:ScanItemStats(7)
expect(stats).toBeTruthy()
expect(next(stats)).toBeNil()
end)
end)