Module:StreetBrawlItems: Difference between revisionsGive feedback
mNo edit summary |
Finalize: keep only the Fill card layout; drop legacy hero renderer, grid mode, theme/style/size options (with help from vergir-bot LLM) |
||
| Line 7: | Line 7: | ||
-- Slot display order: Weapon -> Vitality (Armor) -> Spirit (Tech) | -- Slot display order: Weapon -> Vitality (Armor) -> Spirit (Tech) | ||
local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 } | local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 } | ||
-- | -- Card scale passed to ItemBox. | ||
local CARD_SIZE = "0.667" | local CARD_SIZE = "0.667" | ||
| Line 54: | Line 54: | ||
end | end | ||
local function render_item(frame, code | local function render_item(frame, code) | ||
local name = iname(code); if not name then return nil end | local name = iname(code); if not name then return nil end | ||
local args = { name, size = CARD_SIZE } | |||
local args = { name, size = | |||
-- Legendary (tier 5) cards omit the tier badge; it is redundant in the Legendary tier. | -- Legendary (tier 5) cards omit the tier badge; it is redundant in the Legendary tier. | ||
if itier(code) ~= 5 then args.showTierTag = "true" end | if itier(code) ~= 5 then args.showTierTag = "true" end | ||
| Line 74: | Line 73: | ||
local function hero_sets(hkey) | local function hero_sets(hkey) | ||
local favored, unfavored | local favored, unfavored, counter = {}, {}, {} | ||
for _, o in ipairs(sb.Outliers) do | for _, o in ipairs(sb.Outliers) do | ||
if o.Hero == hkey then | if o.Hero == hkey then | ||
if o.Bucket == "Good" then favored | if o.Bucket == "Good" then favored[o.Item] = true | ||
elseif type(o.Weight) == "number" and o.Weight < 1 then unfavored | elseif type(o.Weight) == "number" and o.Weight < 1 then unfavored[o.Item] = true end | ||
if o.Counter ~= nil then counter[#counter + 1] = o.Item end | if o.Counter ~= nil then counter[#counter + 1] = o.Item end | ||
end | end | ||
end | end | ||
return favored, unfavored | return favored, unfavored, counter | ||
end | end | ||
| Line 116: | Line 115: | ||
-- Builds one tier as conditional columns: | -- Builds one tier as conditional columns: | ||
-- High chance (favored) 35% | -- High chance (favored) takes 35%, the middle column fills the rest. | ||
-- Low chance (unfavored) is dropped when empty; a narrow | -- Low chance (unfavored) is dropped when empty; a narrow column on the right when | ||
-- | -- High is present; a fit-content column on the right when High is absent. | ||
local function tier_columns(frame, hkey, tier | local function tier_columns(frame, hkey, tier, hi, mid, lo) | ||
local high, normal, low = collect(hkey, tier) | local high, normal, low = collect(hkey, tier) | ||
local function col(codes, cls, head) | local function col(codes, cls, head) | ||
local parts = {} | local parts = {} | ||
for _, c in ipairs(codes) do local r = render_item(frame, c | for _, c in ipairs(codes) do local r = render_item(frame, c); if r then parts[#parts + 1] = r end end | ||
return '<div class="sb-col ' .. cls .. '">' | return '<div class="sb-col ' .. cls .. '">' | ||
.. '<div class="sb-col-head">' .. head .. '</div>' | .. '<div class="sb-col-head">' .. head .. '</div>' | ||
.. '<div class=" | .. '<div class="sb-col-body sb-col-cards">' .. table.concat(parts) .. '</div>' | ||
.. '</div>' | .. '</div>' | ||
end | end | ||
local out = {} | local out = {} | ||
| Line 145: | Line 139: | ||
out[#out + 1] = col(low, "sb-col-low " .. low_w, lo) | out[#out + 1] = col(low, "sb-col-low " .. low_w, lo) | ||
end | end | ||
return '<div class= | return '<div class="sb-tier">' .. table.concat(out) .. '</div>' | ||
end | end | ||
-- {{#invoke:StreetBrawlItems|tiers|HERO| | -- {{#invoke:StreetBrawlItems|tiers|HERO|high=..|middle=..|low=..}} | ||
-- All five tiers, each under its own heading. | |||
function p.tiers(frame) | function p.tiers(frame) | ||
local hkey = hero_key(frame.args[1]); if not hkey then return "" end | local hkey = hero_key(frame.args[1]); if not hkey then return "" end | ||
local hi = frame.args.high or "High chance" | local hi = frame.args.high or "High chance" | ||
local mid = frame.args.middle or "Average chance" | local mid = frame.args.middle or "Average chance" | ||
| Line 225: | Line 153: | ||
local out = {} | local out = {} | ||
for t = 1, 5 do | for t = 1, 5 do | ||
out[#out + 1] = "=== " .. labels[t] .. " ===\n" .. tier_columns(frame, hkey, t | out[#out + 1] = "=== " .. labels[t] .. " ===\n" .. tier_columns(frame, hkey, t, hi, mid, lo) | ||
end | end | ||
return table.concat(out, "\n\n") | return table.concat(out, "\n\n") | ||
| Line 231: | Line 159: | ||
-- {{#invoke:StreetBrawlItems|hero_counter|HERO|heading=..|note=..}} | -- {{#invoke:StreetBrawlItems|hero_counter|HERO|heading=..|note=..}} | ||
-- The whole counter block (heading + note + cards), or "" when the hero has none. | |||
function p.hero_counter(frame) | function p.hero_counter(frame) | ||
local hkey = hero_key(frame.args[1]); if not hkey then return "" end | local hkey = hero_key(frame.args[1]); if not hkey then return "" end | ||
local | local _, _, counter = hero_sets(hkey) | ||
local codes = {} | local codes = {} | ||
| Line 241: | Line 170: | ||
local parts = {} | local parts = {} | ||
for _, c in ipairs(codes) do local r = render_item(frame, c | for _, c in ipairs(codes) do local r = render_item(frame, c); if r then parts[#parts + 1] = r end end | ||
local out = {} | local out = {} | ||
| Line 253: | Line 182: | ||
-- {{#invoke:StreetBrawlItems|item|ITEM|GROUP|label=..|note=..}} | -- {{#invoke:StreetBrawlItems|item|ITEM|GROUP|label=..|note=..}} | ||
-- GROUP = favored | unfavored | counter | |||
function p.item(frame) | function p.item(frame) | ||
local code = item_code(frame.args[1]); if not code then return "" end | local code = item_code(frame.args[1]); if not code then return "" end | ||