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

+1 -1
View File
@@ -25,7 +25,7 @@ apt-get download lua5.4 && dpkg -x lua5.4_*.deb /tmp/lua && /tmp/lua/usr/bin/lua
|---|---|
| `test_data.lua` | `BIS_DATA` registry: 9 classes × 3 specs, well-formed slot entries (valid slots, positive item IDs, non-empty names/sources, optional enchant shape), canonical phase order, `ResolvePhase` fallback, shared-list invariants, T4/T5/ZA spot checks |
| `test_stats.lua` | `ScanItemStats`: MAX aggregation across alias keys (spell damage schools, healing, haste/crit/mp5 ratings), single-mapping pass-through, unmapped key filtering, nil handling |
| `test_compare.lua` | `CompareGear`: BIS counting, upgrade ranking by stat gain, positive-diffs-only scoring, spec-specific stat keys (Shadow counts spell damage, Holy counts healing), phase resolution, `GetStatKeysForSpec`, `GetCompletionRatio` |
| `test_compare.lua` | `CompareGear`: BIS counting, weighted upgrade ranking, positive-diffs-only scoring, per-spec stat profiles (Shadow counts spell damage, Holy counts healing, Warrior counts strength/AP, tank mitigation stats), `GetStatKeysForSpec`, `GetCompletionRatio` |
| `test_slash.lua` | `/amibis spec <name>` parsing: override set/clear, case and multi-word normalization, `spec clear` not treated as a spec name |
## Layout
+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
+58 -1
View File
@@ -134,7 +134,7 @@ describe("ScanItemStats", function()
name = "Resist Item",
stats = {
["ITEM_MOD_FIRE_RESISTANCE_SHORT"] = 15,
["ITEM_MOD_STRENGTH_SHORT"] = 8,
["ITEM_MOD_ARCANE_RESISTANCE_SHORT"] = 8,
["ITEM_MOD_INTELLECT_SHORT"] = 4,
},
}
@@ -145,6 +145,63 @@ describe("ScanItemStats", function()
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)