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.
This commit is contained in:
dfj committed 2026-10-24 01:00:24 +02:00
1 parent e08e288f73
commit b66491c5be
7 files changed
+300 -60

No files matched your search

+72 -21
View File
@@ -25,7 +25,7 @@ describe("CompareGear: upgrade scoring", function()
MockItems = {
[21869] = {
name = "Old Weapon",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 35 },
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 35 },
},
[31064] = {
name = "Hood of Absolution",
@@ -37,7 +37,7 @@ describe("CompareGear: upgrade scoring", function()
[31070] = {
name = "Shoulderpads of Absolution",
stats = {
["ITEM_MOD_SPELL_POWER_SHORT"] = 45,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 45,
["ITEM_MOD_INTELLECT_SHORT"] = 20,
},
},
@@ -47,7 +47,7 @@ describe("CompareGear: upgrade scoring", function()
},
[32374] = {
name = "Zhar'doom, Greatstaff of the Devourer",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 60 },
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 60 },
},
}
MockEquipped = {}
@@ -64,18 +64,20 @@ describe("CompareGear: upgrade scoring", function()
expect(data.totalSlots).toEqual(16)
end)
it("ranks empty-slot upgrades by full BIS stat value", function()
it("ranks upgrades by weighted spec stats", function()
equip("MainHand", 21869)
local data = ns.Amibis:CompareGear()
expect(#data.topUpgrades).toEqual(3)
-- Shoulder: 45 spell damage (x3) + 20 intellect (x1) = 155
expect(data.topUpgrades[1].slot).toEqual("Shoulder")
expect(data.topUpgrades[1].score).toEqual(65)
expect(data.topUpgrades[1].statDiffs).toEqual({ spellPower = 45, intellect = 20 })
expect(data.topUpgrades[2].slot).toEqual("Head")
expect(data.topUpgrades[2].score).toEqual(45)
expect(data.topUpgrades[3].slot).toEqual("MainHand")
expect(data.topUpgrades[3].score).toEqual(25)
expect(data.topUpgrades[3].statDiffs.spellPower).toEqual(25)
expect(data.topUpgrades[1].score).toEqual(155)
expect(data.topUpgrades[1].statDiffs).toEqual({ spellDamage = 45, intellect = 20 })
-- MainHand: (60 - 35) spell damage (x3) = 75
expect(data.topUpgrades[2].slot).toEqual("MainHand")
expect(data.topUpgrades[2].score).toEqual(75)
-- Head: 20 intellect (x1) + 25 spirit (x1) = 45
expect(data.topUpgrades[3].slot).toEqual("Head")
expect(data.topUpgrades[3].score).toEqual(45)
end)
it("includes a partial stat gain when only one stat improves", function()
@@ -84,7 +86,7 @@ describe("CompareGear: upgrade scoring", function()
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 15,
["ITEM_MOD_SPIRIT_SHORT"] = 10,
["ITEM_MOD_SPELL_POWER_SHORT"] = 8,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 8,
},
}
equip("Head", 21891)
@@ -135,7 +137,7 @@ describe("CompareGear: spec-specific stat keys", function()
MockItems = {
[21869] = {
name = "Old Weapon",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 20 },
stats = { ["ITEM_MOD_INTELLECT_SHORT"] = 20 },
},
[32374] = {
name = "Zhar'doom, Greatstaff of the Devourer",
@@ -161,7 +163,7 @@ describe("CompareGear: spec-specific stat keys", function()
local mh = find_upgrade(data, "MainHand")
expect(mh).toBeTruthy()
expect(mh.statDiffs.spellDamage).toEqual(40)
expect(mh.score).toEqual(40)
expect(mh.score).toEqual(120)
end)
it("ignores spell damage for Holy", function()
@@ -199,15 +201,64 @@ describe("GetStatKeysForSpec", function()
expect(found).toBeTruthy()
end)
it("falls back to default keys for unsupported specs", function()
it("uses physical stats for melee specs", function()
local keys = ns.Amibis:GetStatKeysForSpec("WARRIOR", "Arms")
expect(#keys).toEqual(6)
for _, key in ipairs(keys) do
expect(key ~= "healing" and key ~= "spellDamage").toBeTruthy()
local seen = {}
for _, key in ipairs(keys) do seen[key] = true end
expect(seen.strength).toBeTruthy()
expect(seen.attackPower).toBeTruthy()
expect(seen.hit).toBeTruthy()
expect(seen.crit).toBeTruthy()
expect(seen.healing).toBeFalsy()
expect(seen.spellDamage).toBeFalsy()
expect(seen.spirit).toBeFalsy()
expect(seen.mp5).toBeFalsy()
end)
it("uses mitigation stats for tanks", function()
local keys = ns.Amibis:GetStatKeysForSpec("PALADIN", "Protection")
local seen = {}
for _, key in ipairs(keys) do seen[key] = true end
expect(seen.stamina).toBeTruthy()
expect(seen.defense).toBeTruthy()
expect(seen.dodge).toBeTruthy()
expect(seen.parry).toBeTruthy()
end)
it("differs between specs of the same class", function()
local shadow = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Shadow"), ",")
local holy = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Holy"), ",")
expect(shadow ~= holy).toBeTruthy()
end)
it("falls back to a default profile for unsupported specs", function()
local keys = ns.Amibis:GetStatKeysForSpec("DEATHKNIGHT", "Frost")
expect(#keys > 0).toBeTruthy()
end)
it("keeps every spec profile within the 8-row panel limit", function()
for _, class in ipairs(ns.Data.BISLists:GetAvailableClasses()) do
for _, spec in ipairs(ns.Data.BISLists:GetAvailableSpecs(class)) do
local keys = ns.Amibis:GetStatKeysForSpec(class, spec)
expect(#keys > 0).toBeTruthy()
expect(#keys <= 8).toBeTruthy()
end
end
end)
end)
describe("StatRatio weighting", function()
it("weights primary stats above secondary ones", function()
local ratios = ns.Amibis
local bis = { spellDamage = 100, spirit = 100 }
local primary = ratios:StatRatio({ spellDamage = 100, spirit = 0 }, bis, "PRIEST", "Shadow")
local secondary = ratios:StatRatio({ spellDamage = 0, spirit = 100 }, bis, "PRIEST", "Shadow")
expect(primary > secondary).toBeTruthy()
expect(primary).toBeCloseTo(0.75)
expect(secondary).toBeCloseTo(0.25)
end)
end)
describe("GetCompletionRatio", function()
before_each(function()
MockItems = {}
@@ -231,7 +282,7 @@ describe("GetCompletionRatio", function()
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
equip(slot, entry.itemID)
@@ -266,7 +317,7 @@ describe("latest phase progress", function()
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
equip(slot, entry.itemID)
@@ -276,7 +327,7 @@ describe("latest phase progress", function()
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 200,
["ITEM_MOD_SPELL_POWER_SHORT"] = 90,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 90,
},
}
end