Bagnon

Bagnon

122M Downloads

4.3.3 enhancement total sum of items over all chars on server

JoeInch opened this issue ยท 0 comments

commented

a) change function formatcounts to return total as 2nd number

    return color:format(total) .. ' ' .. SILVER:format('('.. text:sub(3) .. ')'), total

b) change addowners to calculate item sum over chars and count players who have current item. Add Total Line at the end. 'Total' should come from localization files. ( DEde = 'Gesamt' )

local function AddOwners(tooltip, link)
local id = link and link:match('item:(%d+)')
local total = 0
local playercount = 0
if not id or id == HEARTHSTONE then
return
end

for i, player in ItemCache:IteratePlayers() do
    local class = ItemCache:GetPlayerInfo(player)
    local countText = Items[player][id]
    local color = GetColor(class)
    local subtotal

    if countText ~= false then
        countText, subtotal = FormatCounts(color, ItemCache:GetItemCounts(player, id))

        if ItemCache:IsPlayerCached(player) then
            Items[player][id] = countText or false
        end
    end

    if countText then
        tooltip:AddDoubleLine(color:format(player), countText)
        total = total + subtotal
        playercount = playercount + 1
    end
end
if playercount > 1 then
    tooltip:AddDoubleLine('Total', total)
end

tooltip:Show()

end