@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,171 @@
|
|
|
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
|
+
-- Talent tree grid. C_Traits gives node positions in pixels (in Forever every 600:
|
|
5
|
+
-- rows 2130, 2730, ...), sometimes with jitter (5740 instead of 5730) or 10 times too large
|
|
6
|
+
-- (39300 instead of 3930). TalentGrid converts them to row and column numbers starting at 1 within
|
|
7
|
+
-- a tab. Pure functions only (no game API), tested in addon/tests.
|
|
8
|
+
|
|
9
|
+
local _, ns = ...
|
|
10
|
+
|
|
11
|
+
local TalentGrid = {}
|
|
12
|
+
ns.TalentGrid = TalentGrid
|
|
13
|
+
|
|
14
|
+
TalentGrid.JITTER_SHARE = 0.02 -- difference up to 2% of the value is jitter, not another row
|
|
15
|
+
TalentGrid.SCALE_ERROR = 10 -- a position this many times too large is a data error in the client
|
|
16
|
+
TalentGrid.SCALE_OUTLIER = 5 -- ...but only when it is over 5 times larger than the median
|
|
17
|
+
|
|
18
|
+
local function sortedNumbers(values)
|
|
19
|
+
local out = {}
|
|
20
|
+
for _, v in pairs(values) do
|
|
21
|
+
if type(v) == "number" then out[#out + 1] = v end
|
|
22
|
+
end
|
|
23
|
+
table.sort(out)
|
|
24
|
+
return out
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
local function median(sorted)
|
|
28
|
+
return sorted[math.ceil(#sorted / 2)]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
local function jitterOf(value)
|
|
32
|
+
return math.abs(value) * TalentGrid.JITTER_SHARE
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
-- Whether the value lies (with jitter) near one of the other values.
|
|
36
|
+
local function nearAny(value, sorted)
|
|
37
|
+
for _, other in ipairs(sorted) do
|
|
38
|
+
if math.abs(value - other) <= jitterOf(other) then return true end
|
|
39
|
+
end
|
|
40
|
+
return false
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
-- Values without suspiciously large ones (over SCALE_OUTLIER times the median), ascending.
|
|
44
|
+
function TalentGrid.regular(values)
|
|
45
|
+
local sorted = sortedNumbers(values)
|
|
46
|
+
local out = {}
|
|
47
|
+
if #sorted == 0 then return out end
|
|
48
|
+
local limit = math.abs(median(sorted)) * TalentGrid.SCALE_OUTLIER
|
|
49
|
+
for _, v in ipairs(sorted) do
|
|
50
|
+
if math.abs(v) <= limit then out[#out + 1] = v end
|
|
51
|
+
end
|
|
52
|
+
return out
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
-- Whether the value lies (with jitter) on a grid node with origin origin and step step.
|
|
56
|
+
local function onGrid(value, origin, step)
|
|
57
|
+
if not (origin and step) then return false end
|
|
58
|
+
local offset = (value - origin) / step
|
|
59
|
+
return offset > -0.5 and math.abs(offset - math.floor(offset + 0.5)) * step <= jitterOf(value)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
-- Values with corrected positions that were 10x too large (same keys). A position is 10x too large
|
|
63
|
+
-- when, after dividing, it lands on another position of the tab or (with a known step) on a grid node.
|
|
64
|
+
function TalentGrid.unscale(values, step)
|
|
65
|
+
local regular = TalentGrid.regular(values)
|
|
66
|
+
local limit = regular[#regular]
|
|
67
|
+
local out = {}
|
|
68
|
+
for key, v in pairs(values) do
|
|
69
|
+
out[key] = v
|
|
70
|
+
if type(v) == "number" and limit and v > limit then
|
|
71
|
+
local candidate = v / TalentGrid.SCALE_ERROR
|
|
72
|
+
if nearAny(candidate, regular) or onGrid(candidate, regular[1], step) then out[key] = candidate end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
return out
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
-- Clusters of close values (jitter within one row): list of means, ascending.
|
|
79
|
+
function TalentGrid.clusters(values)
|
|
80
|
+
local sorted = sortedNumbers(values)
|
|
81
|
+
local centers, sum, count = {}, 0, 0
|
|
82
|
+
for i, v in ipairs(sorted) do
|
|
83
|
+
if count > 0 and v - sorted[i - 1] > jitterOf(v) then
|
|
84
|
+
centers[#centers + 1] = sum / count
|
|
85
|
+
sum, count = 0, 0
|
|
86
|
+
end
|
|
87
|
+
sum, count = sum + v, count + 1
|
|
88
|
+
end
|
|
89
|
+
if count > 0 then centers[#centers + 1] = sum / count end
|
|
90
|
+
return centers
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
-- Grid step: the smallest gap between neighbouring clusters; nil for a single cluster.
|
|
94
|
+
function TalentGrid.step(centers)
|
|
95
|
+
local step
|
|
96
|
+
for i = 2, #centers do
|
|
97
|
+
local gap = centers[i] - centers[i - 1]
|
|
98
|
+
if not step or gap < step then step = gap end
|
|
99
|
+
end
|
|
100
|
+
return step
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
-- Grid step from the values of one tab (without suspiciously large positions).
|
|
104
|
+
function TalentGrid.stepOf(values)
|
|
105
|
+
return TalentGrid.step(TalentGrid.clusters(TalentGrid.regular(values)))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
-- Grid numbers from 1 for the values of one tab (same keys). An empty row in the middle
|
|
109
|
+
-- keeps its number. step: the step shared by the tree; without it computed from these values.
|
|
110
|
+
function TalentGrid.indexes(values, step)
|
|
111
|
+
step = step or TalentGrid.stepOf(values)
|
|
112
|
+
local unscaled = TalentGrid.unscale(values, step)
|
|
113
|
+
local origin = TalentGrid.clusters(unscaled)[1]
|
|
114
|
+
local out = {}
|
|
115
|
+
for key, v in pairs(unscaled) do
|
|
116
|
+
if type(v) == "number" then
|
|
117
|
+
out[key] = step and (1 + math.floor((v - origin) / step + 0.5)) or 1
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
return out
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
-- Shared step for several tabs: the median of the tabs' steps (a tab with gaps in rows
|
|
124
|
+
-- or with a single node does not spoil the result).
|
|
125
|
+
function TalentGrid.sharedStep(valueLists)
|
|
126
|
+
local steps = {}
|
|
127
|
+
for _, values in ipairs(valueLists) do
|
|
128
|
+
local step = TalentGrid.stepOf(values)
|
|
129
|
+
if step then steps[#steps + 1] = step end
|
|
130
|
+
end
|
|
131
|
+
if #steps == 0 then return nil end
|
|
132
|
+
table.sort(steps)
|
|
133
|
+
return median(steps)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
-- Nodes grouped by tab, in order of first occurrence.
|
|
137
|
+
local function nodesByTree(nodes)
|
|
138
|
+
local trees, byName = {}, {}
|
|
139
|
+
for _, node in ipairs(nodes) do
|
|
140
|
+
local name = node.tree or ""
|
|
141
|
+
if not byName[name] then
|
|
142
|
+
byName[name] = {}
|
|
143
|
+
trees[#trees + 1] = byName[name]
|
|
144
|
+
end
|
|
145
|
+
table.insert(byName[name], node)
|
|
146
|
+
end
|
|
147
|
+
return trees
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
local function positions(treeNodes, field)
|
|
151
|
+
local values = {}
|
|
152
|
+
for i, node in ipairs(treeNodes) do values[i] = node[field] end
|
|
153
|
+
return values
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
-- Sets row (from posY) and column (from posX) on nodes; numbers computed separately in each tab.
|
|
157
|
+
-- The grid step is shared by the whole tree and both axes (the C_Traits grid is square:
|
|
158
|
+
-- in the real dump 600 horizontally and vertically), so a tab with a few nodes also gets a good step.
|
|
159
|
+
function TalentGrid.place(nodes)
|
|
160
|
+
local trees = nodesByTree(nodes)
|
|
161
|
+
local xs, ys, all = {}, {}, {}
|
|
162
|
+
for i, treeNodes in ipairs(trees) do
|
|
163
|
+
xs[i], ys[i] = positions(treeNodes, "posX"), positions(treeNodes, "posY")
|
|
164
|
+
all[#all + 1], all[#all + 2] = xs[i], ys[i]
|
|
165
|
+
end
|
|
166
|
+
local step = TalentGrid.sharedStep(all)
|
|
167
|
+
for i, treeNodes in ipairs(trees) do
|
|
168
|
+
local columns, rows = TalentGrid.indexes(xs[i], step), TalentGrid.indexes(ys[i], step)
|
|
169
|
+
for j, node in ipairs(treeNodes) do node.row, node.column = rows[j], columns[j] end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
-- Timing of dump sections (debugprofilestop, when the client has it).
|
|
5
|
+
-- Without a clock the recorder behaves like a plain pcall and measures nothing.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local round1 = ns.round1
|
|
9
|
+
|
|
10
|
+
local Timing = {}
|
|
11
|
+
ns.Timing = Timing
|
|
12
|
+
|
|
13
|
+
local SLOWEST_COUNT = 5
|
|
14
|
+
|
|
15
|
+
-- Above this many ms /mcp status warns that the dump is heavy.
|
|
16
|
+
Timing.WARNING_TOTAL_MS = 200
|
|
17
|
+
|
|
18
|
+
local function readClock()
|
|
19
|
+
if type(debugprofilestop) ~= "function" then return nil end
|
|
20
|
+
local ok, now = pcall(debugprofilestop)
|
|
21
|
+
if ok and type(now) == "number" then return now end
|
|
22
|
+
return nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
local function slowestFirst(a, b)
|
|
26
|
+
if a.ms ~= b.ms then return a.ms > b.ms end
|
|
27
|
+
return a.name < b.name
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
local function summarize(laps, totalMs)
|
|
31
|
+
table.sort(laps, slowestFirst)
|
|
32
|
+
local slowest = {}
|
|
33
|
+
for i = 1, math.min(SLOWEST_COUNT, #laps) do
|
|
34
|
+
slowest[i] = { name = laps[i].name, ms = round1(laps[i].ms) }
|
|
35
|
+
end
|
|
36
|
+
return { totalMs = round1(totalMs), slowest = slowest }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
-- Recorder for one dump: measure(name, fn) returns the same as pcall.
|
|
40
|
+
function Timing.newRecorder()
|
|
41
|
+
local startedAt = readClock()
|
|
42
|
+
local laps = {}
|
|
43
|
+
local recorder = {}
|
|
44
|
+
|
|
45
|
+
function recorder.measure(name, fn)
|
|
46
|
+
local from = readClock()
|
|
47
|
+
local ok, result = pcall(fn)
|
|
48
|
+
local to = readClock()
|
|
49
|
+
if from and to then laps[#laps + 1] = { name = name, ms = to - from } end
|
|
50
|
+
return ok, result
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
-- { totalMs, slowest = { {name, ms}, ... } } or nil when there was no clock.
|
|
54
|
+
function recorder.report()
|
|
55
|
+
local now = readClock()
|
|
56
|
+
if not (startedAt and now) then return nil end
|
|
57
|
+
return summarize(laps, now - startedAt)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
return recorder
|
|
61
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
-- Reading trait trees (C_Traits): shared by the class talents (Sections/Talents) and the Legacy perks
|
|
5
|
+
-- (Sections/Legacy). Only reads; never stages, purchases or commits anything.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local Compat = ns.Compat
|
|
9
|
+
local plain, firstValue, callFirst = Compat.plain, Compat.firstValue, Compat.callFirst
|
|
10
|
+
local stripMarkup, tooltipFor = Compat.stripMarkup, Compat.tooltipFor
|
|
11
|
+
|
|
12
|
+
local TraitTree = {}
|
|
13
|
+
ns.TraitTree = TraitTree
|
|
14
|
+
|
|
15
|
+
-- Name and spell of a tree entry.
|
|
16
|
+
function TraitTree.entryInfo(configID, entryID)
|
|
17
|
+
if not entryID then return nil end
|
|
18
|
+
local entry = C_Traits.GetEntryInfo(configID, entryID)
|
|
19
|
+
local def = entry and entry.definitionID and C_Traits.GetDefinitionInfo(entry.definitionID)
|
|
20
|
+
if not def then return nil end
|
|
21
|
+
local spellID = plain(def.spellID) or plain(def.overriddenSpellID)
|
|
22
|
+
local name = plain(def.overrideName)
|
|
23
|
+
if not name and spellID then
|
|
24
|
+
name = firstValue({ "C_Spell.GetSpellName", "GetSpellInfo" }, spellID)
|
|
25
|
+
end
|
|
26
|
+
return name, spellID
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
-- Description from the spell API. In a real client it is sometimes empty until the client loads the spell data.
|
|
30
|
+
local function apiDescription(spellID)
|
|
31
|
+
local text = firstValue({ "C_Spell.GetSpellDescription", "GetSpellDescription" }, spellID)
|
|
32
|
+
if type(text) ~= "string" or not text:find("%S") then return nil end
|
|
33
|
+
return stripMarkup(text)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
-- Description from the spell tooltip: lines under the name (the first line is the name).
|
|
37
|
+
local function tooltipDescription(spellID)
|
|
38
|
+
local lines = tooltipFor("GetSpellByID", spellID)
|
|
39
|
+
if not lines or #lines < 2 then return nil end
|
|
40
|
+
return table.concat(lines, "\n", 2)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
-- Description of the entry itself (C_Traits.GetTraitDescription), for entries whose spell has no text.
|
|
44
|
+
local function traitDescription(entryID, rank)
|
|
45
|
+
if not (entryID and C_Traits.GetTraitDescription) then return nil end
|
|
46
|
+
local text = plain(C_Traits.GetTraitDescription(entryID, rank))
|
|
47
|
+
if type(text) ~= "string" or not text:find("%S") then return nil end
|
|
48
|
+
return stripMarkup(text)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
-- Description and where it came from ("api", "tooltip" or "trait"); nil when the client does not know it yet.
|
|
52
|
+
local function describe(spellID, entryID, rank)
|
|
53
|
+
if spellID then
|
|
54
|
+
local text = apiDescription(spellID)
|
|
55
|
+
if text then return text, "api" end
|
|
56
|
+
text = tooltipDescription(spellID)
|
|
57
|
+
if text then return text, "tooltip" end
|
|
58
|
+
end
|
|
59
|
+
local text = traitDescription(entryID, rank)
|
|
60
|
+
if text then return text, "trait" end
|
|
61
|
+
return nil
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
-- Adds a description to a node entry. No description: a request for spell data (it only loads data into client
|
|
65
|
+
-- memory, not a game action) and the owner's missingDescriptions counter, so the server knows another dump will help.
|
|
66
|
+
function TraitTree.addDescription(owner, entry, entryID, rank)
|
|
67
|
+
local ok, text, source = pcall(describe, entry.spellID, entryID, rank)
|
|
68
|
+
if ok and text then
|
|
69
|
+
entry.description = text
|
|
70
|
+
if source ~= "api" then entry.descriptionSource = source end
|
|
71
|
+
return
|
|
72
|
+
end
|
|
73
|
+
if entry.spellID then
|
|
74
|
+
pcall(callFirst, { "C_Spell.RequestLoadSpellData" }, entry.spellID)
|
|
75
|
+
end
|
|
76
|
+
if entry.spellID or (entryID and C_Traits.GetTraitDescription) then
|
|
77
|
+
owner.missingDescriptions = (owner.missingDescriptions or 0) + 1
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
-- Tree tabs: groupID -> displayName and the list of named groups in display order.
|
|
82
|
+
function TraitTree.tabs(treeID)
|
|
83
|
+
local groupNames, groups = {}, {}
|
|
84
|
+
if C_Traits.GetGroupDisplayInfoByTreeID then
|
|
85
|
+
for _, group in ipairs(C_Traits.GetGroupDisplayInfoByTreeID(treeID) or {}) do
|
|
86
|
+
if group.groupID and group.displayName then
|
|
87
|
+
groupNames[group.groupID] = group.displayName
|
|
88
|
+
groups[#groups + 1] = group
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
table.sort(groups, function(a, b) return (a.orderIndex or 0) < (b.orderIndex or 0) end)
|
|
92
|
+
end
|
|
93
|
+
return groupNames, groups
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
-- A node's tab is the first of its groups that has a display name.
|
|
97
|
+
function TraitTree.tabOf(node, groupNames)
|
|
98
|
+
for _, groupID in ipairs(node.groupIDs or {}) do
|
|
99
|
+
if groupNames[groupID] then return groupNames[groupID] end
|
|
100
|
+
end
|
|
101
|
+
return nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
-- Option names of a node with a choice of one of several.
|
|
105
|
+
local function choices(configID, entryIDs)
|
|
106
|
+
local names = {}
|
|
107
|
+
for _, choiceID in ipairs(entryIDs) do
|
|
108
|
+
local ok, choiceName = pcall(TraitTree.entryInfo, configID, choiceID)
|
|
109
|
+
if ok and choiceName then names[#names + 1] = choiceName end
|
|
110
|
+
end
|
|
111
|
+
return names
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
-- The entry a node shows: the chosen one, else the first.
|
|
115
|
+
function TraitTree.entryOf(node)
|
|
116
|
+
return (node.activeEntry and node.activeEntry.entryID) or (node.entryIDs and node.entryIDs[1])
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
-- Current rank of a node.
|
|
120
|
+
function TraitTree.rankOf(node)
|
|
121
|
+
return plain(node.activeRank or node.currentRank) or 0
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
-- Node entry: tab, name, rank, spell, raw position (row and column come from TalentGrid.place) and the game's flags.
|
|
125
|
+
-- named = false skips the name lookup (nodes that will be dropped anyway).
|
|
126
|
+
function TraitTree.nodeEntry(configID, nodeID, node, treeName, named)
|
|
127
|
+
local entryID = named and TraitTree.entryOf(node)
|
|
128
|
+
local okName, name, spellID = pcall(TraitTree.entryInfo, configID, entryID)
|
|
129
|
+
if not okName then name, spellID = nil, nil end
|
|
130
|
+
name = name or ("node " .. tostring(nodeID))
|
|
131
|
+
|
|
132
|
+
local entry = {
|
|
133
|
+
tree = treeName, name = name, rank = TraitTree.rankOf(node), maxRank = plain(node.maxRanks),
|
|
134
|
+
spellID = spellID,
|
|
135
|
+
posX = plain(node.posX), posY = plain(node.posY),
|
|
136
|
+
}
|
|
137
|
+
if node.canPurchaseRank ~= nil then entry.canPurchase = node.canPurchaseRank and true or false end
|
|
138
|
+
if node.isAvailable ~= nil then entry.available = node.isAvailable and true or false end
|
|
139
|
+
if node.entryIDs and #node.entryIDs > 1 then
|
|
140
|
+
entry.choices = choices(configID, node.entryIDs)
|
|
141
|
+
end
|
|
142
|
+
return entry
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
-- Spent and available points of a tree, one entry per trait currency.
|
|
146
|
+
function TraitTree.currencies(configID, treeID)
|
|
147
|
+
local out = {}
|
|
148
|
+
if not C_Traits.GetTreeCurrencyInfo then return out end
|
|
149
|
+
for _, currency in ipairs(C_Traits.GetTreeCurrencyInfo(configID, treeID, false) or {}) do
|
|
150
|
+
out[#out + 1] = {
|
|
151
|
+
currencyID = plain(currency.traitCurrencyID),
|
|
152
|
+
available = plain(currency.quantity),
|
|
153
|
+
spent = plain(currency.spent),
|
|
154
|
+
max = plain(currency.maxQuantity),
|
|
155
|
+
}
|
|
156
|
+
end
|
|
157
|
+
return out
|
|
158
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
-- Addon lifecycle: what we do after login and before logout.
|
|
5
|
+
|
|
6
|
+
local _, ns = ...
|
|
7
|
+
local Snapshot, Panel, Played, Store = ns.Snapshot, ns.Panel, ns.Played, ns.Store
|
|
8
|
+
|
|
9
|
+
local function onLogin()
|
|
10
|
+
pcall(Store.adoptRealmlessDump)
|
|
11
|
+
if not Store.settings().panelHidden then pcall(Panel.create) end
|
|
12
|
+
pcall(ns.MinimapButton.create)
|
|
13
|
+
pcall(Played.request)
|
|
14
|
+
pcall(ns.Options.register)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
-- Also fires on /reload, right before SavedVariables are written.
|
|
18
|
+
local function onLogout()
|
|
19
|
+
pcall(Snapshot.dump, "logout")
|
|
20
|
+
pcall(Snapshot.sanitizeCurrent) -- also when the dump itself failed
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
ns.Events.on("PLAYER_LOGOUT", onLogout)
|
|
24
|
+
ns.Events.on("PLAYER_LOGIN", onLogin)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## Interface: 16001
|
|
2
|
+
## Title: WowMcp
|
|
3
|
+
## Notes: Saves character state to SavedVariables, from where a local MCP server reads it. Read-only, no automation.
|
|
4
|
+
## Author: Piekasz (GitHub: Piekario)
|
|
5
|
+
## X-License: GPL-3.0-or-later, author attribution must be kept (see NOTICE)
|
|
6
|
+
## Version: 0.16.0
|
|
7
|
+
## OptionalDeps: QuestieDB, Questie, Guidelime
|
|
8
|
+
## SavedVariables: WowMcpDB
|
|
9
|
+
|
|
10
|
+
# Foundations: each file depends only on the files above it.
|
|
11
|
+
Core.lua
|
|
12
|
+
Compat.lua
|
|
13
|
+
Maps.lua
|
|
14
|
+
QuestDb.lua
|
|
15
|
+
Items.lua
|
|
16
|
+
QuestRewards.lua
|
|
17
|
+
TalentGrid.lua
|
|
18
|
+
TraitTree.lua
|
|
19
|
+
Store.lua
|
|
20
|
+
Events.lua
|
|
21
|
+
Timing.lua
|
|
22
|
+
Snapshot.lua
|
|
23
|
+
|
|
24
|
+
# Sections collected on every dump. File order = section order in the dump.
|
|
25
|
+
Sections\Character.lua
|
|
26
|
+
Sections\Quests.lua
|
|
27
|
+
Sections\Inventory.lua
|
|
28
|
+
Sections\Spells.lua
|
|
29
|
+
Sections\Talents.lua
|
|
30
|
+
Sections\Legacy.lua
|
|
31
|
+
Sections\Professions.lua
|
|
32
|
+
Sections\Pet.lua
|
|
33
|
+
Sections\ActionBars.lua
|
|
34
|
+
Sections\Reputation.lua
|
|
35
|
+
Sections\Macros.lua
|
|
36
|
+
Sections\Currencies.lua
|
|
37
|
+
Sections\Cooldowns.lua
|
|
38
|
+
Sections\Played.lua
|
|
39
|
+
Sections\Group.lua
|
|
40
|
+
Sections\Dungeons.lua
|
|
41
|
+
Sections\EquipmentSets.lua
|
|
42
|
+
Sections\Pvp.lua
|
|
43
|
+
Sections\Guide.lua
|
|
44
|
+
Sections\QuestDb.lua
|
|
45
|
+
|
|
46
|
+
# Sections collected when a window opens.
|
|
47
|
+
Sections\Trainer.lua
|
|
48
|
+
Sections\Vendor.lua
|
|
49
|
+
Sections\Buyback.lua
|
|
50
|
+
Sections\Stable.lua
|
|
51
|
+
Sections\QuestGiver.lua
|
|
52
|
+
Sections\Bank.lua
|
|
53
|
+
Sections\FlightPaths.lua
|
|
54
|
+
Sections\Recipes.lua
|
|
55
|
+
Sections\Mail.lua
|
|
56
|
+
Sections\Auctions.lua
|
|
57
|
+
Sections\Inspect.lua
|
|
58
|
+
Sections\Friends.lua
|
|
59
|
+
Sections\Guild.lua
|
|
60
|
+
Sections\Probe.lua
|
|
61
|
+
Sections\Deaths.lua
|
|
62
|
+
Sections\Loot.lua
|
|
63
|
+
Sections\XpGains.lua
|
|
64
|
+
Sections\Note.lua
|
|
65
|
+
|
|
66
|
+
# Player UI.
|
|
67
|
+
Panel.lua
|
|
68
|
+
MinimapButton.lua
|
|
69
|
+
AuctionTooltip.lua
|
|
70
|
+
Options.lua
|
|
71
|
+
WowMcp.lua
|
|
72
|
+
Commands.lua
|