Module:ChartConstant:修订间差异
(创建页面,内容为“local p = {} local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' }) local songlistAppend = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist append.json' }) local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' }) local getArgs = require('Module:Arguments').getArgs function p.getInfList() -- 返回一个数据表。 local songlistE = {} l…”) |
无编辑摘要 |
||
(未显示1个用户的3个中间版本) | |||
第6行: | 第6行: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
function | function getInfList() | ||
-- 返回一个数据表。 | -- 返回一个数据表。 | ||
local songlistE = {} | local songlistE = {} | ||
第15行: | 第15行: | ||
for _,diffInf in ipairs(songInf["difficulties"]) | for _,diffInf in ipairs(songInf["difficulties"]) | ||
do | do | ||
if diffInf["ratingClass"] ~= 0 | if diffInf["ratingClass"] ~= 0 and diffInf["ratingClass"] ~= 1 | ||
then | then | ||
if diffInf[" | if diffInf["ratingClass"] == 2 then ratingClass = "难度III" | ||
else | |||
if diffInf["ratingClass"] == 3 then ratingClass = "难度IV" else ratingClass = "难度IV_Alpha" end | |||
end | |||
table.insert(songlistE,{ | table.insert(songlistE,{ | ||
songInf["id"], | songInf["id"], | ||
第36行: | 第39行: | ||
for _,diffInf in ipairs(songInf["difficulties"]) | for _,diffInf in ipairs(songInf["difficulties"]) | ||
do | do | ||
if diffInf["ratingClass"] ~= 0 | if diffInf["ratingClass"] ~= 0 and diffInf["ratingClass"] ~= 1 | ||
then | then | ||
if diffInf[" | if diffInf["ratingClass"] == 2 then ratingClass = "难度III" | ||
else | |||
if diffInf["ratingClass"] == 3 then ratingClass = "难度IV" else ratingClass = "难度IV_Alpha" end | |||
end | |||
table.insert(songlistE,{ | table.insert(songlistE,{ | ||
songInf["id"], | songInf["id"], | ||
第49行: | 第55行: | ||
end | end | ||
end | end | ||
return songlistE | return songlistE | ||
end | end | ||
第66行: | 第71行: | ||
for _,k in ipairs(inf) | for _,k in ipairs(inf) | ||
do | do | ||
if listReplyA[ | if listReplyA[k[4]] == nil then listReplyA[k[4]] = {} end | ||
table.insert(listReplyA, k) | table.insert(listReplyA[k[4]], k) | ||
end | end | ||
local listReplyB = {} | local listReplyB = {} | ||
local tableC | |||
for s, k in pairs(listReplyA) do | for s, k in pairs(listReplyA) do | ||
tableC = {} | |||
for _, m in pairs(k) do | for _, m in pairs(k) do | ||
table.insert( | table.insert(tableC, mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { m[2], m[1], m[3]} } ) | ||
end | end | ||
table.insert(listReplyB, {s, tableC} ) | |||
end | end | ||
tableC = nil | |||
table.sort(listReplyB, function(a, b) return a[1] > b[1] end) | |||
local finText = "<div class='notaninfobox dstable'>\n" | local finText = "<div class='notaninfobox dstable'>\n" | ||
for _,k in | for _,k in pairs(listReplyB) | ||
do | do | ||
finText = finText .. "<div class='ds'>"..string.format("%.1f", k[1]).."</div>\n" | finText = finText .. "<div class='ds'>"..string.format("%.1f", k[1]).."</div>\n" | ||
finText = finText .. "<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' } | finText = finText .. "<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' } |
2024年7月19日 (五) 16:04的最新版本
可在Module:ChartConstant/doc创建此模块的帮助文档
local p = {} local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' }) local songlistAppend = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist append.json' }) local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' }) local getArgs = require('Module:Arguments').getArgs function getInfList() -- 返回一个数据表。 local songlistE = {} local appendList = {} -- 记录在songlistAppend中存在的曲目,避免重复列举 local ratingClass for _,songInf in ipairs(songlistAppend["songs"]) do for _,diffInf in ipairs(songInf["difficulties"]) do if diffInf["ratingClass"] ~= 0 and diffInf["ratingClass"] ~= 1 then if diffInf["ratingClass"] == 2 then ratingClass = "难度III" else if diffInf["ratingClass"] == 3 then ratingClass = "难度IV" else ratingClass = "难度IV_Alpha" end end table.insert(songlistE,{ songInf["id"], songInf["title_localized"]["default"] , ratingClass, diffInf["ratingReal"] }) end end appendList[songInf["id"]] = true end for _,songInf in ipairs(songlist["songs"]) do if songInf["difficulties"] and not(appendList[songInf["id"]]) then for _,diffInf in ipairs(songInf["difficulties"]) do if diffInf["ratingClass"] ~= 0 and diffInf["ratingClass"] ~= 1 then if diffInf["ratingClass"] == 2 then ratingClass = "难度III" else if diffInf["ratingClass"] == 3 then ratingClass = "难度IV" else ratingClass = "难度IV_Alpha" end end table.insert(songlistE,{ songInf["id"], songInf["title_localized"]["default"] , ratingClass, diffInf["ratingReal"] }) end end end end return songlistE end function p.main(frame) local args = getArgs(frame) return p._main(args) end function p._main(args) local inf = getInfList() local listReplyA = {} for _,k in ipairs(inf) do if listReplyA[k[4]] == nil then listReplyA[k[4]] = {} end table.insert(listReplyA[k[4]], k) end local listReplyB = {} local tableC for s, k in pairs(listReplyA) do tableC = {} for _, m in pairs(k) do table.insert(tableC, mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { m[2], m[1], m[3]} } ) end table.insert(listReplyB, {s, tableC} ) end tableC = nil table.sort(listReplyB, function(a, b) return a[1] > b[1] end) local finText = "<div class='notaninfobox dstable'>\n" for _,k in pairs(listReplyB) do finText = finText .. "<div class='ds'>"..string.format("%.1f", k[1]).."</div>\n" finText = finText .. "<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' } ..table.concat(k[2])..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."</div>\n" end finText = finText .. "</div>" return finText end return p