Module:Sandbox/ChartConstant:修订间差异

来自Arcaea中文维基
无编辑摘要
无编辑摘要
 
(未显示同一用户的9个中间版本)
第1行: 第1行:
<includeonly>
local p = {}
local p = {}
local json = require("Module:LoadJson").ChartConstant()
local chartConstantList = require("Module:LoadJson").ChartConstant()
local songlist = require("Module:LoadJson").Songlist()
local songlist = require("Module:LoadJson").Songlist()


function cv()
 
 
local function cv()
local list = {}
local list = {}
for i,k in pairs(songlist['songs'])
for i,k in pairs(songlist['songs'])
do
do
list[k['id']] = k['title_localized']['en']
list[k['id']] = {
k['title_localized']['en'],
k["date"],
nil,
nil
}
if k["difficulties"][4] then
if k["difficulties"][4]["title_localized"] then
list[k['id']][3] = k["difficulties"][4]["title_localized"]["en"]
end
if k["difficulties"][4]["date"] then
list[k['id']][4] = k["difficulties"][4]["date"]
end
end
end
end
return list
return list
end
end
local specialSongNameConverter = {}
specialSongNameConverter["#1f1e33"]="#1f1e33"
specialSongNameConverter["AI[UE]OON"]="AI[UE]OON"


function p.main()
function p.main()
local list = {}
local list = {}
local name 
local name
local cvList = cv()
local cvList = cv()
    for i, k in pairs(json)
    for i, k in pairs(chartConstantList) do
   do
    if k[2] or k[3] or k[4] then
    if k[2] or k[3] or k[4]
    name = cvList[i][1]
   then
end
    name = cvList[i]
     local link = name
   end
     if specialSongNameConverter[name] then
       link = specialSongNameConverter[name]
     end
    if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old']) then
    if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old']) then
    table.insert(list, { i, name, k[2]['constant'], "PRS", name })
    table.insert(list, { i, name, k[2]['constant'], "PRS", link, cvList[i][2] })
    end
    end
    if k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old']) then
    if k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old']) then
    table.insert(list, { i, name, k[3]['constant'], "FTR", name })
    table.insert(list, { i, name, k[3]['constant'], "FTR", link, cvList[i][2] })
    end
    end
    if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
    if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
       local name1 = name
    if cvList[i][3] then
    for m,n in pairs(songlist['songs'])
name = cvList[i][3]
   do
end
   if n["difficulties"][4]['title_localized']['en'] then
if cvList[i][4] then
   name = n["difficulties"][4]['title_localized']['en']
table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][4] })
break
else
end
   table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][2] })
   end
end
   table.insert(list, { i, name, k[4]['constant'], "BYD", name1 })
    end
    end
    end
    end
    
    
-- make lists
    local result = {}
    local result = {}
    local temporary = {}
    local mid_result = {}
  
    result[11], result[12] = {}, {}
    result[11], result[12] = {}, {}
   mid_result[11], mid_result[12] = {}, {}
    for s, k in pairs(list) do
    for s, k in pairs(list) do
   if k[3]<11
     if not(mid_result[k[3]]) then mid_result[k[3]]={} end
   then
     if k[3]>=11 then
   if not(result[k[3]]) then result[k[3]]={} end
       if k[3]>=12 then
   table.insert(result[k[3]],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { k[2], k[1], k[4], link=k[5] } } )
         table.insert(mid_result[12], k)
       else
         table.insert(mid_result[11], k)
       end
     else table.insert(mid_result[k[3]], k) end
   end
 
 
   -- sort songs
   local diffConverter = { PRS=2, FTR=3, BYD=4 }
   for s, k in pairs(mid_result) do
     table.sort(k, function (a, b)
       if not(a[3]==b[3]) then
         return a[3]>b[3]
       end
return a[6]<b[6]
--[=[
       if not(diffConverter[a[4]]==diffConverter[b[4]]) then
         return diffConverter[a[4]]>diffConverter[b[4]]
       else return string.upper(a[2])<string.upper(b[2]) end
]=]
     end)
   end
 
 
-- use template
   for s, k in pairs(mid_result) do
   if s<11 then
   if not(result[s]) then result[s]={} end
       for n, m in pairs(k) do
         table.insert(result[s],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], link=m[5] } } )
       end
   else
   else
   if k[3]<12
   if s<12 then
   then
   for n, m in pairs(k) do
   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]) } } } )
           table.insert(result[11],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], CC = string.format("%.1f", m[3]), link=m[5] } } )
         end
   else
   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]) } } )
   for n, m in pairs(k) do
           table.insert(result[12],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], CC = string.format("%.1f", m[3]), link=m[5] } } )
         end
   end
   end
   end
   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


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


-- add head and end
local finText = "<div class='notaninfobox dstable'>\n"
local finText = "<div class='notaninfobox dstable'>\n"


第94行: 第147行:
finText = finText .. "</div>"
finText = finText .. "</div>"


  return finText
 
   return finText
end
end


return p
return p
</includeonly>

2022年7月10日 (日) 16:50的最新版本

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

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



local function cv()
	local list = {}
	for i,k in pairs(songlist['songs'])
	do
		list[k['id']] = { 
			k['title_localized']['en'], 
			k["date"],
			nil,
			nil
		}
		if k["difficulties"][4] then
			if k["difficulties"][4]["title_localized"] then
				list[k['id']][3] = k["difficulties"][4]["title_localized"]["en"]
			end
			if k["difficulties"][4]["date"] then
				list[k['id']][4] = k["difficulties"][4]["date"]
			end
		end
	end
	return list
end


local specialSongNameConverter = {}
specialSongNameConverter["#1f1e33"]="#1f1e33"
specialSongNameConverter["AI[UE]OON"]="AI[UE]OON"


function p.main()
	local list = {}
	local name
	local cvList = cv()
    for i, k in pairs(chartConstantList) do
    	if k[2] or k[3] or k[4] then
    		name = cvList[i][1]
		end
        local link = name
        if specialSongNameConverter[name] then
            link = specialSongNameConverter[name]
        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", link, cvList[i][2] })
    	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", link, cvList[i][2] })
    	end
    	if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
    		if cvList[i][3] then
				name = cvList[i][3]
			end
			if cvList[i][4] then
				table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][4] })
			else
    			table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][2] })
			end
    	end
    end
    

	-- make lists
    local result = {}
    local mid_result = {}
    result[11], result[12] = {}, {}
    mid_result[11], mid_result[12] = {}, {}

    for s, k in pairs(list) do
        if not(mid_result[k[3]]) then mid_result[k[3]]={} end
        if k[3]>=11 then
            if k[3]>=12 then
                table.insert(mid_result[12], k)
            else
                table.insert(mid_result[11], k)
            end
        else table.insert(mid_result[k[3]], k) end
    end


    -- sort songs
    local diffConverter = { PRS=2, FTR=3, BYD=4 }
    for s, k in pairs(mid_result) do
        table.sort(k, function (a, b)
            if not(a[3]==b[3]) then
                return a[3]>b[3]
            end
			return a[6]<b[6]
			--[=[
            if not(diffConverter[a[4]]==diffConverter[b[4]]) then
                return diffConverter[a[4]]>diffConverter[b[4]]
            else return string.upper(a[2])<string.upper(b[2]) end
			]=]
        end)
    end


	-- use template
    for s, k in pairs(mid_result) do
    	if s<11 then
	    	if not(result[s]) then result[s]={} end
            for n, m in pairs(k) do
                table.insert(result[s],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], link=m[5] } } )
            end
	    else
	    	if s<12 then
	    		for n, m in pairs(k) do
                    table.insert(result[11],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], CC = string.format("%.1f", m[3]), link=m[5] } } )
                end
	    	else
	    		for n, m in pairs(k) do
                    table.insert(result[12],mw.getCurrentFrame():expandTemplate { title = 'User:DrLee_lihr/sandbox/组排单元', args = { m[2], m[1], m[4], CC = string.format("%.1f", m[3]), link=m[5] } } )
                end
	    	end
	    end
    end


	-- sort constants
	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)


	-- add head and end
	local finText = "<div class='notaninfobox dstable'>\n"

	for i,k in ipairs(sortTable)
	do	
		if k[1] == 11 or k[1] == 12
		then
			finText = finText .. "<div class='ds'>"..k[1].."</div>\n"
			finText = finText .. "<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列', args = { ['高度']="154px"  }  }
					..table.concat(k[2])..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."</div>\n"
		else
			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
	end
	
	finText = finText .. "</div>"


    return finText
end

return p