883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
117 lines
6.3 KiB
Lua
117 lines
6.3 KiB
Lua
-- Synthetic native API timing only; no client, chat transmission or name data.
|
|
local frames, messages, requests, states, timers = {}, {}, {}, {}, {}
|
|
local containerLink
|
|
LOOT_ITEM_SELF = "You receive loot: %s."
|
|
LOOT_ITEM_SELF_MULTIPLE = "You receive loot: %sx%d."
|
|
LOOT_ROLL_ROLLED_NEED = "|HlootHistory:%d|h[Loot]|h: Need Roll - %d for %s by %s"
|
|
LOOT_ROLL_ROLLED_GREED = "|HlootHistory:%d|h[Loot]|h: Greed Roll - %d for %s by %s"
|
|
LOOT_ROLL_YOU_WON = "|HlootHistory:%d|h[Loot]|h: You won: %s"
|
|
LOOT_ROLL_WON = "|HlootHistory:%d|h[Loot]|h: %s won: %s"
|
|
CHAT_FRAMES = {"ChatFrame1"}
|
|
ChatFrame1 = {
|
|
ContainsMessageGroup = function(_, group) return group == "LOOT" end,
|
|
MessageEventHandler = function(_, event, message)
|
|
assert(event == "CHAT_MSG_LOOT"); messages[#messages + 1] = message
|
|
end,
|
|
}
|
|
CreateFrame = function()
|
|
local frame = {events = {}, RegisterEvent = function(self, event) self.events[event] = true end,
|
|
SetScript = function(self, script, callback) assert(script == "OnEvent"); self.callback = callback end}
|
|
frames[#frames + 1] = frame; return frame
|
|
end
|
|
ChatFrameUtil = {AddMessageEventFilter = function() end}
|
|
C_Container = {GetContainerItemLink = function() return containerLink end}
|
|
C_Item = {
|
|
GetItemInfo = function(id) local row = states[id]; if row then return row.name, row.link end end,
|
|
RequestLoadItemDataByID = function(id) requests[id] = (requests[id] or 0) + 1 end,
|
|
}
|
|
C_Timer = {After = function(delay, callback) assert(delay == 0); timers[#timers + 1] = callback end}
|
|
local api = dofile(arg[1] or "client_addons/WoWHybridUI/NativeLootReceipts.lua")
|
|
local function event(name, id, success) frames[1].callback(frames[1], name, id, success) end
|
|
local function nextFrame()
|
|
local callbacks = timers; timers = {}
|
|
for _, callback in ipairs(callbacks) do callback() end
|
|
end
|
|
local function receipt(sequence, id) api.receive("GWLOOT1 R 1:" .. sequence .. " " .. id .. " 1 0 1") end
|
|
local function link(id, label, extra) return "|cff1eff00|Hitem:" .. id .. (extra or "") .. "|h[" .. label .. "]|h|r" end
|
|
|
|
-- A genuine-ID cold native link exists before the name. It must remain pending.
|
|
containerLink = link(10001, "")
|
|
states[10001] = {name = "", link = containerLink}
|
|
receipt(1, 10001)
|
|
assert(#messages == 0, "cold [] container link was irreversibly displayed")
|
|
assert(requests[10001] == 1)
|
|
receipt(1, 10001); event("GET_ITEM_INFO_RECEIVED", 10001, false)
|
|
assert(#messages == 0 and requests[10001] == 1)
|
|
-- Name/API callback can arrive while the bound instance hyperlink is still cold.
|
|
states[10001] = {name = "Fixture Blade", link = link(10001, "Fixture Blade")}
|
|
event("GET_ITEM_INFO_RECEIVED", 10001, true)
|
|
assert(#messages == 0, "base link replaced an unresolved bound instance")
|
|
containerLink = link(10001, "Fixture Blade of Testing", ":0:0:0:0:0:7")
|
|
event("BAG_UPDATE_DELAYED")
|
|
assert(#messages == 1 and messages[1] == "You receive loot: " .. containerLink .. ".")
|
|
receipt(1, 10001); event("ITEM_DATA_LOAD_RESULT", 10001, true)
|
|
assert(#messages == 1, "completed cold receipt was duplicated")
|
|
|
|
-- The fallback API can return an empty or whitespace label before item metadata.
|
|
containerLink = nil
|
|
states[10002] = {name = "Fixture Shield", link = link(10002, " ")}
|
|
receipt(2, 10002); assert(#messages == 1 and requests[10002] == 1)
|
|
states[10002].link = link(10002, "Fixture Shield")
|
|
event("ITEM_DATA_LOAD_RESULT", 10002, true)
|
|
assert(#messages == 2 and messages[2]:find("[Fixture Shield]", 1, true))
|
|
|
|
-- A ready bound native instance is independently sufficient; do not require a
|
|
-- second base-item cache or lose its enchant/random-property hyperlink fields.
|
|
containerLink = link(10003, "Fixture Ring of Testing", ":0:0:0:0:0:19")
|
|
states[10003] = nil
|
|
receipt(3, 10003)
|
|
assert(#messages == 3 and messages[3] == "You receive loot: " .. containerLink .. ".")
|
|
assert(requests[10003] == nil)
|
|
|
|
-- Wrong identity and missing fallback names never produce a receipt.
|
|
containerLink = link(19999, "Unrelated")
|
|
states[10004] = {name = "", link = link(10004, "")}
|
|
receipt(4, 10004); assert(#messages == 3 and requests[10004] == 1)
|
|
states[10004] = {name = "Fixture Helm", link = link(19999, "Unrelated")}
|
|
event("GET_ITEM_INFO_RECEIVED", 10004, true); assert(#messages == 3)
|
|
states[10004].link = link(10004, "Fixture Helm")
|
|
event("GET_ITEM_INFO_RECEIVED", 10004, true); assert(#messages == 4)
|
|
|
|
-- The same name-readiness rule covers numeric roll notices and winners.
|
|
containerLink = nil; states[10005] = {name = "", link = link(10005, "")}
|
|
api.receive("GWLOOT1 N 1:1:0:1 10005 42 1 1 Fixture")
|
|
api.receive("GWLOOT1 W 1:1:0:1 10005 42 1 1 Fixture")
|
|
assert(#messages == 4 and requests[10005] == 1)
|
|
states[10005] = {name = "Fixture Staff", link = link(10005, "Fixture Staff")}
|
|
event("ITEM_DATA_LOAD_RESULT", 10005, true)
|
|
assert(#messages == 6 and messages[5]:find("Need Roll - 42", 1, true) and messages[6]:find("You won:", 1, true))
|
|
api.flush(); assert(#messages == 6)
|
|
nextFrame(); assert(#timers == 0)
|
|
-- Genuine native metadata event can precede its last cache mutation. A single
|
|
-- coalesced next-frame revisit must observe the now-ready original API value.
|
|
states[10006] = {name = "", link = link(10006, "")}
|
|
receipt(6, 10006); assert(#messages == 6 and requests[10006] == 1)
|
|
event("ITEM_DATA_LOAD_RESULT", 10006, true)
|
|
event("GET_ITEM_INFO_RECEIVED", 10006, true)
|
|
assert(#timers == 1 and #messages == 6)
|
|
states[10006] = {name = "Fixture Boots", link = link(10006, "Fixture Boots")}
|
|
nextFrame(); assert(#messages == 7 and #timers == 0)
|
|
api.flush(); nextFrame(); assert(#messages == 7)
|
|
-- A failed request stays quiet until another genuine receipt needs the item.
|
|
containerLink = nil
|
|
receipt(7, 93223)
|
|
event("ITEM_DATA_LOAD_RESULT", 93223, false)
|
|
nextFrame()
|
|
receipt(7, 93223)
|
|
assert(requests[93223] == 1 and #messages == 7)
|
|
receipt(8, 93223)
|
|
assert(requests[93223] == 2)
|
|
states[93223] = {name = "Simple Bronze Katana", link = link(93223, "Simple Bronze Katana")}
|
|
event("ITEM_DATA_LOAD_RESULT", 93223, true)
|
|
nextFrame()
|
|
assert(#messages == 9 and messages[8] == messages[9] and messages[8]:find("[Simple Bronze Katana]", 1, true))
|
|
assert(frames[1].events.BAG_UPDATE_DELAYED)
|
|
for _, message in ipairs(messages) do assert(not message:find("|h[]|h", 1, true)) end
|
|
print("PASS cold blank/whitespace names held; native instance identity retained; item/bag events and coalesced next-frame cache readiness release exactly once; ready cache unchanged; roll/winner shared")
|