Module:StreetBrawlAbilities: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Round change output to nearest 5% step, prefixing ~ when rounding exceeds 1.5% (with help from vergir-bot LLM) |
Add hero_has_changes checker for the Street Brawl hero category (with help from vergir-bot LLM) |
||
| Line 81: | Line 81: | ||
return "* <code>" .. mw.text.nowiki(call) .. "</code> → '''" .. sb | return "* <code>" .. mw.text.nowiki(call) .. "</code> → '''" .. sb | ||
.. "''' ''(default " .. base .. ")''" | .. "''' ''(default " .. base .. ")''" | ||
end | |||
-- True when Street Brawl changes at least one of this hero's abilities. Accepts a | |||
-- hero_* key or the hero's English name, so callers may pass whichever they hold. | |||
function p.hero_has_changes(hero) | |||
if hero == nil or hero == "" then return false end | |||
local record = mw.loadJsonData(HERO_PAGE)[hero] | |||
local name = (record and record.Name) or hero | |||
local owners = build_owner_map() | |||
local changes = mw.loadJsonData(SB_PAGE)["ability-changes"] | |||
for key in pairs(changes) do | |||
local owner = owners[key] | |||
if owner and owner.hero == name then return true end | |||
end | |||
return false | |||
end | |||
-- {{#invoke:StreetBrawlAbilities|hasChanges|HERO}} exposes the same check to wikitext, | |||
-- answering "1" or the empty string so #if can branch on it. | |||
function p.hasChanges(frame) | |||
return p.hero_has_changes(mw.text.trim(frame.args[1] or "")) and "1" or "" | |||
end | end | ||