Module:Sandbox/ChartConstant

< Module:Sandbox
DrLee lihr讨论 | 贡献2022年7月9日 (六) 09:49的版本 (创建页面,内容为“local p = {} local json = require("Module:LoadJson").ChartConstant() local songlist = require("Module:LoadJson").Songlist() function cv() 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 tonumb…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

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

function cv() 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
   		for m,n in pairs(songlist['songs'])
   		do
   			if n["difficulties"][4]['title_localized']['en'] then
   				name = n["difficulties"][4]['title_localized']['en']

break end

   		end
   		table.insert(list, { i, name, k[4]['constant'], "BYD" })
   	end
   end
   
   local result = {}
   local temporary = {}
   
   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 = 'User:DrLee_lihr/sandbox/组排单元', args = { k[2], k[1], k[4] } } ) else if k[3]<12 then table.insert(temporary,{ k[3], mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { k[2], k[1], k[4], CC = string.format("%.1f", k[3]) } } } ) else table.insert(result[12],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { k[2], k[1], k[4], CC = string.format("%.1f", k[3]) } } ) end end

   end
   
   table.sort(temporary, function(a,b) return a[1]>b[1] end )
   for i,k in ipairs(temporary)
   do
   	table.insert(result[11], k[2])
   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 = "

\n"

for i,k in ipairs(sortTable) do if k[1] == 11 or k[1] == 12 then

finText = finText .. "
"..k[1].."
\n" finText = finText .. "
"..mw.getCurrentFrame():expandTemplate { title = '组排列', args = { ['高度']="154px" } } ..table.concat(k[2])..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."
\n"

else

finText = finText .. "
"..string.format("%.1f", k[1]).."
\n" finText = finText .. "
"..mw.getCurrentFrame():expandTemplate { title = '组排列' } ..table.concat(k[2])..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."
\n"

end end

finText = finText .. "

"

  return finText

end

return p