From e08e288f73da4e6e0679a290fbb5285697c9fe92 Mon Sep 17 00:00:00 2001 From: dfj Date: Sat, 24 Oct 2026 00:50:02 +0200 Subject: [PATCH] Read TBC school-specific haste and crit item stats TBC items report per-school ratings with a different key shape than the WotLK-era names the addon mapped: "spell haste" is ITEM_MOD_HASTE_SPELL_RATING(_SHORT), not ITEM_MOD_SPELL_HASTE_RATING, and crit is ITEM_MOD_CRIT_SPELL_RATING/MELEE/RANGED rather than ITEM_MOD_SPELL_CRIT_RATING. As a result spell haste (and spell/melee crit) on TBC gear scanned as zero, so the stats panel showed no haste and upgrade scoring ignored it. Map the TBC haste/crit keys alongside the existing generic ones, plus non-_SHORT variants for safety. The alias logic still takes MAX per stat, so an item that reports both forms is not double counted. Tests cover TBC spell haste + crit, melee/ranged haste keys, and generic+school-specific de-duplication. 96 passing. --- Amibis/Amibis.lua | 21 ++++++++++++++++++- Amibis/Tests/test_stats.lua | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Amibis/Amibis.lua b/Amibis/Amibis.lua index b430ef9..630c22d 100644 --- a/Amibis/Amibis.lua +++ b/Amibis/Amibis.lua @@ -201,11 +201,30 @@ local STAT_MAP = { ["ITEM_MOD_SPIRIT_SHORT"] = "spirit", ["ITEM_MOD_STAMINA_SHORT"] = "stamina", ["ITEM_MOD_MANA_REGENERATION_SHORT"] = "mp5", + ["ITEM_MOD_MANA_REGENERATION"] = "mp5", ["ITEM_MOD_POWER_REGEN0_SHORT"] = "mp5", + -- TBC uses school-specific ratings (haste/crit melee, ranged, spell) as well + -- as the generic WotLK-era keys; items report whichever applies. ["ITEM_MOD_HASTE_RATING_SHORT"] = "haste", + ["ITEM_MOD_HASTE_RATING"] = "haste", + ["ITEM_MOD_HASTE_MELEE_RATING_SHORT"] = "haste", + ["ITEM_MOD_HASTE_MELEE_RATING"] = "haste", + ["ITEM_MOD_HASTE_RANGED_RATING_SHORT"] = "haste", + ["ITEM_MOD_HASTE_RANGED_RATING"] = "haste", + ["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = "haste", + ["ITEM_MOD_HASTE_SPELL_RATING"] = "haste", ["ITEM_MOD_SPELL_HASTE_RATING_SHORT"] = "haste", - ["ITEM_MOD_SPELL_CRIT_RATING_SHORT"] = "crit", + ["ITEM_MOD_SPELL_HASTE_RATING"] = "haste", ["ITEM_MOD_CRIT_RATING_SHORT"] = "crit", + ["ITEM_MOD_CRIT_RATING"] = "crit", + ["ITEM_MOD_CRIT_MELEE_RATING_SHORT"] = "crit", + ["ITEM_MOD_CRIT_MELEE_RATING"] = "crit", + ["ITEM_MOD_CRIT_RANGED_RATING_SHORT"] = "crit", + ["ITEM_MOD_CRIT_RANGED_RATING"] = "crit", + ["ITEM_MOD_CRIT_SPELL_RATING_SHORT"] = "crit", + ["ITEM_MOD_CRIT_SPELL_RATING"] = "crit", + ["ITEM_MOD_SPELL_CRIT_RATING_SHORT"] = "crit", + ["ITEM_MOD_SPELL_CRIT_RATING"] = "crit", ["ITEM_MOD_SPELL_POWER_SHORT"] = "spellPower", ["ITEM_MOD_SPELL_DMG_SHORT"] = "spellDamage", ["ITEM_MOD_HEALING_SHORT"] = "healing", diff --git a/Amibis/Tests/test_stats.lua b/Amibis/Tests/test_stats.lua index 1eb5475..4337aef 100644 --- a/Amibis/Tests/test_stats.lua +++ b/Amibis/Tests/test_stats.lua @@ -61,6 +61,46 @@ describe("ScanItemStats", function() 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",