Module:ChartConstant:修订间差异

来自Arcaea中文维基
无编辑摘要
无编辑摘要
第52行: 第52行:
    end
    end


local textList = {}
local sortTable = {}
textList[1] = "<div class='notaninfobox dstable'>\n"
for i,k in pairs(result)
textList[2]= "</div>"
do
table.insert(sortTable, {i, k})
end
local sText = ""
table.sort(sortTable, function(a,b) return a[1] > b[1] end)
for i,k in pairs(result)
 
local finText = "<div class='notaninfobox dstable'>\n"
 
for i,k in ipairs(sortTable)
do
do
sText = "<div class='ds'>"..string.format("%.1f", i).."</div>\n<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' }
finText = finText .. "<div class='ds'>"..string.format("%.1f", k[1]).."</div>\n<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' }
..table.concat(k)..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."</div>\n"
..table.concat(k[2])..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."</div>\n"
table.insert (textList, 2, sText)
end
end
finText = finText .. "</div>"


   return table.concat(textList)
   return finText
end
end


return p
return p

2022年7月8日 (五) 23:08的版本

可在Module:ChartConstant/doc创建此模块的帮助文档

local p = {}
local json = require("Module:LoadJson").ChartConstant()

function cv()
	local songlist = require("Module:LoadJson").Songlist()
	local list = {}
	for i,k in pairs(songlist['songs'])
	do
		list[k['id']] = k['title_localized']['en']
	end
	
	return list
end

function p.main()
	local list = {}
	local name 
	local cvList = cv()
    for i, k in pairs(json)
    do
    	if k[2] or k[3] or k[4]
    	then
    		name = cvList[i]
    	end
    	if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old']) then
    		table.insert(list, { i, name, k[2]['constant'], "PRS" })
    	end
    	if k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old']) then
    		table.insert(list, { i, name, k[3]['constant'], "FTR" })
    	end
    	if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
    		table.insert(list, { i, name, k[4]['constant'], "BYD" })
    	end
    end
    
    local result = {}
    
    result[11], result[12] = {}, {}
    for s, k in pairs(list) do
    	if k[3]<11
    	then
	    	if not(result[k[3]]) then result[k[3]]={} end
	    	table.insert(result[k[3]],mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { k[2], k[1], k[4]  } } )
	    else
	    	if k[3]<12
	    	then
	    		table.insert(result[11],mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { k[2], k[1], k[4]  } } )
	    	else
	    		table.insert(result[12],mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { k[2], k[1], k[4]  } } )
	    	end
	    end
    end

	local sortTable = {}
	for i,k in pairs(result)
	do
		table.insert(sortTable, {i, k})
	end
	
	table.sort(sortTable, function(a,b) return a[1] > b[1] end)

	local finText = "<div class='notaninfobox dstable'>\n"

	for i,k in ipairs(sortTable)
	do
		finText = finText .. "<div class='ds'>"..string.format("%.1f", k[1]).."</div>\n<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