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:
1 parent
e08e288f73
commit
b66491c5be
7 files changed
+300
-60
No files matched your search
@@ -40,4 +40,5 @@ Amibis/
|
||||
- ElvUI-style dark backdrop (`{0.07, 0.07, 0.07}`, alpha 0.95)
|
||||
- Color coding: green = BIS, yellow = upgrade available, gray = empty slot
|
||||
- Max 17 visible rows; rows are clickable (Shift+click = chat link, Ctrl+click = dress-up)
|
||||
- Stats panel shows: Healing, Spell Power, Intellect, Spirit, MP5, Haste, Crit
|
||||
- Stats panel is **per-spec**: `SPEC_STAT_PROFILES` in `Amibis.lua` defines an ordered `{ stat, weight }` list for every class/spec (casters see spell damage/hit/crit/haste, melee see strength/AP/hit/expertise/armor pen, tanks see stamina/defense/dodge/parry/block, healers see healing/spirit/mp5). The same weights rank top upgrades, score completion, and pick which two gains are shown in the upgrade line. Keep profiles to 8 rows so the panel fits the frame.
|
||||
- Stat values are read via `STAT_MAP` (WoW `GetItemStats` keys → internal stat names); TBC's per-school hit/crit/haste keys are all mapped to one internal stat.
|
||||
+126
-34
@@ -18,66 +18,101 @@ local DEFAULT_AMIBIS_CHAR_DB = {
|
||||
|
||||
local TOP_UPGRADES_COUNT = 3
|
||||
|
||||
local UPGRADE_STAT_KEYS = {
|
||||
-- Per-spec stat priorities. Each entry is { statKey, weight } in display order:
|
||||
-- the panel shows every listed stat, and the weight drives upgrade scoring and
|
||||
-- the completion ratio, so each spec is measured by what actually matters to it.
|
||||
local SPEC_STAT_PROFILES = {
|
||||
["PRIEST"] = {
|
||||
["Discipline"] = { "healing", "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Shadow"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Discipline"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
|
||||
["Holy"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
|
||||
["Shadow"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
|
||||
},
|
||||
["DRUID"] = {
|
||||
["Balance"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Balance"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
|
||||
["Feral Combat"] = { { "attackPower", 3 }, { "strength", 2 }, { "agility", 2 }, { "feralAttackPower", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "armorPen", 1 } },
|
||||
["Restoration"] = { { "healing", 3 }, { "intellect", 2 }, { "spirit", 2 }, { "mp5", 2 }, { "haste", 2 }, { "crit", 1 } },
|
||||
},
|
||||
["PALADIN"] = {
|
||||
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Holy"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
|
||||
["Protection"] = { { "stamina", 3 }, { "armor", 2 }, { "defense", 2 }, { "dodge", 2 }, { "parry", 2 }, { "spellDamage", 2 }, { "block", 1 }, { "hit", 1 } },
|
||||
["Retribution"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "haste", 1 }, { "armorPen", 1 }, { "agility", 1 } },
|
||||
},
|
||||
["SHAMAN"] = {
|
||||
["Elemental"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Elemental"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "mp5", 1 }, { "stamina", 1 } },
|
||||
["Enhancement"] = { { "attackPower", 3 }, { "strength", 2 }, { "agility", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 } },
|
||||
["Restoration"] = { { "healing", 3 }, { "intellect", 2 }, { "spirit", 2 }, { "mp5", 2 }, { "haste", 2 }, { "crit", 1 } },
|
||||
},
|
||||
["MAGE"] = {
|
||||
["Arcane"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Fire"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Frost"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Arcane"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||
["Fire"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||
["Frost"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||
},
|
||||
["WARLOCK"] = {
|
||||
["Affliction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Demonology"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Destruction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Affliction"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
|
||||
["Demonology"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
|
||||
["Destruction"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||
},
|
||||
["WARRIOR"] = {
|
||||
["Arms"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "armorPen", 1 }, { "haste", 1 }, { "stamina", 1 } },
|
||||
["Fury"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "armorPen", 1 }, { "haste", 1 }, { "stamina", 1 } },
|
||||
["Protection"] = { { "stamina", 3 }, { "armor", 2 }, { "defense", 2 }, { "dodge", 2 }, { "parry", 2 }, { "expertise", 1 }, { "block", 1 }, { "hit", 1 } },
|
||||
},
|
||||
["ROGUE"] = {
|
||||
["Assassination"] = { { "agility", 3 }, { "attackPower", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
|
||||
["Combat"] = { { "agility", 3 }, { "attackPower", 2 }, { "armorPen", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "stamina", 1 } },
|
||||
["Subtlety"] = { { "agility", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "haste", 1 }, { "stamina", 1 } },
|
||||
},
|
||||
["HUNTER"] = {
|
||||
["Beast Mastery"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
|
||||
["Marksmanship"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
|
||||
["Survival"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
|
||||
},
|
||||
}
|
||||
|
||||
local DEFAULT_UPGRADE_STAT_KEYS = { "spellPower", "intellect", "spirit", "mp5", "haste", "crit" }
|
||||
local DEFAULT_STAT_PROFILE = { { "spellDamage", 3 }, { "crit", 2 }, { "haste", 2 }, { "hit", 2 }, { "intellect", 1 } }
|
||||
|
||||
local function GetUpgradeStatKeys(class, spec)
|
||||
if class and UPGRADE_STAT_KEYS[class] and UPGRADE_STAT_KEYS[class][spec] then
|
||||
return UPGRADE_STAT_KEYS[class][spec]
|
||||
local function GetStatProfile(class, spec)
|
||||
local classProfiles = SPEC_STAT_PROFILES[class]
|
||||
if classProfiles and classProfiles[spec] then
|
||||
return classProfiles[spec]
|
||||
end
|
||||
return DEFAULT_UPGRADE_STAT_KEYS
|
||||
return DEFAULT_STAT_PROFILE
|
||||
end
|
||||
|
||||
function Amibis:GetStatKeysForSpec(class, spec)
|
||||
return GetUpgradeStatKeys(class, spec)
|
||||
local keys = {}
|
||||
for _, entry in ipairs(GetStatProfile(class, spec)) do
|
||||
table.insert(keys, entry[1])
|
||||
end
|
||||
return keys
|
||||
end
|
||||
|
||||
function Amibis:GetStatWeightsForSpec(class, spec)
|
||||
local weights = {}
|
||||
for _, entry in ipairs(GetStatProfile(class, spec)) do
|
||||
weights[entry[1]] = entry[2]
|
||||
end
|
||||
return weights
|
||||
end
|
||||
|
||||
function Amibis:StatRatio(equippedStats, bisStats, class, spec)
|
||||
if not equippedStats or not bisStats then return 0 end
|
||||
|
||||
local statKeys = GetUpgradeStatKeys(class, spec)
|
||||
local count, sum = 0, 0
|
||||
for _, statKey in ipairs(statKeys) do
|
||||
local weightSum, sum = 0, 0
|
||||
for _, entry in ipairs(GetStatProfile(class, spec)) do
|
||||
local statKey, weight = entry[1], entry[2]
|
||||
local bis = bisStats[statKey] or 0
|
||||
if bis > 0 then
|
||||
local current = equippedStats[statKey] or 0
|
||||
local ratio = current / bis
|
||||
if ratio > 1 then ratio = 1 end
|
||||
sum = sum + ratio
|
||||
count = count + 1
|
||||
sum = sum + ratio * weight
|
||||
weightSum = weightSum + weight
|
||||
end
|
||||
end
|
||||
|
||||
if count == 0 then return 0 end
|
||||
return sum / count
|
||||
if weightSum == 0 then return 0 end
|
||||
return sum / weightSum
|
||||
end
|
||||
|
||||
function Amibis:GetCompletionRatio(data)
|
||||
@@ -228,16 +263,55 @@ local STAT_MAP = {
|
||||
["ITEM_MOD_SPELL_POWER_SHORT"] = "spellPower",
|
||||
["ITEM_MOD_SPELL_DMG_SHORT"] = "spellDamage",
|
||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
||||
-- Physical stats (TBC uses per-school hit ratings; take the applicable one).
|
||||
["ITEM_MOD_ATTACK_POWER_SHORT"] = "attackPower",
|
||||
["ITEM_MOD_ATTACK_POWER"] = "attackPower",
|
||||
["ITEM_MOD_RANGED_ATTACK_POWER_SHORT"] = "rangedAttackPower",
|
||||
["ITEM_MOD_RANGED_ATTACK_POWER"] = "rangedAttackPower",
|
||||
["ITEM_MOD_FERAL_ATTACK_POWER_SHORT"] = "feralAttackPower",
|
||||
["ITEM_MOD_FERAL_ATTACK_POWER"] = "feralAttackPower",
|
||||
["ITEM_MOD_STRENGTH_SHORT"] = "strength",
|
||||
["ITEM_MOD_STRENGTH"] = "strength",
|
||||
["ITEM_MOD_AGILITY_SHORT"] = "agility",
|
||||
["ITEM_MOD_AGILITY"] = "agility",
|
||||
["ITEM_MOD_HIT_RATING_SHORT"] = "hit",
|
||||
["ITEM_MOD_HIT_RATING"] = "hit",
|
||||
["ITEM_MOD_HIT_MELEE_RATING_SHORT"] = "hit",
|
||||
["ITEM_MOD_HIT_MELEE_RATING"] = "hit",
|
||||
["ITEM_MOD_HIT_RANGED_RATING_SHORT"] = "hit",
|
||||
["ITEM_MOD_HIT_RANGED_RATING"] = "hit",
|
||||
["ITEM_MOD_HIT_SPELL_RATING_SHORT"] = "hit",
|
||||
["ITEM_MOD_HIT_SPELL_RATING"] = "hit",
|
||||
["ITEM_MOD_EXPERTISE_RATING_SHORT"] = "expertise",
|
||||
["ITEM_MOD_EXPERTISE_RATING"] = "expertise",
|
||||
["ITEM_MOD_ARMOR_PENETRATION_RATING_SHORT"] = "armorPen",
|
||||
["ITEM_MOD_ARMOR_PENETRATION_RATING"] = "armorPen",
|
||||
["ITEM_MOD_DEFENSE_SKILL_RATING_SHORT"] = "defense",
|
||||
["ITEM_MOD_DEFENSE_SKILL_RATING"] = "defense",
|
||||
["ITEM_MOD_DODGE_RATING_SHORT"] = "dodge",
|
||||
["ITEM_MOD_DODGE_RATING"] = "dodge",
|
||||
["ITEM_MOD_PARRY_RATING_SHORT"] = "parry",
|
||||
["ITEM_MOD_PARRY_RATING"] = "parry",
|
||||
["ITEM_MOD_BLOCK_RATING_SHORT"] = "block",
|
||||
["ITEM_MOD_BLOCK_RATING"] = "block",
|
||||
["ITEM_MOD_BLOCK_VALUE_SHORT"] = "blockValue",
|
||||
["ITEM_MOD_BLOCK_VALUE"] = "blockValue",
|
||||
["ITEM_MOD_RESILIENCE_RATING_SHORT"] = "resilience",
|
||||
["ITEM_MOD_RESILIENCE_RATING"] = "resilience",
|
||||
-- Classic reports armor under RESISTANCE0_NAME; later clients use ITEM_MOD_ARMOR.
|
||||
["RESISTANCE0_NAME"] = "armor",
|
||||
["ITEM_MOD_ARMOR"] = "armor",
|
||||
}
|
||||
|
||||
-- Stats that multiple WoW API keys map to (school-specific spell damage, haste
|
||||
-- rating, etc.): only one alias is ever active, so take MAX instead of SUM.
|
||||
-- Stats that multiple WoW API keys map to (school-specific spell damage, hit,
|
||||
-- haste, crit, etc.): only one alias is ever active, so take MAX instead of SUM.
|
||||
local ALIAS_STATS = {
|
||||
healing = true,
|
||||
spellDamage = true,
|
||||
mp5 = true,
|
||||
haste = true,
|
||||
crit = true,
|
||||
hit = true,
|
||||
}
|
||||
|
||||
function Amibis:ScanItemStats(itemID)
|
||||
@@ -273,13 +347,28 @@ function Amibis:AggregateStats(items)
|
||||
local totals = {
|
||||
healing = 0,
|
||||
spellDamage = 0,
|
||||
spellPower = 0,
|
||||
intellect = 0,
|
||||
spirit = 0,
|
||||
stamina = 0,
|
||||
mp5 = 0,
|
||||
haste = 0,
|
||||
crit = 0,
|
||||
spellPower = 0,
|
||||
hit = 0,
|
||||
attackPower = 0,
|
||||
rangedAttackPower = 0,
|
||||
feralAttackPower = 0,
|
||||
strength = 0,
|
||||
agility = 0,
|
||||
expertise = 0,
|
||||
armorPen = 0,
|
||||
defense = 0,
|
||||
dodge = 0,
|
||||
parry = 0,
|
||||
block = 0,
|
||||
blockValue = 0,
|
||||
armor = 0,
|
||||
resilience = 0,
|
||||
}
|
||||
|
||||
for slotName, item in pairs(items) do
|
||||
@@ -320,6 +409,8 @@ function Amibis:CompareGear()
|
||||
local bisCount = 0
|
||||
local totalSlots = 0
|
||||
local allUpgrades = {}
|
||||
local statProfile = GetStatProfile(class, spec)
|
||||
local statWeights = self:GetStatWeightsForSpec(class, spec)
|
||||
|
||||
for slotName, bisItem in pairs(bisList) do
|
||||
totalSlots = totalSlots + 1
|
||||
@@ -343,13 +434,13 @@ function Amibis:CompareGear()
|
||||
local score = 0
|
||||
local equippedStats = (equippedItem and self:ScanItemStats(equippedItem.itemID)) or {}
|
||||
local bisStats = self:ScanItemStats(bisItem.itemID) or {}
|
||||
local upgradeStatKeys = GetUpgradeStatKeys(class, spec)
|
||||
|
||||
for _, statKey in ipairs(upgradeStatKeys) do
|
||||
for _, entry in ipairs(statProfile) do
|
||||
local statKey = entry[1]
|
||||
local diff = (bisStats[statKey] or 0) - (equippedStats[statKey] or 0)
|
||||
if diff > 0 then
|
||||
statDiffs[statKey] = diff
|
||||
score = score + diff
|
||||
score = score + diff * entry[2]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -358,6 +449,7 @@ function Amibis:CompareGear()
|
||||
equipped = equippedItem,
|
||||
bis = bisItem,
|
||||
statDiffs = statDiffs,
|
||||
statWeights = statWeights,
|
||||
score = score,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,12 +201,61 @@ 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -249,9 +249,25 @@ local STAT_LABELS = {
|
||||
spellPower = "+Spell Power",
|
||||
intellect = "Intellect",
|
||||
spirit = "Spirit",
|
||||
stamina = "Stamina",
|
||||
mp5 = "MP5",
|
||||
haste = "Haste",
|
||||
crit = "Crit",
|
||||
hit = "Hit",
|
||||
attackPower = "Attack Power",
|
||||
rangedAttackPower = "Ranged AP",
|
||||
feralAttackPower = "Feral AP",
|
||||
strength = "Strength",
|
||||
agility = "Agility",
|
||||
expertise = "Expertise",
|
||||
armorPen = "Armor Pen",
|
||||
defense = "Defense",
|
||||
dodge = "Dodge",
|
||||
parry = "Parry",
|
||||
block = "Block",
|
||||
blockValue = "Block Value",
|
||||
armor = "Armor",
|
||||
resilience = "Resilience",
|
||||
}
|
||||
|
||||
local STAT_DISPLAY_NAME = {
|
||||
@@ -260,9 +276,25 @@ local STAT_DISPLAY_NAME = {
|
||||
spellPower = "spell power",
|
||||
intellect = "intellect",
|
||||
spirit = "spirit",
|
||||
stamina = "stamina",
|
||||
mp5 = "mp5",
|
||||
haste = "haste",
|
||||
crit = "crit",
|
||||
hit = "hit",
|
||||
attackPower = "attack power",
|
||||
rangedAttackPower = "ranged AP",
|
||||
feralAttackPower = "feral AP",
|
||||
strength = "strength",
|
||||
agility = "agility",
|
||||
expertise = "expertise",
|
||||
armorPen = "armor pen",
|
||||
defense = "defense",
|
||||
dodge = "dodge",
|
||||
parry = "parry",
|
||||
block = "block",
|
||||
blockValue = "block value",
|
||||
armor = "armor",
|
||||
resilience = "resilience",
|
||||
}
|
||||
|
||||
local STATS_COL_W = 60
|
||||
@@ -291,7 +323,14 @@ local function FormatUpgradeEntry(idx, upgrade)
|
||||
for statKey, diff in pairs(upgrade.statDiffs) do
|
||||
table.insert(sorted, { key = statKey, diff = diff })
|
||||
end
|
||||
table.sort(sorted, function(a, b) return a.diff > b.diff end)
|
||||
-- Show the gains this spec cares about most, not just the biggest number.
|
||||
table.sort(sorted, function(a, b)
|
||||
local aWeight = (upgrade.statWeights and upgrade.statWeights[a.key]) or 1
|
||||
local bWeight = (upgrade.statWeights and upgrade.statWeights[b.key]) or 1
|
||||
local aValue, bValue = a.diff * aWeight, b.diff * bWeight
|
||||
if aValue ~= bValue then return aValue > bValue end
|
||||
return a.diff > b.diff
|
||||
end)
|
||||
|
||||
local parts = {}
|
||||
local maxShow = math.min(2, #sorted)
|
||||
|
||||
@@ -8,7 +8,7 @@ A World of Warcraft: The Burning Crusade Classic addon that compares your equipp
|
||||
|
||||
- **Gear Comparison** — See at a glance which slots are BIS and which can be upgraded
|
||||
- **Auto-Detection** — Automatically detects your class and active talent spec
|
||||
- **Stats Comparison** — Side-by-side stat breakdown (Healing, Spell Power, Intellect, Spirit, MP5, Haste, Crit)
|
||||
- **Stats Comparison** — Side-by-side stat breakdown tailored to your spec (spell damage/hit/crit/haste for casters, strength/AP/expertise for melee, stamina/mitigation for tanks, healing/spirit/MP5 for healers)
|
||||
- **Upgrade Highlight** — Identifies your biggest available upgrade
|
||||
- **Persistent Settings** — Window position and spec overrides saved per character
|
||||
|
||||
|
||||
Reference in new issue
Block a user