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
+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
|
||||
|
||||
Reference in new issue
Block a user