Goldbeutel: freie Taschenplätze, Rüstungszustand und Gegenstandsstufe

Der Rahmen zeigt jetzt in einer Zeile Gold, freie Taschenplätze, den
Zustand des am stärksten beschädigten Teils und die durchschnittliche
Gegenstandsstufe der angelegten Ausrüstung. Spezialtaschen zählen nicht
mit. Wenig Platz oder niedriger Zustand werden gelb bzw. rot.

Der Tooltip zeigt zusätzlich Spezialtaschen, den Gesamtzustand der
Rüstung samt schwächstem Teil und die Gegenstandsstufe mit bester
Ausrüstung aus den Taschen. Mehrere Ereignisse kurz hintereinander lösen
nur eine Aktualisierung aus.

Tests für die neue Anzeige ergänzt, ZIP neu gebaut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-11-24 12:18:46 +01:00
1 parent 4959c470c1
commit 3065c3e70e
4 files changed
+212 -11

No files matched your search

+59 -2
View File
@@ -8,7 +8,16 @@ local noop = function() end
local function obj(t) return setmetatable(t or {}, {__index = function() return noop end}) end
---------------------------------------------------------------- Goldbeutel
local money, ev, lines
local money, ev, lines, shownText, gtimers
-- Ausgangszustand fuer Taschen, Ruestung und Gegenstandsstufe (in Tests veraenderbar)
-- bags[i] = { Plaetze, frei, Taschentyp }; Index 0 = Rucksack, 5 = Reagenzientasche
local bags, dura, ilvl
local function defaultGear()
bags = { [0] = {16, 5, 0}, {20, 10, 0}, {16, 16, 1}, {0, 0, 0}, {20, 8, 0}, {36, 30, 0} }
dura = { [1] = {45, 100}, [5] = {100, 100}, [7] = {80, 80} } -- Kopf, Brust, Beine
ilvl = {247.14, 245.34} -- beste, angelegt
end
defaultGear()
local function startGold(name, db)
GoldbeutelDB = db
print = noop
@@ -18,6 +27,16 @@ local function startGold(name, db)
UnitName = function() return name end
UnitClass = function() return "Magier", "MAGE" end
GetMoney = function() return money end
NUM_BAG_SLOTS, NUM_TOTAL_EQUIPPED_BAG_SLOTS, INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED = 4, 5, 1, 19
C_Container = {
GetContainerNumSlots = function(b) return bags[b] and bags[b][1] or 0 end,
GetContainerNumFreeSlots = function(b) if bags[b] then return bags[b][2], bags[b][3] end return 0, 0 end,
}
GetInventoryItemDurability = function(s) if dura[s] then return dura[s][1], dura[s][2] end end
GetInventoryItemLink = function(_, s) return "[Item" .. s .. "]" end
GetAverageItemLevel = function() return ilvl[1], ilvl[2] end
gtimers = {}
C_Timer = { After = function(_, fn) gtimers[#gtimers + 1] = fn end }
UIParent = obj{ GetHeight = function() return 800 end }
lines = {}
GameTooltip = obj{ AddDoubleLine = function(_, l, r) lines[l] = r end, IsOwned = function() return false end }
@@ -28,7 +47,8 @@ local function startGold(name, db)
GetCenter = function() return 500, 300 end,
SetShown = function(self, v) self.shown = v end,
IsShown = function(self) return self.shown end,
CreateFontString = function() return obj{ GetStringWidth = function() return 80 end, GetStringHeight = function() return 12 end } end }
CreateFontString = function() return obj{ SetText = function(_, t) shownText = t end,
GetStringWidth = function() return 80 end, GetStringHeight = function() return 12 end } end }
frames[#frames + 1] = f
return f
end
@@ -68,6 +88,43 @@ SlashCmdList.GOLDBEUTEL("forget ÉLODIE"); check("ÉLODIE -> Élodie entfernt",
SlashCmdList.GOLDBEUTEL("forget öx×y"); check("öx×y -> Öx×y entfernt (× unveraendert)", chars["Öx×y"] == nil)
SlashCmdList.GOLDBEUTEL("forget testmagier"); check("Eigener Charakter bleibt", chars.Testmagier ~= nil)
out("Goldbeutel: Taschen, Ruestung, Gegenstandsstufe")
local function flush() while #gtimers > 0 do table.remove(gtimers, 1)() end end
local function plain(s) return (s:gsub("|T.-|t", ""):gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):gsub("||", "|")) end
defaultGear(); money = 1234567
fr = startGold("Testmagier", nil); ev.scripts.OnEvent(ev, "PLAYER_ENTERING_WORLD", true, false); flush()
check("Rahmen: eine Zeile mit allen vier Werten",
plain(shownText) == "123 45 67 | Taschen 23 | 45% | iLvl 245")
check("Spezialtaschen (Koecher, Reagenzientasche) nicht im Rahmen mitgezaehlt", plain(shownText):find("Taschen 23", 1, true))
check("45% gelb (unter 50)", shownText:find("|cffffd10045%|r", 1, true) ~= nil)
check("23 freie Plaetze ohne Warnfarbe", shownText:find("|r 23", 1, true) ~= nil)
lines = {}; fr.scripts.OnEnter(fr)
check("Tooltip: Taschen frei 23 / 56", lines["Taschen frei:"] == "23 / 56")
check("Tooltip: Spezialtaschen frei 46 / 52", lines["Spezialtaschen frei:"] == "46 / 52")
check("Tooltip: Ruestung gesamt 80% (225/280)", lines["Rüstung gesamt:"] == "80%")
check("Tooltip: am staerksten beschaedigtes Teil (Kopf) mit 45%", plain(lines[" [Item1]"] or "") == "45%")
check("Tooltip: Gegenstandsstufe 245,3", lines["Gegenstandsstufe:"] == "245,3")
check("Tooltip: beste Ausruestung 247,1", lines["Beste Ausrüstung:"] == "247,1")
bags[0][2], bags[1][2], bags[4][2] = 0, 3, 0; dura[1][1] = 10
for _ = 1, 3 do ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED") end
ev.scripts.OnEvent(ev, "UPDATE_INVENTORY_DURABILITY")
check("Mehrere Ereignisse -> nur eine Aktualisierung", #gtimers == 1)
flush()
check("3 freie Plaetze gelb", shownText:find("|cffffd1003|r", 1, true) ~= nil)
check("10% rot", shownText:find("|cffff333310%|r", 1, true) ~= nil)
bags[1][2] = 0; ev.scripts.OnEvent(ev, "BAG_UPDATE_DELAYED"); flush()
check("0 freie Plaetze rot", shownText:find("|cffff33330|r", 1, true) ~= nil)
dura = {}; ilvl = {0, 0}; ev.scripts.OnEvent(ev, "PLAYER_EQUIPMENT_CHANGED"); flush()
check("Ohne Haltbarkeit und ohne iLvl nur Gold und Taschen", plain(shownText) == "123 45 67 | Taschen 0")
lines = {}; fr.scripts.OnEnter(fr)
check("Tooltip ohne Ruestungs- und iLvl-Zeilen", lines["Rüstung gesamt:"] == nil and lines["Gegenstandsstufe:"] == nil)
dura = { [1] = {50, 50} }; ilvl = {245.34, 245.34}; ev.scripts.OnEvent(ev, "PLAYER_AVG_ITEM_LEVEL_UPDATE"); flush()
lines = {}; fr.scripts.OnEnter(fr)
check("Alles heil: keine Zeile fuer beschaedigtes Teil", lines[" [Item1]"] == nil and lines["Rüstung gesamt:"] == "100%")
check("Beste = angelegt: keine Zeile 'Beste Ausruestung'", lines["Beste Ausrüstung:"] == nil)
---------------------------------------------------------------- ForeverScale
local scale, h, combat, timers, f
local function startScale(db)