「Module:沙盒/盐棋/Sandbox」:修訂間差異

增加 385 位元組 、​ 2024年2月24日 (星期六)
调整
(ulk测试)
(调整)
行 60: 行 60:
for _, cond in ipairs(chartUlk.conditions) do
for _, cond in ipairs(chartUlk.conditions) do
local className
local className
if cond.type == 0 then
if cond.type == 0 or cond.type == 5 then
className = 'ulk-frag'
className = 'frag'
elseif cond.type <= 100 and cond.type ~= 5 then
elseif cond.type <= 100 then
className = 'ulk-prev'
className = 'prev'
end
end
if className then
if className then
local row = view[id]
local row = view[id]
if not row then
if not row then
row = {}
row = {frag = 0, prev = 0}
view[id] = row
view[id] = row
end
end
row[className] = row[className] + 1
local cell = row[rc]
local cell = row[rc]
if not cell then
if not cell then
行 76: 行 77:
row[rc] = cell
row[rc] = cell
end
end
table.insert(cell, mw.html.create 'span':addClass(className):wikitext(stringify(cond)))
table.insert(cell, tostring(mw.html.create 'span':addClass('ulk-' .. className):wikitext(stringify(cond))))
end
end
end
end
行 82: 行 83:


local texts = {}
local texts = {}
local rowFormat = '|-\n|[[%s]]' .. ('||%s'):rep(3)
local rowFormat = '|-%s\n|[[%s]]' .. ('||%s'):rep(3)
local sectionCode = {unknown = 0, single = 1, free = 2, mainstory = 3, sidestory = 4, collab = 5}
local sectionCode = {unknown = 0, single = 1, free = 2, mainstory = 3, sidestory = 4, collab = 5}
for id, row in pairs(view) do
for id, row in pairs(view) do
行 93: 行 94:
rowText[i] = ' '
rowText[i] = ' '
else
else
rowText[i] = mw.allToString(unpack(cell))
rowText[i] = table.concat(cell, '<br/>')
end
end
end
end
local tot = row.frag + row.prev
local className
if row.frag == tot then
className = 'frag'
elseif row.prev == tot then
className = 'prev'
end
className = className and ('class="ulk-%s"'):format(className) or ''
if id == 'lasteternity' then className = 'class="ulk-frag ulk-prev"' end
table.insert(texts, {
table.insert(texts, {
data = rowFormat:format(mLink[id], unpack(rowText)),
data = rowFormat:format(className, mLink[id], unpack(rowText)),
pack = packItem['name'],
pack = packItem['name'],
sort = {sectionCode[packItem['section']], packItem['numero'], song.date},
sort = {sectionCode[packItem['section']], packItem['numero'], song.date},
2,525

次編輯