Module:ChartConstantDetail:修订间差异

来自Rotaeno中文维基
(创建页面,内容为“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 = {} loc…”)
 
(添加颜色)
 
(未显示同一用户的4个中间版本)
第3行: 第3行:
local songlistAppend = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist append.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 trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' })
local getArgs = require('Module:Arguments').getArgs


function getInfList()
function getInfList()
第13行: 第11行:
for _,songInf in ipairs(songlistAppend["songs"])
for _,songInf in ipairs(songlistAppend["songs"])
do
do
for _,diffInf in ipairs(songInf["difficulties"])
table.insert(songlistE,{
do
songInf["id"],
if diffInf["ratingClass"] == 0 then ratingClass = "I"
songInf["title_localized"]["default"],
elseif diffInf["ratingClass"] == 1 then ratingClass = "II"
songInf["difficulties"][1]["ratingReal"],
elseif diffInf["ratingClass"] == 2 then ratingClass = "III"
songInf["difficulties"][2]["ratingReal"],
elseif diffInf["ratingClass"] == 3 then ratingClass = "IV"
songInf["difficulties"][3]["ratingReal"],
end
songInf["difficulties"][4]["ratingReal"]
table.insert(songlistE,{
})
songInf["id"],
songInf["title_localized"]["default"] ,
ratingClass,
diffInf["ratingReal"]
})
end
appendList[songInf["id"]] = true
appendList[songInf["id"]] = true
end
end
第35行: 第27行:
if songInf["difficulties"] and not(appendList[songInf["id"]])
if songInf["difficulties"] and not(appendList[songInf["id"]])
then
then
for _,diffInf in ipairs(songInf["difficulties"])
table.insert(songlistE,{
do
songInf["id"],
if diffInf["ratingClass"] == 0 then ratingClass = "I"
songInf["title_localized"]["default"],
elseif diffInf["ratingClass"] == 1 then ratingClass = "II"
songInf["difficulties"][1]["ratingReal"],
elseif diffInf["ratingClass"] == 2 then ratingClass = "III"
songInf["difficulties"][2]["ratingReal"],
elseif diffInf["ratingClass"] == 3 then ratingClass = "IV"
songInf["difficulties"][3]["ratingReal"],
end
songInf["difficulties"][4]["ratingReal"]
table.insert(songlistE,{
})
songInf["id"],
songInf["title_localized"]["default"] ,
ratingClass,
diffInf["ratingReal"]
})
end
end
end
end
end
第54行: 第40行:
end
end


function p.main(frame)
local inf = getInfList()


table.sort(inf, function(a, b) return a[6] > b[6] end)


function p.main(frame)
local outputTable = mw.html.create("table"):addClass("rotable"):addClass("sortable")
   local args = getArgs(frame)
outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目")
   return p._main(args)
:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度I", "难度I"} })
end
:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度II", "难度II"} })
:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度III", "难度III"} })
:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度IV", "难度IV"} })


function p._main(args)
for _,inf in ipairs(inf)
local inf = getInfList()
 
local listReplyA = {}
for _,k in ipairs(inf)
do
do
if listReplyA[k[4]] == nil then listReplyA[k[4]] = {} end
outputTable:tag("tr"):tag("td"):wikitext("[[File:Songs "..inf[1]..".png|40px]]")
table.insert(listReplyA[k[4]], k)
:tag("td"):wikitext("[["..inf[2].."]]")
:tag("td"):wikitext(inf[3]):tag("td"):wikitext(inf[4])
:tag("td"):wikitext(inf[5]):tag("td"):wikitext(inf[6])
end
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 outputTable = mw.html.create("table")
outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目")
:tag("th"):wikitext("曲师"):tag("th"):wikitext("谱师")
:tag("th"):wikitext("难度"):tag("th"):wikitext("定数")





2022年8月28日 (日) 22:35的最新版本

可在Module:ChartConstantDetail/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' })

function getInfList()
	-- 返回一个数据表。
	local songlistE = {}
	local appendList = {} -- 记录在songlistAppend中存在的曲目,避免重复列举
	local ratingClass
	for _,songInf in ipairs(songlistAppend["songs"])
	do
		table.insert(songlistE,{
			songInf["id"],
			songInf["title_localized"]["default"],
			songInf["difficulties"][1]["ratingReal"],
			songInf["difficulties"][2]["ratingReal"],
			songInf["difficulties"][3]["ratingReal"],
			songInf["difficulties"][4]["ratingReal"]
		})
		appendList[songInf["id"]] = true
	end

	
	for _,songInf in ipairs(songlist["songs"])
	do
		if songInf["difficulties"] and not(appendList[songInf["id"]])
		then
			table.insert(songlistE,{
				songInf["id"],
				songInf["title_localized"]["default"],
				songInf["difficulties"][1]["ratingReal"],
				songInf["difficulties"][2]["ratingReal"],
				songInf["difficulties"][3]["ratingReal"],
				songInf["difficulties"][4]["ratingReal"]
			})
		end
	end
	return songlistE
end

function p.main(frame)
	local inf = getInfList()

	table.sort(inf, function(a, b) return a[6] > b[6] end)

	local outputTable = mw.html.create("table"):addClass("rotable"):addClass("sortable")
	outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目")
				:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度I", "难度I"} })
				:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度II", "难度II"} })
				:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度III", "难度III"} })
				:tag("th"):wikitext(frame:expandTemplate{ title = "Color", args = { "难度IV", "难度IV"} })

	for _,inf in ipairs(inf)
	do
		outputTable:tag("tr"):tag("td"):wikitext("[[File:Songs "..inf[1]..".png|40px]]")
					:tag("td"):wikitext("[["..inf[2].."]]")
					:tag("td"):wikitext(inf[3]):tag("td"):wikitext(inf[4])
					:tag("td"):wikitext(inf[5]):tag("td"):wikitext(inf[6])
	end


    return outputTable
end

return p