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

增加 185 位元組 、​ 2024年2月25日 (星期日)
ulk测试
(调整)
(ulk测试)
行 52: 行 52:
end)
end)
return res
return res
end
local names = {'frag', 'prev', 'ptt'}
local function judgeCond(type)
if type == 0 then
return 'frag'
elseif type == 5 then
return 'ptt'
elseif type <= 100 and type ~= 5 then
return 'prev'
end
end
local function createRow()
local res = {}
for _, k in ipairs(names) do res[k] = 0 end
return res
end
local function judgeRow(row)
local res = {}
for _, k in ipairs(names) do if row[k] > 0 then table.insert(res, 'ulk-' .. k) end end
return #res > 0 and ('class="%s"'):format(table.concat(res, ' ')) or ''
end
end


行 59: 行 80:
local id, rc = chartUlk.songId, chartUlk.ratingClass + 1
local id, rc = chartUlk.songId, chartUlk.ratingClass + 1
for _, cond in ipairs(chartUlk.conditions) do
for _, cond in ipairs(chartUlk.conditions) do
local className
local className = judgeCond(cond.type)
if cond.type == 0 or cond.type == 5 then
className = 'frag'
elseif cond.type <= 100 then
className = 'prev'
end
if className then
if className then
local row = view[id]
local row = view[id]
if not row then
if not row then
row = {frag = 0, prev = 0}
row = createRow()
view[id] = row
view[id] = row
end
end
行 94: 行 110:
rowText[i] = ' '
rowText[i] = ' '
else
else
rowText[i] = table.concat(cell, '<br/>')
rowText[i] = table.concat(cell, '<br>')
end
end
end
end
local tot = row.frag + row.prev
local className = judgeRow(row)
local className
if id == 'lasteternity' then className = '' end
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(className, mLink[id], unpack(rowText)),
data = rowFormat:format(className, mLink[id], unpack(rowText)),
2,525

次編輯