Module:StreetBrawlAbilities: Difference between revisions

Jump to navigation Jump to search
Add report() to list Street Brawl ability changes grouped by hero (with help from vergir-bot LLM)
Fix hero lookup: ability slot keys decode as numbers, not strings (with help from vergir-bot LLM)
Line 20: Line 20:
if type(card) == "table" and hero and hero.Name and hero.IsDisabled ~= true then
if type(card) == "table" and hero and hero.Name and hero.IsDisabled ~= true then
for slot = 1, 8 do
for slot = 1, 8 do
local ability = card[tostring(slot)]
-- The card's slot keys decode as numbers, so index with one.
local ability = card[slot] or card[tostring(slot)]
if type(ability) == "table" and ability.Key then
if type(ability) == "table" and ability.Key then
map[ability.Key] = { hero = hero.Name, slot = slot, name = ability.Name }
map[ability.Key] = { hero = hero.Name, slot = slot, name = ability.Name }
Line 46: Line 47:
local na, nb = tonumber(a), tonumber(b)
local na, nb = tonumber(a), tonumber(b)
if na and nb then return na < nb end
if na and nb then return na < nb end
return a < b
-- Upgrade tiers arrive as numbers, so never compare a number with a string.
return tostring(a) < tostring(b)
end)
end)
return keys
return keys
Line 55: Line 57:
for _, key in ipairs(sorted_keys(node, top)) do
for _, key in ipairs(sorted_keys(node, top)) do
local value = node[key]
local value = node[key]
local path = prefix and (prefix .. "." .. key) or key
local path = prefix and (prefix .. "." .. key) or tostring(key)
if type(value) == "table" then
if type(value) == "table" then
flatten(value, path, out, false)
flatten(value, path, out, false)