@piekasz/wow-mcp 0.0.0-stage → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/NOTICE +37 -0
- package/README.md +41 -2
- package/addon/WowMcp/AuctionTooltip.lua +106 -0
- package/addon/WowMcp/Commands.lua +259 -0
- package/addon/WowMcp/Compat.lua +167 -0
- package/addon/WowMcp/Core.lua +50 -0
- package/addon/WowMcp/Events.lua +62 -0
- package/addon/WowMcp/Items.lua +314 -0
- package/addon/WowMcp/Maps.lua +66 -0
- package/addon/WowMcp/MinimapButton.lua +114 -0
- package/addon/WowMcp/Options.lua +208 -0
- package/addon/WowMcp/Panel.lua +294 -0
- package/addon/WowMcp/QuestDb.lua +303 -0
- package/addon/WowMcp/QuestRewards.lua +137 -0
- package/addon/WowMcp/Sections/ActionBars.lua +54 -0
- package/addon/WowMcp/Sections/Auctions.lua +305 -0
- package/addon/WowMcp/Sections/Bank.lua +48 -0
- package/addon/WowMcp/Sections/Buyback.lua +47 -0
- package/addon/WowMcp/Sections/Character.lua +177 -0
- package/addon/WowMcp/Sections/Cooldowns.lua +76 -0
- package/addon/WowMcp/Sections/Currencies.lua +47 -0
- package/addon/WowMcp/Sections/Deaths.lua +43 -0
- package/addon/WowMcp/Sections/Dungeons.lua +117 -0
- package/addon/WowMcp/Sections/EquipmentSets.lua +83 -0
- package/addon/WowMcp/Sections/FlightPaths.lua +145 -0
- package/addon/WowMcp/Sections/Friends.lua +70 -0
- package/addon/WowMcp/Sections/Group.lua +101 -0
- package/addon/WowMcp/Sections/Guide.lua +317 -0
- package/addon/WowMcp/Sections/Guild.lua +131 -0
- package/addon/WowMcp/Sections/Inspect.lua +100 -0
- package/addon/WowMcp/Sections/Inventory.lua +64 -0
- package/addon/WowMcp/Sections/Legacy.lua +375 -0
- package/addon/WowMcp/Sections/Loot.lua +170 -0
- package/addon/WowMcp/Sections/Macros.lua +26 -0
- package/addon/WowMcp/Sections/Mail.lua +70 -0
- package/addon/WowMcp/Sections/Note.lua +38 -0
- package/addon/WowMcp/Sections/Pet.lua +127 -0
- package/addon/WowMcp/Sections/Played.lua +52 -0
- package/addon/WowMcp/Sections/Probe.lua +79 -0
- package/addon/WowMcp/Sections/Professions.lua +129 -0
- package/addon/WowMcp/Sections/Pvp.lua +45 -0
- package/addon/WowMcp/Sections/QuestDb.lua +106 -0
- package/addon/WowMcp/Sections/QuestGiver.lua +45 -0
- package/addon/WowMcp/Sections/Quests.lua +146 -0
- package/addon/WowMcp/Sections/Recipes.lua +195 -0
- package/addon/WowMcp/Sections/Reputation.lua +56 -0
- package/addon/WowMcp/Sections/Spells.lua +87 -0
- package/addon/WowMcp/Sections/Stable.lua +90 -0
- package/addon/WowMcp/Sections/Talents.lua +137 -0
- package/addon/WowMcp/Sections/Trainer.lua +58 -0
- package/addon/WowMcp/Sections/Vendor.lua +72 -0
- package/addon/WowMcp/Sections/XpGains.lua +258 -0
- package/addon/WowMcp/Snapshot.lua +412 -0
- package/addon/WowMcp/Store.lua +142 -0
- package/addon/WowMcp/TalentGrid.lua +171 -0
- package/addon/WowMcp/Timing.lua +61 -0
- package/addon/WowMcp/TraitTree.lua +158 -0
- package/addon/WowMcp/WowMcp.lua +24 -0
- package/addon/WowMcp/WowMcp.toc +72 -0
- package/bin/wow-mcp.js +248 -0
- package/package.json +41 -4
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section legacy: the Forever Legacy system (account-wide Legacy Points, per-character perk trees
|
|
5
|
+
-- Professions / Adventure / Resourcefulness with an "Apply Changes" button, challenges and rewards).
|
|
6
|
+
--
|
|
7
|
+
-- No public documentation names the API behind it, so the section does not hard-code one:
|
|
8
|
+
-- * configs: every C_Traits config that is not the class talents (C_Traits.GetConfigsByType for each
|
|
9
|
+
-- Enum.TraitConfigType, plus a configID found on a Legacy frame), read like the talents (TraitTree);
|
|
10
|
+
-- * challenges: achievements in categories whose title contains "Legacy" (English client text);
|
|
11
|
+
-- * discovery: Enum entries, C_* namespaces, functions and frames whose name contains "Legacy", and the
|
|
12
|
+
-- results of their argument-free Get/Is/Has/Are functions, so the next version can use the real API.
|
|
13
|
+
-- Everything is a read. Nothing here stages, learns, refunds or applies a perk.
|
|
14
|
+
|
|
15
|
+
local _, ns = ...
|
|
16
|
+
local Compat = ns.Compat
|
|
17
|
+
local plain = Compat.plain
|
|
18
|
+
local TraitTree = ns.TraitTree
|
|
19
|
+
|
|
20
|
+
local MAX_DISCOVERED = 60 -- entries per discovery list
|
|
21
|
+
local MAX_COPY_ENTRIES = 40 -- entries per table copied from a reading
|
|
22
|
+
local MAX_COPY_DEPTH = 3 -- nesting of a copied reading
|
|
23
|
+
local MAX_ACHIEVEMENTS = 150
|
|
24
|
+
local READ_PREFIXES = { "^Get", "^Is", "^Has", "^Are" }
|
|
25
|
+
|
|
26
|
+
local function mentionsLegacy(name)
|
|
27
|
+
return type(name) == "string" and name:lower():find("legacy", 1, true) ~= nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
local function append(list, value, limit)
|
|
31
|
+
if #list < (limit or MAX_DISCOVERED) then list[#list + 1] = value end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
---------------------------------------------------------------------------
|
|
35
|
+
-- Perk trees (C_Traits configs other than the class talents)
|
|
36
|
+
---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
-- Enum.TraitConfigType: value -> name (empty when the client has no such enum).
|
|
39
|
+
local function configTypeNames()
|
|
40
|
+
local names = {}
|
|
41
|
+
local enum = Enum and Enum.TraitConfigType
|
|
42
|
+
if type(enum) == "table" then
|
|
43
|
+
for key, value in pairs(enum) do
|
|
44
|
+
if type(key) == "string" and type(value) == "number" then names[value] = key end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
return names
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
-- Config types worth asking about: all known ones except Invalid and Combat (class talents);
|
|
51
|
+
-- without the enum, the small numbers the enum uses in the modern client.
|
|
52
|
+
local function candidateTypes(names)
|
|
53
|
+
local types = {}
|
|
54
|
+
if next(names) then
|
|
55
|
+
for value, name in pairs(names) do
|
|
56
|
+
if name ~= "Invalid" and name ~= "Combat" then types[#types + 1] = value end
|
|
57
|
+
end
|
|
58
|
+
else
|
|
59
|
+
for value = 0, 15 do types[#types + 1] = value end
|
|
60
|
+
end
|
|
61
|
+
table.sort(types)
|
|
62
|
+
return types
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
-- The account trait currency behind a tree currency (name, total earned), when the client links one.
|
|
66
|
+
local function addAccountCurrency(currency)
|
|
67
|
+
local id = currency.currencyID
|
|
68
|
+
if not (id and C_Traits.GetTraitCurrencyInfo) then return end
|
|
69
|
+
local ok, _, _, currencyTypesID = pcall(C_Traits.GetTraitCurrencyInfo, id)
|
|
70
|
+
currencyTypesID = ok and plain(currencyTypesID)
|
|
71
|
+
if currencyTypesID and C_CurrencyInfo and C_CurrencyInfo.GetCurrencyInfo then
|
|
72
|
+
local okInfo, info = pcall(C_CurrencyInfo.GetCurrencyInfo, currencyTypesID)
|
|
73
|
+
if okInfo and type(info) == "table" then
|
|
74
|
+
currency.currencyTypesID = currencyTypesID
|
|
75
|
+
currency.name = plain(info.name)
|
|
76
|
+
currency.quantity = plain(info.quantity)
|
|
77
|
+
currency.totalEarned = plain(info.totalEarned)
|
|
78
|
+
currency.maxQuantity = plain(info.maxQuantity)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
if C_Traits.GetMaxAvailableTraitCurrency then
|
|
82
|
+
local okMax, maxAvailable = pcall(C_Traits.GetMaxAvailableTraitCurrency, id)
|
|
83
|
+
if okMax then currency.maxAvailable = plain(maxAvailable) end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
-- Locks from node conditions (e.g. points to spend in the tree first).
|
|
88
|
+
local function addConditions(entry, configID, node)
|
|
89
|
+
if not C_Traits.GetConditionInfo then return end
|
|
90
|
+
for _, conditionID in ipairs(node.conditionIDs or {}) do
|
|
91
|
+
local ok, condition = pcall(C_Traits.GetConditionInfo, configID, conditionID)
|
|
92
|
+
if ok and type(condition) == "table" and condition.isMet == false then
|
|
93
|
+
entry.locked = true
|
|
94
|
+
local required = plain(condition.spentAmountRequired)
|
|
95
|
+
if required and required > (entry.requiresSpent or 0) then entry.requiresSpent = required end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
-- Reads one node; also remembers its arrows (visibleEdges) to fill "requires" later.
|
|
101
|
+
local function readNode(config, configID, nodeID, node, groupNames, edges)
|
|
102
|
+
local treeName = TraitTree.tabOf(node, groupNames)
|
|
103
|
+
local entry = TraitTree.nodeEntry(configID, nodeID, node, treeName, true)
|
|
104
|
+
entry.nodeID = plain(nodeID)
|
|
105
|
+
if node.meetsEdgeRequirements ~= nil then entry.prereqMet = node.meetsEdgeRequirements and true or false end
|
|
106
|
+
TraitTree.addDescription(config, entry, TraitTree.entryOf(node), math.max(entry.rank, 1))
|
|
107
|
+
addConditions(entry, configID, node)
|
|
108
|
+
for _, edge in ipairs(node.visibleEdges or {}) do
|
|
109
|
+
local target = plain(edge.targetNode)
|
|
110
|
+
if target then
|
|
111
|
+
edges[target] = edges[target] or {}
|
|
112
|
+
table.insert(edges[target], nodeID)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
return entry
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
-- Fills "requires" (names of the nodes whose arrow points at a node).
|
|
119
|
+
local function addRequirements(nodes, edges)
|
|
120
|
+
local names = {}
|
|
121
|
+
for _, entry in ipairs(nodes) do
|
|
122
|
+
if entry.nodeID then names[entry.nodeID] = entry.name end
|
|
123
|
+
end
|
|
124
|
+
for _, entry in ipairs(nodes) do
|
|
125
|
+
for _, source in ipairs(edges[entry.nodeID] or {}) do
|
|
126
|
+
entry.requires = entry.requires or {}
|
|
127
|
+
table.insert(entry.requires, names[source] or ("node " .. tostring(source)))
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
local function readTree(config, configID, treeID, edges)
|
|
133
|
+
local groupNames, groups = TraitTree.tabs(treeID)
|
|
134
|
+
for _, currency in ipairs(TraitTree.currencies(configID, treeID)) do
|
|
135
|
+
currency.treeID = plain(treeID)
|
|
136
|
+
addAccountCurrency(currency)
|
|
137
|
+
config.currencies[#config.currencies + 1] = currency
|
|
138
|
+
end
|
|
139
|
+
local fallbackName = next(groupNames) == nil and ("tree " .. tostring(treeID)) or nil
|
|
140
|
+
local points = {}
|
|
141
|
+
for _, nodeID in ipairs(C_Traits.GetTreeNodes(treeID) or {}) do
|
|
142
|
+
local node = C_Traits.GetNodeInfo(configID, nodeID)
|
|
143
|
+
if node and node.isVisible ~= false and (node.maxRanks or 0) > 0 then
|
|
144
|
+
local entry = readNode(config, configID, nodeID, node, groupNames, edges)
|
|
145
|
+
entry.tree = entry.tree or fallbackName
|
|
146
|
+
if entry.tree then points[entry.tree] = (points[entry.tree] or 0) + entry.rank end
|
|
147
|
+
config.nodes[#config.nodes + 1] = entry
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
if fallbackName then
|
|
151
|
+
config.trees[#config.trees + 1] = { name = fallbackName, treeID = plain(treeID), points = points[fallbackName] or 0 }
|
|
152
|
+
end
|
|
153
|
+
for _, group in ipairs(groups) do
|
|
154
|
+
config.trees[#config.trees + 1] = {
|
|
155
|
+
name = group.displayName, treeID = plain(treeID), points = points[group.displayName] or 0,
|
|
156
|
+
}
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
local function readConfig(configID, typeName)
|
|
161
|
+
local info = C_Traits.GetConfigInfo(configID)
|
|
162
|
+
if type(info) ~= "table" then return nil end
|
|
163
|
+
local config = {
|
|
164
|
+
configID = plain(configID), type = plain(info.type), typeName = typeName, name = plain(info.name),
|
|
165
|
+
trees = {}, nodes = {}, currencies = {},
|
|
166
|
+
}
|
|
167
|
+
local edges = {}
|
|
168
|
+
for _, treeID in ipairs(info.treeIDs or {}) do
|
|
169
|
+
readTree(config, configID, treeID, edges)
|
|
170
|
+
end
|
|
171
|
+
addRequirements(config.nodes, edges)
|
|
172
|
+
ns.TalentGrid.place(config.nodes)
|
|
173
|
+
return config
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
-- Config IDs by type, without the active class talent config.
|
|
177
|
+
local function findConfigs(typeNames, extraConfigIDs)
|
|
178
|
+
local talentConfig = C_ClassTalents and C_ClassTalents.GetActiveConfigID and C_ClassTalents.GetActiveConfigID()
|
|
179
|
+
local found, seen = {}, {}
|
|
180
|
+
local function add(configID, typeName)
|
|
181
|
+
configID = plain(configID)
|
|
182
|
+
if configID and configID ~= talentConfig and not seen[configID] then
|
|
183
|
+
seen[configID] = true
|
|
184
|
+
found[#found + 1] = { id = configID, typeName = typeName }
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
if C_Traits.GetConfigsByType then
|
|
188
|
+
for _, configType in ipairs(candidateTypes(typeNames)) do
|
|
189
|
+
local ok, ids = pcall(C_Traits.GetConfigsByType, configType)
|
|
190
|
+
if ok and type(ids) == "table" then
|
|
191
|
+
for _, configID in ipairs(ids) do add(configID, typeNames[configType] or tostring(configType)) end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
for _, configID in ipairs(extraConfigIDs) do add(configID, "frame") end
|
|
196
|
+
return found
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
local function readConfigs(legacy, typeNames, extraConfigIDs)
|
|
200
|
+
if not (C_Traits and C_Traits.GetConfigInfo and C_Traits.GetTreeNodes and C_Traits.GetNodeInfo) then return end
|
|
201
|
+
for _, found in ipairs(findConfigs(typeNames, extraConfigIDs)) do
|
|
202
|
+
local ok, config = pcall(readConfig, found.id, found.typeName)
|
|
203
|
+
if ok and config then
|
|
204
|
+
legacy.configs[#legacy.configs + 1] = config
|
|
205
|
+
elseif not ok then
|
|
206
|
+
legacy.configErrors = legacy.configErrors or {}
|
|
207
|
+
append(legacy.configErrors, tostring(found.id) .. ": " .. tostring(config), 10)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
---------------------------------------------------------------------------
|
|
213
|
+
-- Challenges (achievements in a "Legacy" category)
|
|
214
|
+
---------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
local function legacyCategories()
|
|
217
|
+
local titles, parents, picked = {}, {}, {}
|
|
218
|
+
for _, categoryID in ipairs(GetCategoryList() or {}) do
|
|
219
|
+
local title, parentID = GetCategoryInfo(categoryID)
|
|
220
|
+
titles[categoryID], parents[categoryID] = plain(title), plain(parentID)
|
|
221
|
+
if mentionsLegacy(plain(title)) then picked[categoryID] = true end
|
|
222
|
+
end
|
|
223
|
+
local list = {}
|
|
224
|
+
for categoryID in pairs(titles) do
|
|
225
|
+
if picked[categoryID] or picked[parents[categoryID]] then
|
|
226
|
+
list[#list + 1] = { id = categoryID, title = titles[categoryID] }
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
table.sort(list, function(a, b) return a.id < b.id end)
|
|
230
|
+
return list
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
local function readChallenges()
|
|
234
|
+
if not (GetCategoryList and GetCategoryInfo and GetCategoryNumAchievements and GetAchievementInfo) then return nil end
|
|
235
|
+
local challenges = { matchedBy = "achievement category title contains Legacy", list = {} }
|
|
236
|
+
for _, category in ipairs(legacyCategories()) do
|
|
237
|
+
for index = 1, GetCategoryNumAchievements(category.id, true) or 0 do
|
|
238
|
+
local id, name, points, completed, _, _, _, description, _, _, rewardText, _, earnedByMe =
|
|
239
|
+
GetAchievementInfo(category.id, index)
|
|
240
|
+
if id and #challenges.list < MAX_ACHIEVEMENTS then
|
|
241
|
+
challenges.list[#challenges.list + 1] = {
|
|
242
|
+
id = plain(id), category = category.title, name = plain(name), points = plain(points),
|
|
243
|
+
completed = completed and true or false, earnedByMe = Compat.pick(earnedByMe == nil, nil, earnedByMe and true or false),
|
|
244
|
+
description = plain(description), reward = Compat.pick(plain(rewardText) == "", nil, plain(rewardText)),
|
|
245
|
+
}
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
return challenges
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
---------------------------------------------------------------------------
|
|
253
|
+
-- Discovery: what this client calls the Legacy API
|
|
254
|
+
---------------------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
-- A bounded copy of a returned value (plain values, small tables).
|
|
257
|
+
local function boundedCopy(value, depth)
|
|
258
|
+
if type(value) ~= "table" then return plain(value) end
|
|
259
|
+
if depth >= MAX_COPY_DEPTH then return nil end
|
|
260
|
+
local out, count = {}, 0
|
|
261
|
+
for key, item in pairs(value) do
|
|
262
|
+
if count >= MAX_COPY_ENTRIES then break end
|
|
263
|
+
if plain(key) ~= nil then
|
|
264
|
+
local copied = boundedCopy(item, depth + 1)
|
|
265
|
+
if copied ~= nil then
|
|
266
|
+
out[key] = copied
|
|
267
|
+
count = count + 1
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
return out
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
local function isReader(name)
|
|
275
|
+
for _, pattern in ipairs(READ_PREFIXES) do
|
|
276
|
+
if name:find(pattern) then return true end
|
|
277
|
+
end
|
|
278
|
+
return false
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
-- Function names of a namespace, and the results of the argument-free readers (Get/Is/Has/Are only).
|
|
282
|
+
local function readNamespace(discovery, namespaceName, namespace)
|
|
283
|
+
local names = {}
|
|
284
|
+
for key, fn in pairs(namespace) do
|
|
285
|
+
if type(key) == "string" and type(fn) == "function" then names[#names + 1] = key end
|
|
286
|
+
end
|
|
287
|
+
table.sort(names)
|
|
288
|
+
discovery.namespaces[namespaceName] = names
|
|
289
|
+
for _, name in ipairs(names) do
|
|
290
|
+
if isReader(name) then
|
|
291
|
+
local result = { pcall(namespace[name]) }
|
|
292
|
+
if result[1] and #result > 1 then
|
|
293
|
+
local values = {}
|
|
294
|
+
for i = 2, math.min(#result, 4) do values[#values + 1] = boundedCopy(result[i], 0) end
|
|
295
|
+
discovery.readings[namespaceName .. "." .. name] = values
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
-- Name, visibility and the plain fields of a frame (e.g. a configID or treeID set by the UI).
|
|
302
|
+
local function frameInfo(name, frame, extraConfigIDs)
|
|
303
|
+
local info = { name = name, fields = {} }
|
|
304
|
+
local okShown, shown = pcall(frame.IsShown, frame)
|
|
305
|
+
if okShown then info.shown = shown and true or false end
|
|
306
|
+
local count = 0
|
|
307
|
+
for key, value in pairs(frame) do
|
|
308
|
+
if type(key) == "string" and plain(value) ~= nil and count < MAX_COPY_ENTRIES then
|
|
309
|
+
info.fields[key] = value
|
|
310
|
+
count = count + 1
|
|
311
|
+
if key == "configID" and type(value) == "number" then extraConfigIDs[#extraConfigIDs + 1] = value end
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
return info
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
local function isFrame(value)
|
|
318
|
+
return type(value) == "table" and type(value.GetObjectType) == "function"
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
local function addEnums(discovery)
|
|
322
|
+
if type(Enum) ~= "table" then return end
|
|
323
|
+
for enumName, values in pairs(Enum) do
|
|
324
|
+
if type(enumName) == "string" and type(values) == "table" then
|
|
325
|
+
local whole = mentionsLegacy(enumName) or enumName == "TraitConfigType" or enumName == "TraitSystemID"
|
|
326
|
+
for key, value in pairs(values) do
|
|
327
|
+
if (whole or mentionsLegacy(key)) and plain(value) ~= nil then
|
|
328
|
+
append(discovery.enums, "Enum." .. enumName .. "." .. tostring(key) .. "=" .. tostring(value))
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
table.sort(discovery.enums)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
local function discover(extraConfigIDs)
|
|
337
|
+
local discovery = { enums = {}, namespaces = {}, readings = {}, globals = {}, frames = {} }
|
|
338
|
+
addEnums(discovery)
|
|
339
|
+
local namespaces = {}
|
|
340
|
+
for key, value in pairs(_G) do
|
|
341
|
+
if mentionsLegacy(key) then
|
|
342
|
+
if type(value) == "function" then
|
|
343
|
+
append(discovery.globals, key)
|
|
344
|
+
elseif key:find("^C_") and type(value) == "table" then
|
|
345
|
+
namespaces[#namespaces + 1] = key
|
|
346
|
+
elseif isFrame(value) then
|
|
347
|
+
append(discovery.frames, frameInfo(key, value, extraConfigIDs))
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
table.sort(namespaces)
|
|
352
|
+
for _, name in ipairs(namespaces) do readNamespace(discovery, name, _G[name]) end
|
|
353
|
+
table.sort(discovery.globals)
|
|
354
|
+
table.sort(discovery.frames, function(a, b) return a.name < b.name end)
|
|
355
|
+
return discovery
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
---------------------------------------------------------------------------
|
|
359
|
+
|
|
360
|
+
local function collectLegacy()
|
|
361
|
+
local legacy = { configs = {} }
|
|
362
|
+
local extraConfigIDs = {}
|
|
363
|
+
legacy.discovery = discover(extraConfigIDs)
|
|
364
|
+
readConfigs(legacy, configTypeNames(), extraConfigIDs)
|
|
365
|
+
local ok, challenges = pcall(readChallenges)
|
|
366
|
+
if ok then
|
|
367
|
+
legacy.challenges = challenges
|
|
368
|
+
else
|
|
369
|
+
legacy.challengesError = tostring(challenges)
|
|
370
|
+
end
|
|
371
|
+
legacy.source = Compat.pick(#legacy.configs > 0, "traits", "none")
|
|
372
|
+
return legacy
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
ns.Snapshot.addSection("legacy", collectLegacy)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section loot: the player's own loot since the previous dump saved to disk.
|
|
5
|
+
-- Reads only CHAT_MSG_LOOT messages, which the client shows in chat anyway; other
|
|
6
|
+
-- players' loot is skipped. After login (also after /reload, i.e. after a disk save)
|
|
7
|
+
-- it starts from zero, so each dump carries what came in since the previous one. The section is
|
|
8
|
+
-- in the dump from the start of the period (even empty), and the counters messagesSeen, messagesParsed,
|
|
9
|
+
-- messagesSecret and formats show whether messages arrive at all and whether they match the patterns.
|
|
10
|
+
-- Closed periods with loot are carried in loot.periods (oldest first, bounded; see Snapshot.closePeriod).
|
|
11
|
+
|
|
12
|
+
local _, ns = ...
|
|
13
|
+
local plain, callFirst = ns.Compat.plain, ns.Compat.callFirst
|
|
14
|
+
local Items = ns.Items
|
|
15
|
+
|
|
16
|
+
local Loot = {}
|
|
17
|
+
ns.Loot = Loot
|
|
18
|
+
|
|
19
|
+
Loot.MAX_ITEMS = 100
|
|
20
|
+
|
|
21
|
+
-- Patterns of own-loot messages: first the ones with a count, since a pattern without a count would swallow "x5".
|
|
22
|
+
local SELF_LOOT_FORMATS = {
|
|
23
|
+
"LOOT_ITEM_SELF_MULTIPLE", "LOOT_ITEM_PUSHED_SELF_MULTIPLE", "LOOT_ITEM_CREATED_SELF_MULTIPLE",
|
|
24
|
+
"LOOT_ITEM_BONUS_ROLL_SELF_MULTIPLE",
|
|
25
|
+
"LOOT_ITEM_SELF", "LOOT_ITEM_PUSHED_SELF", "LOOT_ITEM_CREATED_SELF", "LOOT_ITEM_BONUS_ROLL_SELF",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
-- When the client lacks these strings: the English "You receive ..." forms.
|
|
29
|
+
local ENGLISH_FORMATS = {
|
|
30
|
+
"You receive loot: %sx%d.", "You receive item: %sx%d.", "You create: %sx%d.",
|
|
31
|
+
"You receive loot: %s.", "You receive item: %s.", "You create: %s.",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
local lootSince -- time of the dump that last reached the disk (or of login)
|
|
35
|
+
local formatCount = 0 -- how many game format strings were found (0 = the English fallback)
|
|
36
|
+
|
|
37
|
+
---------------------------------------------------------------------------
|
|
38
|
+
-- Message recognition (pure functions)
|
|
39
|
+
---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
-- Converts a game format string ("You receive loot: %sx%d.") into a Lua pattern.
|
|
42
|
+
-- Returns the pattern and the field order ("link", "count"), since some languages have %1$s and %2$d.
|
|
43
|
+
function Loot.patternFrom(format)
|
|
44
|
+
local order = {}
|
|
45
|
+
local marked = format:gsub("%%(%d?)%$?([sd])", function(_, kind)
|
|
46
|
+
order[#order + 1] = kind == "s" and "link" or "count"
|
|
47
|
+
return kind == "s" and "\1" or "\2"
|
|
48
|
+
end)
|
|
49
|
+
local escaped = marked:gsub("[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0")
|
|
50
|
+
local pattern = "^" .. escaped:gsub("\1", "(.+)"):gsub("\2", "(%%d+)") .. "$"
|
|
51
|
+
return pattern, order
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
local function selfLootPatterns()
|
|
55
|
+
local patterns = {}
|
|
56
|
+
for _, global in ipairs(SELF_LOOT_FORMATS) do
|
|
57
|
+
local format = _G[global]
|
|
58
|
+
if type(format) == "string" and format ~= "" then patterns[#patterns + 1] = { Loot.patternFrom(format) } end
|
|
59
|
+
end
|
|
60
|
+
formatCount = #patterns
|
|
61
|
+
if #patterns == 0 then
|
|
62
|
+
for _, format in ipairs(ENGLISH_FORMATS) do patterns[#patterns + 1] = { Loot.patternFrom(format) } end
|
|
63
|
+
end
|
|
64
|
+
return patterns
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
-- Item link and count from the player's own loot message; nil for other players' loot.
|
|
68
|
+
function Loot.parseOwn(message, patterns)
|
|
69
|
+
if type(message) ~= "string" then return nil end
|
|
70
|
+
for _, p in ipairs(patterns or selfLootPatterns()) do
|
|
71
|
+
local captures = { message:match(p[1]) }
|
|
72
|
+
if #captures > 0 then
|
|
73
|
+
local fields = {}
|
|
74
|
+
for i, field in ipairs(p[2]) do fields[field] = captures[i] end
|
|
75
|
+
if fields.link and fields.link:find("|Hitem:") then
|
|
76
|
+
return fields.link, tonumber(fields.count) or 1
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
return nil
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
---------------------------------------------------------------------------
|
|
84
|
+
-- Recording in the dump
|
|
85
|
+
---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
local function newSection(since)
|
|
88
|
+
return { since = since, items = {}, messagesSeen = 0, messagesParsed = 0, messagesSecret = 0 }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
local function lootSection()
|
|
92
|
+
local current = ns.Snapshot.current()
|
|
93
|
+
if type(current.loot) ~= "table" then current.loot = newSection(lootSince or time()) end
|
|
94
|
+
local loot = current.loot
|
|
95
|
+
if type(loot.items) ~= "table" then loot.items = {} end
|
|
96
|
+
return loot
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
-- Diagnostic counter (older dumps may not have it).
|
|
100
|
+
local function bump(section, field)
|
|
101
|
+
section[field] = (type(section[field]) == "number" and section[field] or 0) + 1
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
local function findItem(items, id, name)
|
|
105
|
+
for _, item in ipairs(items) do
|
|
106
|
+
if (id and item.id == id) or (not id and item.name == name) then return item end
|
|
107
|
+
end
|
|
108
|
+
return nil
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
-- The longest-ago looted fall off when there are too many different items.
|
|
112
|
+
local function trimOldest(items)
|
|
113
|
+
while #items > Loot.MAX_ITEMS do
|
|
114
|
+
local oldest = 1
|
|
115
|
+
for i, item in ipairs(items) do
|
|
116
|
+
if (item.lastAt or 0) < (items[oldest].lastAt or 0) then oldest = i end
|
|
117
|
+
end
|
|
118
|
+
table.remove(items, oldest)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
local function itemQuality(link)
|
|
123
|
+
local info = callFirst({ "C_Item.GetItemInfo", "GetItemInfo" }, link)
|
|
124
|
+
return info and plain(info[3]) or nil
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
function Loot.record(link, count)
|
|
128
|
+
local items = lootSection().items
|
|
129
|
+
local id, name = Items.idFromLink(link), Items.nameFromLink(link)
|
|
130
|
+
if not (id or name) then return end
|
|
131
|
+
local item = findItem(items, id, name)
|
|
132
|
+
if not item then
|
|
133
|
+
item = { id = id, name = name, quality = itemQuality(link), count = 0 }
|
|
134
|
+
items[#items + 1] = item
|
|
135
|
+
end
|
|
136
|
+
item.count = item.count + count
|
|
137
|
+
item.lastAt = time()
|
|
138
|
+
trimOldest(items)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
local function onLootMessage(message)
|
|
142
|
+
local section = lootSection()
|
|
143
|
+
bump(section, "messagesSeen")
|
|
144
|
+
local text = plain(message)
|
|
145
|
+
if message ~= nil and text == nil then
|
|
146
|
+
bump(section, "messagesSecret") -- the client hid the content ("secret"), it cannot be read
|
|
147
|
+
return
|
|
148
|
+
end
|
|
149
|
+
local link, amount = Loot.parseOwn(text)
|
|
150
|
+
if link then
|
|
151
|
+
bump(section, "messagesParsed")
|
|
152
|
+
Loot.record(link, amount)
|
|
153
|
+
end
|
|
154
|
+
section.formats = formatCount
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
-- A closed period is worth carrying only when it has own loot.
|
|
158
|
+
function Loot.hasContent(section)
|
|
159
|
+
return type(section.items) == "table" and #section.items > 0
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
-- After login (and after /reload) the previous dump is already on disk together with its loot; the closed period
|
|
163
|
+
-- is carried in loot.periods (Snapshot.startPeriod), so a second save before the server reads the file loses nothing.
|
|
164
|
+
local function startLootPeriod()
|
|
165
|
+
lootSince = ns.Snapshot.startPeriod("loot", newSection, Loot.hasContent)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
ns.Snapshot.addWindowSection("loot", nil, nil, { quiet = true })
|
|
169
|
+
ns.Events.on("PLAYER_LOGIN", function() pcall(startLootPeriod) end)
|
|
170
|
+
ns.Events.on("CHAT_MSG_LOOT", ns.Snapshot.whenEnabled("loot", function(message) pcall(onLootMessage, message) end))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section macros: account and character macros with their bodies.
|
|
5
|
+
|
|
6
|
+
local _, ns = ...
|
|
7
|
+
local plain = ns.Compat.plain
|
|
8
|
+
|
|
9
|
+
local function collectMacros()
|
|
10
|
+
if not (GetNumMacros and GetMacroInfo) then return nil end
|
|
11
|
+
local macros = {}
|
|
12
|
+
local accountCount, characterCount = GetNumMacros()
|
|
13
|
+
-- Character macros start right after all the account macro slots.
|
|
14
|
+
local accountSlots = MAX_ACCOUNT_MACROS or 120
|
|
15
|
+
local function add(index, scope)
|
|
16
|
+
local ok, name, _, body = pcall(GetMacroInfo, index)
|
|
17
|
+
if ok and plain(name) then
|
|
18
|
+
macros[#macros + 1] = { name = name, scope = scope, body = plain(body) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
for index = 1, accountCount or 0 do add(index, "account") end
|
|
22
|
+
for index = accountSlots + 1, accountSlots + (characterCount or 0) do add(index, "character") end
|
|
23
|
+
return macros
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ns.Snapshot.addSection("macros", collectMacros)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section mail (from the window): the mailbox. Sender, subject, gold, cash on
|
|
5
|
+
-- delivery (COD), attachments and when the mail expires.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local plain, callFirst, firstValue = ns.Compat.plain, ns.Compat.callFirst, ns.Compat.firstValue
|
|
9
|
+
local round1, Items, pick = ns.round1, ns.Items, ns.Compat.pick
|
|
10
|
+
|
|
11
|
+
local SECONDS_PER_DAY = 86400
|
|
12
|
+
|
|
13
|
+
local function positiveAmount(amount)
|
|
14
|
+
if type(plain(amount)) == "number" and amount > 0 then return amount end
|
|
15
|
+
return nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
local function attachment(index, slot)
|
|
19
|
+
local r = callFirst({ "GetInboxItem" }, index, slot)
|
|
20
|
+
if not (r and plain(r[1])) then return nil end
|
|
21
|
+
-- Newer clients: name, itemID, texture, count, quality, canUse; older: name, texture, count, quality, canUse.
|
|
22
|
+
local newer = type(r[6]) == "boolean"
|
|
23
|
+
local item = {
|
|
24
|
+
name = r[1],
|
|
25
|
+
count = plain(pick(newer, r[4], r[3])) or 1,
|
|
26
|
+
quality = plain(pick(newer, r[5], r[4])),
|
|
27
|
+
}
|
|
28
|
+
local link = firstValue({ "GetInboxItemLink" }, index, slot)
|
|
29
|
+
item.id = Items.idFromLink(link) or pick(newer, plain(r[2]), nil)
|
|
30
|
+
return item
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
local function attachments(index)
|
|
34
|
+
local items = {}
|
|
35
|
+
for slot = 1, ATTACHMENTS_MAX_RECEIVE or 12 do
|
|
36
|
+
items[#items + 1] = attachment(index, slot)
|
|
37
|
+
end
|
|
38
|
+
return items
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
local function inboxMessage(index)
|
|
42
|
+
local h = callFirst({ "GetInboxHeaderInfo" }, index)
|
|
43
|
+
if not h then return nil end
|
|
44
|
+
-- packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned
|
|
45
|
+
local days = plain(h[7])
|
|
46
|
+
local message = {
|
|
47
|
+
sender = plain(h[3]), subject = plain(h[4]),
|
|
48
|
+
moneyCopper = positiveAmount(h[5]),
|
|
49
|
+
codCopper = positiveAmount(h[6]),
|
|
50
|
+
daysLeft = type(days) == "number" and round1(days) or nil,
|
|
51
|
+
expiresAt = type(days) == "number" and (time() + math.floor(days * SECONDS_PER_DAY)) or nil,
|
|
52
|
+
read = h[9] and true or nil,
|
|
53
|
+
returned = h[10] and true or nil,
|
|
54
|
+
}
|
|
55
|
+
if h[8] then message.items = attachments(index) end
|
|
56
|
+
return message
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
local function collectMail()
|
|
60
|
+
local counts = callFirst({ "GetInboxNumItems" })
|
|
61
|
+
local count = counts and plain(counts[1])
|
|
62
|
+
if type(count) ~= "number" then return nil end
|
|
63
|
+
local mail = { capturedAt = time(), messages = {}, totalOnServer = counts and plain(counts[2]) or nil }
|
|
64
|
+
for index = 1, count do
|
|
65
|
+
mail.messages[#mail.messages + 1] = inboxMessage(index)
|
|
66
|
+
end
|
|
67
|
+
return mail
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
ns.Snapshot.addWindowSection("mail", collectMail, { "MAIL_SHOW", "MAIL_INBOX_UPDATE" })
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section note: a short player note for the assistant (/mcp note <text>), e.g. "I want Deadmines today".
|
|
5
|
+
-- Lives in the character's saved dump and passes through subsequent dumps; a command without text removes it.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
|
|
9
|
+
local Note = {}
|
|
10
|
+
ns.Note = Note
|
|
11
|
+
|
|
12
|
+
local MAX_LENGTH = 500
|
|
13
|
+
|
|
14
|
+
-- The first max bytes of text without cutting a UTF-8 character in half (an invalid byte sequence would reach the dump).
|
|
15
|
+
function Note.clip(text, max)
|
|
16
|
+
if #text <= max then return text end
|
|
17
|
+
local cut = max
|
|
18
|
+
while cut > 0 do
|
|
19
|
+
local nextByte = text:byte(cut + 1)
|
|
20
|
+
if not nextByte or nextByte < 128 or nextByte >= 192 then break end -- not a continuation byte: cut is a boundary
|
|
21
|
+
cut = cut - 1
|
|
22
|
+
end
|
|
23
|
+
return text:sub(1, cut)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
-- Saves the note; returns it, or nil when the text is empty (then the note disappears).
|
|
27
|
+
function Note.set(text)
|
|
28
|
+
text = tostring(text or ""):gsub("%s+", " "):match("^%s*(.-)%s*$")
|
|
29
|
+
local current = ns.Snapshot.current()
|
|
30
|
+
if text == "" then
|
|
31
|
+
current.note = nil
|
|
32
|
+
return nil
|
|
33
|
+
end
|
|
34
|
+
current.note = { text = Note.clip(text, MAX_LENGTH), setAt = time() }
|
|
35
|
+
return current.note
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
ns.Snapshot.addWindowSection("note", nil, nil, { quiet = true })
|