From 1c79240b58caab5f16e9caf21475813658bd1cfe Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Mon, 29 Nov 2010 20:51:45 +0000 Subject: [PATCH] Normalize scores, same as StatScores --- WowheadPoints.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/WowheadPoints.lua b/WowheadPoints.lua index d23e373..335876f 100644 --- a/WowheadPoints.lua +++ b/WowheadPoints.lua @@ -389,12 +389,20 @@ local function GetWeights(link) local scores = {} for wname, info in pairs(info[class]) do - local stats = GetItemStats(link) if not link then return scores end + + local stats = GetItemStats(link) + if not stats then + return scores + end + + local total = 0 local score = 0 for stat, weight in pairs(info.weights) do + total = total + weight + local key, value if stat == "ARMOR" then @@ -415,7 +423,7 @@ local function GetWeights(link) score = score + value * weight end - scores[wname] = score + scores[wname] = score / total end return scores @@ -448,7 +456,8 @@ local function OnTooltipSetItem(tooltip, ...) tooltip:AddLine(" ") tooltip:AddLine("Equipment ratings from Wowhead.com:") for idx, name in ipairs(sort) do - tooltip:AddDoubleLine(name .. ":", math.floor(scores[name]), 1.0, 1.0, 1.0) + local val = string.format("%0.2f", scores[name]) + tooltip:AddDoubleLine(name .. ":", val, 1.0, 1.0, 1.0) end tooltip:AddLine(" ") end @@ -472,3 +481,43 @@ for idx, tooltip in ipairs(tooltips) do tooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) tooltip:HookScript("OnTooltipCleared", OnTooltipCleared) end + +function addon:Enable() + -- Calculate the player's 'WowheadGearScore' + local slotNames = { + "BackSlot", + "ChestSlot", + "FeetSlot", + "Finger0Slot", + "Finger1Slot", + "HeadSlot", + "HandsSlot", + "LegsSlot", + "NeckSlot", + "RangedSlot", + "ShoulderSlot", + "Trinket0Slot", + "Trinket1Slot", + "WaistSlot", + "WristSlot", + "MainHandSlot", + "SecondaryHandSlot", + } + + -- local gscores = {} + -- for idx, slotName in ipairs(slotNames) do + -- local slotNum = GetInventorySlotInfo(slotName) + -- local link = GetInventoryItemLink("player", slotNum) + -- if link then + -- local scores = GetWeights(link) + -- for name, score in pairs(scores) do + -- if not gscores[name] then gscores[name] = 0 end + -- gscores[name] = gscores[name] + score + -- end + -- end + -- end + + -- for name, score in pairs(gscores) do + -- self:Printf("Your '%s' gearscore is %d", name, score) + -- end +end -- 1.7.9.5