Files
ascension-char-exporter/AscensionExporter/Collectors/Talents.lua
T
florian.berthold 52621faa5e Add Ascension talent ID to calculator position mapping
- Introduced `AscensionTalentMapper.lua` to provide mapping between Ascension talent IDs and calculator positions.
- Auto-generated mapping table includes talent tabs, slots, and rank data for supported classes.
2025-12-08 19:01:28 +01:00

148 lines
5.3 KiB
Lua

-- AscensionExporter - Talents collector (active spec only)
-- Ensure global addon table exists even if load order varies
AscensionExporter = _G.AscensionExporter or {}
_G.AscensionExporter = AscensionExporter
local AE = AscensionExporter
local function get_active_group()
if GetActiveTalentGroup then
local g = GetActiveTalentGroup()
if g == 0 then g = 1 end
return g or 1
end
return 1
end
local function collect_selected_for_tab(tabIndex, talentGroup)
local arr = {}
local debug = {}
local numTalents = GetNumTalents(tabIndex)
for talentIndex = 1, numTalents do
-- Ascension API signature test - try different parameter combinations
local name, iconTexture, tier, column, rank, maxRank, isExceptional, available
-- Standard WoW API: GetTalentInfo(tabIndex, talentIndex, inspect, pet, talentGroup)
-- Try 1: Just tab and talent index
name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex)
-- Try 2: With nil for inspect/pet
if rank == 0 or rank == nil then
name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, nil, nil, talentGroup)
end
-- Try 3: With explicit false for inspect/pet
if rank == 0 or rank == nil then
name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, nil, talentGroup)
end
-- Try 4: No talentGroup at all
if rank == 0 or rank == nil then
name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(tabIndex, talentIndex, false, false)
end
-- Debug first few of each tab to see what we're getting
if tabIndex == 3 and talentIndex <= 5 then
table.insert(debug, string.format("tab%d [%d]: %s rank=%s/%s tier=%s col=%s",
tabIndex, talentIndex, tostring(name), tostring(rank), tostring(maxRank), tostring(tier), tostring(column)))
end
-- Debug: scan ALL talents looking for any with rank > 0
if rank and rank > 0 then
table.insert(debug, string.format("FOUND: tab%d talent%d: name=%s rank=%d/%d", tabIndex, talentIndex, tostring(name), rank, maxRank))
end
if rank and rank > 0 then
local link = GetTalentLink(tabIndex, talentIndex)
local spellId = 0
if link then
spellId = tonumber(string.match(link, "talent:(%d+)")) or 0
end
table.insert(arr, {
tabIndex = tabIndex,
talentIndex = talentIndex,
name = name or "",
rank = rank or 0,
maxRank = maxRank or 0,
spellId = spellId,
})
end
end
return arr, debug
end
function AE.CollectTalents()
local out = {
selected = {},
debug = {},
buildString = nil,
talents = {},
}
-- Use Ascension's native talent export API
if C_CharacterAdvancement and C_CharacterAdvancement.ExportBuild then
local buildString = C_CharacterAdvancement.ExportBuild(true)
out.buildString = buildString
table.insert(out.debug, "Ascension API: C_CharacterAdvancement.ExportBuild() = " .. tostring(buildString))
-- Get individual talent entries
if C_CharacterAdvancement.GetKnownTalentEntries then
local entries = C_CharacterAdvancement.GetKnownTalentEntries()
table.insert(out.debug, string.format("Found %d known talent entries", #entries))
for _, entry in ipairs(entries) do
table.insert(out.talents, {
id = entry.ID or 0,
name = entry.name or "",
icon = entry.icon or "",
})
end
end
-- For now, we'll store the build string and parse it later
-- The build string format is Ascension's native format
if buildString and buildString ~= "" then
out.hasTalents = true
end
return out
end
-- Fallback to standard WoW API (for non-Ascension servers)
local active = get_active_group()
out.activeTalentGroup = active
local numTabs = GetNumTalentTabs()
table.insert(out.debug, "Fallback: using GetNumTalentTabs, numTabs=" .. tostring(numTabs))
for tabIndex = 1, numTabs do
local tabName, _, pointsSpent = GetTalentTabInfo(tabIndex, false, false, active)
table.insert(out.debug, string.format("tab%d: name=%s points=%d", tabIndex, tostring(tabName), tonumber(pointsSpent) or 0))
local numTalents = GetNumTalents(tabIndex)
table.insert(out.debug, string.format("tab%d: numTalents=%d", tabIndex, numTalents))
-- Only export selected ranks for the active group
local selected, talentDebug = collect_selected_for_tab(tabIndex, active)
-- Add talent-level debug info
if talentDebug then
for _, msg in ipairs(talentDebug) do
table.insert(out.debug, msg)
end
end
table.insert(out.debug, string.format("tab%d: collected=%d talents", tabIndex, #selected))
for _, v in ipairs(selected) do
table.insert(out.selected, v)
end
end
return out
end
-- Mark module as loaded for debug visibility
AE._loadedTalents = true