Add per-spec stat scoring and top upgrades computation
This commit is contained in:
@@ -16,6 +16,50 @@ local DEFAULT_AMIBIS_CHAR_DB = {
|
||||
overrideSpec = nil,
|
||||
}
|
||||
|
||||
local TOP_UPGRADES_COUNT = 3
|
||||
|
||||
local UPGRADE_STAT_KEYS = {
|
||||
["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" },
|
||||
},
|
||||
["DRUID"] = {
|
||||
["Balance"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
},
|
||||
["PALADIN"] = {
|
||||
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
},
|
||||
["SHAMAN"] = {
|
||||
["Elemental"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
||||
},
|
||||
["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" },
|
||||
},
|
||||
["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" },
|
||||
},
|
||||
}
|
||||
|
||||
local DEFAULT_UPGRADE_STAT_KEYS = { "spellPower", "intellect", "spirit", "mp5", "haste", "crit" }
|
||||
|
||||
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]
|
||||
end
|
||||
return DEFAULT_UPGRADE_STAT_KEYS
|
||||
end
|
||||
|
||||
function Amibis:GetStatKeysForSpec(class, spec)
|
||||
return GetUpgradeStatKeys(class, spec)
|
||||
end
|
||||
|
||||
local function InitializeDB()
|
||||
if not AmibisDB then
|
||||
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
||||
@@ -139,6 +183,11 @@ local STAT_MAP = {
|
||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
||||
}
|
||||
|
||||
local MAX_AGGREGATE_STATS = {
|
||||
healing = true,
|
||||
spellDamage = true,
|
||||
}
|
||||
|
||||
function Amibis:ScanItemStats(itemID)
|
||||
if not itemID then return nil end
|
||||
|
||||
@@ -152,8 +201,16 @@ function Amibis:ScanItemStats(itemID)
|
||||
|
||||
local result = {}
|
||||
for wowKey, ourKey in pairs(STAT_MAP) do
|
||||
if stats[wowKey] then
|
||||
result[ourKey] = (result[ourKey] or 0) + stats[wowKey]
|
||||
local value = stats[wowKey]
|
||||
if value then
|
||||
if MAX_AGGREGATE_STATS[ourKey] then
|
||||
local current = result[ourKey]
|
||||
if not current or value > current then
|
||||
result[ourKey] = value
|
||||
end
|
||||
else
|
||||
result[ourKey] = (result[ourKey] or 0) + value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -202,7 +259,7 @@ function Amibis:CompareGear()
|
||||
slots = {},
|
||||
bisCount = 0,
|
||||
totalSlots = 0,
|
||||
biggestUpgrade = nil,
|
||||
topUpgrades = {},
|
||||
}
|
||||
end
|
||||
|
||||
@@ -210,7 +267,7 @@ function Amibis:CompareGear()
|
||||
local slots = {}
|
||||
local bisCount = 0
|
||||
local totalSlots = 0
|
||||
local biggestUpgrade = nil
|
||||
local allUpgrades = {}
|
||||
|
||||
for slotName, bisItem in pairs(bisList) do
|
||||
totalSlots = totalSlots + 1
|
||||
@@ -222,47 +279,48 @@ function Amibis:CompareGear()
|
||||
bisCount = bisCount + 1
|
||||
end
|
||||
|
||||
local itemLevelDiff = nil
|
||||
if equippedItem and not isBIS then
|
||||
local equippedILvl = GetItemInfo(equippedItem.itemID) and select(4, GetItemInfo(equippedItem.itemID))
|
||||
local bisILvl = GetItemInfo(bisItem.itemID) and select(4, GetItemInfo(bisItem.itemID))
|
||||
if equippedILvl and bisILvl then
|
||||
itemLevelDiff = bisILvl - equippedILvl
|
||||
end
|
||||
end
|
||||
|
||||
if not isBIS and equippedItem then
|
||||
if not biggestUpgrade or (itemLevelDiff and biggestUpgrade.itemLevelDiff and itemLevelDiff > biggestUpgrade.itemLevelDiff) then
|
||||
biggestUpgrade = {
|
||||
slot = slotName,
|
||||
equipped = equippedItem,
|
||||
bis = bisItem,
|
||||
itemLevelDiff = itemLevelDiff,
|
||||
}
|
||||
elseif not biggestUpgrade then
|
||||
biggestUpgrade = {
|
||||
slot = slotName,
|
||||
equipped = equippedItem,
|
||||
bis = bisItem,
|
||||
itemLevelDiff = itemLevelDiff,
|
||||
}
|
||||
end
|
||||
elseif not isBIS and not biggestUpgrade then
|
||||
biggestUpgrade = {
|
||||
slot = slotName,
|
||||
equipped = nil,
|
||||
bis = bisItem,
|
||||
itemLevelDiff = nil,
|
||||
}
|
||||
end
|
||||
|
||||
table.insert(slots, {
|
||||
slotName = slotName,
|
||||
equipped = equippedItem,
|
||||
bis = bisItem,
|
||||
isBIS = isBIS,
|
||||
itemLevelDiff = itemLevelDiff,
|
||||
})
|
||||
|
||||
if not isBIS then
|
||||
local statDiffs = {}
|
||||
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
|
||||
local diff = (bisStats[statKey] or 0) - (equippedStats[statKey] or 0)
|
||||
if diff > 0 then
|
||||
statDiffs[statKey] = diff
|
||||
score = score + diff
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(allUpgrades, {
|
||||
slot = slotName,
|
||||
equipped = equippedItem,
|
||||
bis = bisItem,
|
||||
statDiffs = statDiffs,
|
||||
score = score,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(allUpgrades, function(a, b)
|
||||
if a.score ~= b.score then
|
||||
return a.score > b.score
|
||||
end
|
||||
return a.slot < b.slot
|
||||
end)
|
||||
|
||||
local topUpgrades = {}
|
||||
for i = 1, math.min(TOP_UPGRADES_COUNT, #allUpgrades) do
|
||||
table.insert(topUpgrades, allUpgrades[i])
|
||||
end
|
||||
|
||||
table.sort(slots, function(a, b)
|
||||
@@ -307,7 +365,7 @@ function Amibis:CompareGear()
|
||||
slots = slots,
|
||||
bisCount = bisCount,
|
||||
totalSlots = totalSlots,
|
||||
biggestUpgrade = biggestUpgrade,
|
||||
topUpgrades = topUpgrades,
|
||||
equippedStats = equippedStats,
|
||||
bisStats = bisStats,
|
||||
statsComplete = statsComplete,
|
||||
|
||||
Reference in New Issue
Block a user