2,525
次編輯
小 (ulk测试) |
小 (ulk测试) |
||
行 45: | 行 45: | ||
function handlers.ratingPlus(v) return v and '+' or '' end | function handlers.ratingPlus(v) return v and '+' or '' end | ||
local function stringify(cond) | local function stringify(cond) | ||
local res = templates[cond.type]:gsub('%$([a-zA-Z12_]+)', function(k) | |||
local nk = tonumber(k) | local nk = tonumber(k) | ||
if nk then return stringify(cond.conditions[nk]) end | if nk then return stringify(cond.conditions[nk]) end | ||
行 51: | 行 51: | ||
return cond[k] | return cond[k] | ||
end) | end) | ||
return res | |||
end | end | ||
行 56: | 行 57: | ||
local view = {} | local view = {} | ||
for _, chartUlk in ipairs(mad.listOf 'unlocks') do | for _, chartUlk in ipairs(mad.listOf 'unlocks') do | ||
local id, rc = chartUlk.songId, chartUlk.ratingClass | local id, rc = chartUlk.songId, chartUlk.ratingClass + 1 | ||
for _, cond in ipairs(chartUlk.conditions) do | |||
for _, cond in ipairs(chartUlk. | |||
local className | local className | ||
if cond.type == 0 then | if cond.type == 0 then | ||
行 72: | 行 66: | ||
end | end | ||
if className then | if className then | ||
local row = view[id] | |||
if not row then | |||
row = {} | |||
view[id] = row | |||
end | |||
local cell = row[rc] | |||
if not cell then | |||
cell = {} | |||
row[rc] = cell | |||
end | |||
table.insert(cell, mw.html.create 'span':addClass(className):wikitext(stringify(cond))) | table.insert(cell, mw.html.create 'span':addClass(className):wikitext(stringify(cond))) | ||
end | end |
次編輯