Module:DesignerSong:修订间差异

来自Arcaea中文维基
(test table)
无编辑摘要
 
(未显示同一用户的22个中间版本)
第1行: 第1行:
p={}
p={}
local DL = mw.loadJsonData 'User:Economy666/DesignersList.json'
local DL = mw.loadJsonData 'Template:DesignersList.json'
local multiId = mw.loadJsonData 'Template:Transition.json'.multiId
local multiId = mw.loadJsonData 'Template:Transition.json'.multiId
local trans = mw.loadJsonData 'Template:Transition.json'
local trans = mw.loadJsonData 'Template:Transition.json'
第6行: 第6行:
local mad = require 'Module:AnotherData'
local mad = require 'Module:AnotherData'
local data = require "Module:Arcaea Data"
local data = require "Module:Arcaea Data"
local CL = require 'Module: 沙盒/Economy666/CL'
local CL = require 'Module:ConvertLink'


local CDL = DL.complex
local CDL = DL.complex
第15行: 第15行:
local queryNS = data.allSongInformation("id", "ns")
local queryNS = data.allSongInformation("id", "ns")
local diffList = {'PST', 'PRS', 'FTR', 'BYD', 'ETR'}
local diffList = {'PST', 'PRS', 'FTR', 'BYD', 'ETR'}
local diffNameList = {PST='Past', PRS='Present', FTR='Future', BYD='Beyond', ETR='Eternal'}
local bydAppend = {[284]='last'}


local songDiffDesigner={}
local songDiffDesigner={}
local specialDesigner ={}
local specialDesigner ={}
local LinkedDesignerList={}
local LinkedDesignerMemory={['/']='/'}
local function readList()
local bydAppendInfo={}
local function linkDesigner(designer, songid)
 
if LinkedDesignerList[designer] then return LinkedDesignerList[designer] end
local function linkDesigner(designer, songid)
local Linked = CL.designerLink(designer, songid)
if LinkedDesignerMemory[designer] then return LinkedDesignerMemory[designer] end
LinkedDesignerList[designer] = Linked
local Linked = CL.designerLink(designer, songid)
return Linked
LinkedDesignerMemory[designer] = Linked
end
return Linked
end
 
local function readList(appendList)
local pickList = {}
local pickList = {}
    local mobileList = {}
    local mobileList = {}
    for _, song in ipairs(mad.listOf('songs', 'mobile')) do
    local listMO = mad.listOf('songs', 'mobile')
   songDiffDesigner[song.id]={}
   local lastDesigner=''
local function write(songid, songDiffList)
   local sameCount=1
songDiffDesigner[songid]={}
   for _,level in ipairs(song.difficulties) do
local num, sameCount = 0,0
   local designer = level.chartDesigner
local lastDesigner = nil
   local diff = level.ratingClass
for _,level in ipairs(songDiffList) do
   -- if lastDesigner ~= designer then
local diff = diffList[level.ratingClass+1]
   if not pickList[designer] then
local designer = level.chartDesigner
   pickList[designer] = {}
num=num+1
   end
if lastDesigner ~= designer then
   if not pickList[designer][song.id] then
sameCount = 0
   pickList[designer][song.id] = {}
if not pickList[designer] then
   end
pickList[designer] = {}
   pickList[designer][song.id][diffList[diff+1]]=true
end
   mobileList[song.id]=true
if not pickList[designer][songid] then
   table.insert(songDiffDesigner[song.id], {diffList[diff+1], linkDesigner(designer, song.id)})
pickList[designer][songid] = {}
   -- songDiffDesigner[song.id]={diffList[diff+1], linkDesigner(designer, song.id)}
end
   if specialSong[song.id] then
pickList[designer][songid][diff]=true
   specialDesigner[designer]=true
mobileList[songid]=true
   end
table.insert(songDiffDesigner[songid], {diff, linkDesigner(designer, songid)})
   lastDesigner=designer
if specialSong[songid] then
   -- else
specialDesigner[designer]=true
   -- sameCount=sameCount+1
end
   -- local theTable = diffList[diff+1-sameCount]
lastDesigner=designer
   -- table.insert(songDiffDesigner[song.id].data, {diffList[diff+1], nil})
else
   -- if theTable then
sameCount=sameCount+1
   -- songDiffDesigner[song.id][theTable]=sameCount
table.insert(songDiffDesigner[songid], {diff, nil})
   -- end
-- if songDiffDesigner[songid][num-sameCount] then
   -- end
songDiffDesigner[songid][num-sameCount][3]=sameCount+1
-- end
-- songDiffDesigner[songid][num][3]=sameCount+1
end
   end
end
  
   for index, id in pairs(bydAppend) do
bydAppendInfo[id] = listMO[index].difficulties[4]
bydAppendInfo[id].id=listMO[index].id
end
  
   for index, song in ipairs(listMO) do
   local songid = song.id
   local songDiffList = song.difficulties
   if bydAppendInfo[songid] then table.insert(songDiffList,bydAppendInfo[songid]) end
   if not bydAppend[index] then
   write(songid, songDiffList)
    end
    end
    end
    end
    
    
   for _, song in ipairs(mad.listOf('songs', 'ns')) do
--  有独占ns曲目再启用
     if not mobileList[song.id] and not multiId[song.id] then
--  for index, song in ipairs(listNS) do
for _,level in ipairs(song.difficulties) do
-- local songid = song.id
   local designer = level.chartDesigner
-- local songDiffList = song.difficulties
   local diff = level.ratingClass
-- if not mobileList.songid then
   if not pickList[designer] then
-- write(songid, songDiffList)
   pickList[designer] = {}
-- end
   end
-- end
   if not pickList[designer][song.id] then
  
   pickList[designer][song.id] = {}
for songid, songDiffList in pairs(appendList) do
   end
   write(songid, songDiffList)
   pickList[designer][song.id][diffList[diff+1]]=true
   if specialSong[song.id] then
   specialDesigner[designer]=true
   end
   end
end
    end
    end
return pickList
return pickList
第142行: 第157行:


-- Function to convert table to string
-- Function to convert table to string
local function tableToString(tbl, indent)
-- local function t2s(tbl, indent)
    indent = indent or 0
--    indent = indent or 0
    local toPrint = string.rep(" ", indent) .. "{\n"
--    local toPrint = string.rep(" ", indent) .. "{\n"
    
    
    for k, v in pairs(tbl) do
--    for k, v in pairs(tbl) do
      local keyString = tostring(k)
--      local keyString = tostring(k)
      local valueString
--      local valueString
 
--     if type(v) == "table" then
--       valueString = t2s(v, indent + 2)
--     else
--       valueString = tostring(v)
--     end
 
--     toPrint = toPrint .. string.rep(" ", indent + 2) .. "[" .. keyString .. "] = " .. valueString .. ",\n"
--   end


     if type(v) == "table" then
--   toPrint = toPrint .. string.rep(" ", indent) .. "}"
       valueString = tableToString(v, indent + 2)
--   return toPrint
     else
-- end
       valueString = tostring(v)
     end


     toPrint = toPrint .. string.rep(" ", indent + 2) .. "[" .. keyString .. "] = " .. valueString .. ",\n"
local function songTitle(id,byd)
   end
local display
local title = queryMO(id, 'title') or queryNS(id, 'title')
if byd then
display = queryMO(id, 'bydSongName')
-- 如果有新的ns独占byd曲目再使用
-- display = queryMO(id, 'bydSongName') or queryNS(id, 'bydSongName') or 'cant find BYD'
if not display then
return nil
end
else
display = title
end
local res = trans.songNameToDisplayName[title]
if res then return res..'|'..display end
res = trans.sameName[title]
if res then return res[id]..'|'..display end
if title then return title..'|'..display
else return nil end
end


   toPrint = toPrint .. string.rep(" ", indent) .. "}"
local function songPack(id)
   return toPrint
local packid,plat,isNS
-- if queryNS(id, 'set') then
-- packid = queryNS(id, 'set')
-- plat = 'ns'
-- isNS = 1
if queryMO(id, 'set') then
packid = queryMO(id, 'set')
else
return nil
end
local packName = trans.packName[packid] or mad.packQueryWrap(packid, plat).name
local packLink = CL.packLink(packName,1,isNS)
return packLink
end
end


第169行: 第221行:
head = head .. '! width="20%" style="position:-webkit-sticky;position:sticky;top:0px;" |备注 \n'
head = head .. '! width="20%" style="position:-webkit-sticky;position:sticky;top:0px;" |备注 \n'


local function songUnit(songid)
local ratingSortMemory ={}
   local data = songDiffDesigner[songid]
local function ratingSort(rating)
   local pack = ''
local findInMemory = ratingSortMemory[rating]
   local text = ''
if findInMemory then return findInMemory end
   text = text .. '|-\n|rowspan='.. #data ..'|'..songid ..'\n'
local num
   text = text .. '|rowspan='.. #data ..'|'..pack ..'\n'
if string.find(rating, '+') then
   for _, i in ipairs(data) do
num = tonumber(string.match(rating,'%d+'))*2 +1
   -- local row = 'rowspan="2"|'
else
     text = text .. '| '.. (i[1] or '') ..' || '.. (i[2] or '') .. '\n'
num = tonumber(rating)*2
   text = text .. '|-\n'
end
   end
ratingSortMemory[rating] = num
   return text
return num
end
end




function p.main()
function p.main(frame)
pickList = readList()
singleList = genList(pickList)
local parentArgs = frame:getParent().args
local text =''
local Args = frame.args
for designer,songs in pairs(singleList) do
text = text .."'''".. designer.."'''\n"
local function getOrder(name)
text = text .. head
local orderArg = Args[name]
for songid,diff in pairs(songs) do
if orderArg then return mw.text.split(orderArg,'\n') end
text = text .. songUnit(songid)
end
local function getDescription(title)
return parentArgs[title .. '.description'] and parentArgs[title .. '.description']..'\n' or ''
end
local function getText(dasigner, songid)
local argName = dasigner..'.'..songid .. '.text'
return parentArgs[argName] or '<span title="'.. argName .. '">-</span>'
end
local function color(diff,theText)
theText = theText or (diffNameList[diff] or '?')
return frame:expandTemplate{ title = "color", args = {diff, theText} }
end
local append = Args['appendList']
local appendList = {}
if append then
local list = mw.text.split(append,'\n')
for _,id in pairs(list) do
appendList[id] = {}
local designerList = {}
for i=0,4 do
local diffDesigner = Args[id .. '.'.. i ..'.designer']
if diffDesigner then
table.insert(designerList,{ratingClass = i, chartDesigner = diffDesigner})
-- chartDesigner ratingClass
end
end
-- appendList[id].pack = Args[id .. '.pack']
appendList[id] = designerList
end
end
local pickList = readList(appendList)
local singleList = genList(pickList)
 
local function songUnit(songid,text)
if not songDiffDesigner[songid] then return '' end
   local data = songDiffDesigner[songid]
   local name =  songTitle(songid) or Args[songid .. '.title'] or '???'
   local nameBYD = {songTitle(songid,true)}
   table.insert(nameBYD, bydAppendInfo[songid] and songTitle(bydAppendInfo[songid].id))
   local pack = songPack(songid) or Args[songid .. '.pack'] or '/'
   if data[1][3]==#data then
   local times = #data
   local row = #nameBYD+1
   local rowspan = 'rowspan='.. row ..'|'
   -- local diffTag = color(diffList[1],'全')..color(diffList[2],'难')..color(diffList[3],'度')
   local diffTag = color(data[times][1],'全难度')
   local style = '|style="height: 35px"'
   local Text = '|-\n'.. style ..'|[['..name..']]||'..rowspan..pack..'||'..rowspan..diffTag..'||'..rowspan..data[1][2]..'\n|'..rowspan..text..'\n|-\n'
if nameBYD[1] then
for _,bydName in ipairs(nameBYD) do
Text = Text .. '|[['..bydName..']]\n|-\n'
end
end
   return Text  end
   local row = #data
   local wikiText = ''
   local rowspanSong = nameBYD and ('|rowspan='.. row-#nameBYD ..'|') or ('|rowspan='.. #data ..'|')
   local rowspan ='|rowspan='.. row ..'|'
   wikiText = wikiText .. '|-\n'..rowspanSong ..'[['..name..']]'..'\n'
   wikiText = wikiText .. rowspan ..pack ..'\n'
   local j = 1
   local style='|style="height: 15px" width="10%"'
   for num, i in ipairs(data) do
   wikiText = wikiText ..style
   if nameBYD[1] and i[1] == 'BYD' then
   wikiText = wikiText ..'|'..'[['..(nameBYD[j] or '')..']]'..'\n'
   j = j + 1
   end
   local diffFormat = '| '..(i[1] and color(i[1]) or '')
   local designerFormat = i[3] and '||rowspan='.. i[3] ..'|' ..i[2]  or (i[2] and '||'..i[2] or '')
     wikiText = wikiText .. diffFormat ..designerFormat..'\n'
   wikiText = wikiText .. (num == 1 and rowspan .. (text or '')..'\n' or '')
   wikiText = wikiText ..'\n|-\n'
   end
   return wikiText
end
local function cateText(cate, titelStr, formatJa)
local theText = ''
local sectionCode = {unknown = 100, free = 1, archive = 2, mainstory = 3, sidestory = 4, collab = 5, single = 6}
function sort_fun(a, b)
a, b = a.sort, b.sort
for i = 1, 3 do
local d = a[i] - b[i]
if d ~= 0 then return d < 0 end
end
return a[4]<b[4]
end
local function getSongSort(songs)
local songSort = {}
for songid, diff in pairs(songs) do
local packItem = mad.packQueryWrap(queryMO(songid, 'set'), 'mobile')
local sortLevel = ratingSort(queryMO(songid, 'ftrRating') or 0)
table.insert(songSort, {
id=songid,
sort={
sectionCode[packItem['section']],
packItem['numero'] or Args[songid..'.sortNum'] or 0,
sortLevel,
songid
}})
end
table.sort(songSort, sort_fun)
return songSort
end
local function writeText(designer, songs)
local songSort = getSongSort(songs)
local designerTitle = designer
if formatJa and mw.ustring.match(designer,'[一-龠ぁ-ゔァ-ヴー々〆〤ヶ]+') then
designerTitle = '-{<span lang="ja">' .. designer .. '</span>}-'
end
theText = theText ..titelStr.. designerTitle ..titelStr.."\n"
theText = theText .. getDescription(designer)
theText = theText .. head
for _,data in ipairs(songSort) do
local songid = data.id
local text = getText(designer, songid)
theText = theText .. songUnit(songid,text)
end
theText = theText .. '|}\n'
end
if cate then
for _,designer in ipairs(cate) do
local songs = singleList[designer] or {}
writeText(designer, songs)
singleList[designer]=nil
end
else
for designer,songs in pairs(singleList) do
writeText(designer, songs)
singleList[designer]=nil
end
end
end
text = text .. '|}'
return theText
end
end
-- for i,ii in pairs(songDiffDesigner) do
 
-- text = text .. songUnit(i)
local common = getOrder("common")
-- end
local commonText = cateText(common, '==')
-- return tableToString(songDiffDesigner)
-- return list1
local rare = getOrder("rare")
local rareTitle = '非常驻谱师'
local rareSpanid = '\n<span id="已确认的其他谱师名义及相关曲目名单" />'
local rareText = rareSpanid.. '\n=='.. rareTitle .. '==\n' .. getDescription(rareTitle)
rareText = rareText .. cateText(rare, '===')
return text
local uncommonTitle = '未确认谱师'
local uncommonSpanid = '\n<span id="未采用常驻谱师名义的曲目名单及所用名义" />'
local uncommonText = uncommonSpanid..'\n=='.. uncommonTitle .. '==\n' .. getDescription(uncommonTitle)
local headText = cateText(getOrder("uncommon_head"), '===', true)
local endText = cateText(getOrder("uncommon_end"), '===')
uncommonText = uncommonText..headText..cateText(nil, '===')..endText
 
return commonText..rareText..uncommonText
-- return tableToString(appendList) ..'\n'..commonText..rareText..uncommonText
end
end


return p
return p

2024年7月27日 (六) 11:55的最新版本

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

p={}
local DL = mw.loadJsonData 'Template:DesignersList.json'
local multiId = mw.loadJsonData 'Template:Transition.json'.multiId
local trans = mw.loadJsonData 'Template:Transition.json'

local mad = require 'Module:AnotherData'
local data = require "Module:Arcaea Data"
local CL = require 'Module:ConvertLink'

local CDL = DL.complex
local SDL = DL.simple
local specialSong = DL.special

local queryMO = data.allSongInformation("id", "mobile")
local queryNS = data.allSongInformation("id", "ns")
local diffList = {'PST', 'PRS', 'FTR', 'BYD', 'ETR'}
local diffNameList = {PST='Past', PRS='Present', FTR='Future', BYD='Beyond', ETR='Eternal'}
local bydAppend = {[284]='last'}

local songDiffDesigner={}
local specialDesigner ={}
local LinkedDesignerMemory={['/']='/'}
local bydAppendInfo={}

local function linkDesigner(designer, songid)
	if LinkedDesignerMemory[designer] then return LinkedDesignerMemory[designer] end
	local Linked = CL.designerLink(designer, songid)
	LinkedDesignerMemory[designer] = Linked
	return Linked
end

local function readList(appendList)
	local pickList = {}
    local mobileList = {}
    local listMO = mad.listOf('songs', 'mobile')
	
	local function write(songid, songDiffList)
		songDiffDesigner[songid]={}
		local num, sameCount = 0,0
		local lastDesigner = nil
		for _,level in ipairs(songDiffList) do
			local diff = diffList[level.ratingClass+1]
			local designer = level.chartDesigner
			num=num+1
			if lastDesigner ~= designer then
				sameCount = 0
				if not pickList[designer] then
					pickList[designer] = {}
				end
				if not pickList[designer][songid] then
					pickList[designer][songid] = {}
				end
				pickList[designer][songid][diff]=true
				mobileList[songid]=true
				table.insert(songDiffDesigner[songid], {diff, linkDesigner(designer, songid)})
				if specialSong[songid] then
					specialDesigner[designer]=true
				end
				lastDesigner=designer
			else
				sameCount=sameCount+1
				table.insert(songDiffDesigner[songid], {diff, nil})
				-- if songDiffDesigner[songid][num-sameCount] then
					songDiffDesigner[songid][num-sameCount][3]=sameCount+1
				-- end
				-- songDiffDesigner[songid][num][3]=sameCount+1
			end
    	end
	end
    
    for index, id in pairs(bydAppend) do
		bydAppendInfo[id] = listMO[index].difficulties[4]
		bydAppendInfo[id].id=listMO[index].id
	end
    
    for index, song in ipairs(listMO) do
    	local songid = song.id
    	local songDiffList = song.difficulties
    	if bydAppendInfo[songid] then table.insert(songDiffList,bydAppendInfo[songid]) end
    	if not bydAppend[index] then
    		write(songid, songDiffList)
    	end
    end
    
 --   有独占ns曲目再启用
 --   for index, song in ipairs(listNS) do
	-- 	local songid = song.id
	-- 	local songDiffList = song.difficulties
	-- 	if not mobileList.songid then
	-- 		write(songid, songDiffList)
	-- 	end
	-- end
    
	for songid, songDiffList in pairs(appendList) do
    	write(songid, songDiffList)
    end
	return pickList
end

local function genList(pickList)
	local function cate(singleList, cArtist, artist)
		local artist = artist or cArtist
		if not singleList[artist] then singleList[artist] = {} end
        for id,diff in pairs(pickList[cArtist]) do
        	singleList[artist][id]=diff
        end
        return singleList
	end
	
    local singleList = {}
    for cDesigner,songids in pairs(pickList) do
    	local designerList={}
        if CDL[cDesigner] then
			if CDL[cDesigner].__FullData__ then
				for _,text in pairs(CDL[cDesigner].__FullData__) do
					if text.link then
	                    local designer = text['link']
						if not designerList[designer] then
							singleList = cate(singleList, cDesigner, designer)
							designerList[designer]=true
						end
					end
				end
			else
				for link in pairs(CDL[cDesigner]) do
                    local designer = link
					if not designerList[designer] then
						singleList = cate(singleList, cDesigner, designer)
						designerList[designer]=true
					end
				end
			end
        else
        	local temp_text = cDesigner
        	local count = 0
        	for _,data in ipairs(SDL) do
				local designer = data.link
				local dis = data.display
				if string.find(temp_text, dis) then
					singleList = cate(singleList, cDesigner, designer)
					designerList[designer]=true
					temp_text = string.gsub(temp_text, dis, '')
					count = count + 1
				end
			end
			if count == 0 then
				if specialDesigner[cDesigner] then
					singleList = cate(singleList, cDesigner, '与主线剧情相关的特殊名义')
				else
					singleList = cate(singleList, cDesigner, '其他未确认谱师名义')
				end
			end
        end
	end
    return singleList
end

-- Function to convert table to string
-- local function t2s(tbl, indent)
--     indent = indent or 0
--     local toPrint = string.rep(" ", indent) .. "{\n"
    
--     for k, v in pairs(tbl) do
--         local keyString = tostring(k)
--         local valueString

--         if type(v) == "table" then
--             valueString = t2s(v, indent + 2)
--         else
--             valueString = tostring(v)
--         end

--         toPrint = toPrint .. string.rep(" ", indent + 2) .. "[" .. keyString .. "] = " .. valueString .. ",\n"
--     end

--     toPrint = toPrint .. string.rep(" ", indent) .. "}"
--     return toPrint
-- end

local function songTitle(id,byd)
	local display
	local title = queryMO(id, 'title') or queryNS(id, 'title')
	if byd then
		display = queryMO(id, 'bydSongName')
		-- 如果有新的ns独占byd曲目再使用
		-- display = queryMO(id, 'bydSongName') or queryNS(id, 'bydSongName') or 'cant find BYD'
		if not display then
			return nil
		end
	else 
		display = title
	end
	local res = trans.songNameToDisplayName[title]
	if res then return res..'|'..display end
	res = trans.sameName[title]
	if res then return res[id]..'|'..display end
	if title then return title..'|'..display
	else return nil end
end

local function songPack(id)
	local packid,plat,isNS
	-- if queryNS(id, 'set') then
	-- 	packid = queryNS(id, 'set')
	-- 	plat = 'ns'
	-- 	isNS = 1
	if queryMO(id, 'set') then
		packid = queryMO(id, 'set')
	else
		return nil
	end
	local packName = trans.packName[packid] or mad.packQueryWrap(packid, plat).name
	local packLink = CL.packLink(packName,1,isNS)
	return packLink
end

local head = '{| class="wikitable" border="1" cellspacing="1" cellpadding="5" style="text-align:center" width="100%"\n'
head = head .. '! width="20%" style="position:-webkit-sticky;position:sticky;top:0px;" |曲名 \n'
head = head .. '! width="20%" style="position:-webkit-sticky;position:sticky;top:0px;" |所属曲包 \n'
head = head .. '! colspan="2" width="40%" style="position:-webkit-sticky;position:sticky;top:0px;" |谱师名义 \n'
head = head .. '! width="20%" style="position:-webkit-sticky;position:sticky;top:0px;" |备注 \n'

local ratingSortMemory ={}
local function ratingSort(rating)
	local findInMemory = ratingSortMemory[rating]
	if findInMemory then return findInMemory end
	local num
	if string.find(rating, '+') then
		num = tonumber(string.match(rating,'%d+'))*2 +1
	else
		num = tonumber(rating)*2
	end
	ratingSortMemory[rating] = num
	return num
end


function p.main(frame)
	
	local parentArgs = frame:getParent().args
	local Args = frame.args
	
	local function getOrder(name)
		local orderArg = Args[name]
		if orderArg then return mw.text.split(orderArg,'\n') end
	end
	
	local function getDescription(title)
		return parentArgs[title .. '.description'] and parentArgs[title .. '.description']..'\n' or ''
	end
	
	local function getText(dasigner, songid)
		local argName = dasigner..'.'..songid .. '.text'
		return parentArgs[argName] or '<span title="'.. argName .. '">-</span>'
	end
	
	local function color(diff,theText)
		theText = theText or (diffNameList[diff] or '?')
		return frame:expandTemplate{ title = "color", args = {diff, theText} }
	end
	
	local append = Args['appendList']
	local appendList = {}
	if append then
		local list = mw.text.split(append,'\n')
		for _,id in pairs(list) do
			appendList[id] = {}
			local designerList = {}
			for i=0,4 do
				local diffDesigner = Args[id .. '.'.. i ..'.designer']
				if diffDesigner then
					table.insert(designerList,{ratingClass = i, chartDesigner = diffDesigner})
					-- chartDesigner ratingClass
				end
			end
			-- appendList[id].pack = Args[id .. '.pack']
			appendList[id] = designerList
		end
	end
	
	local pickList = readList(appendList)
	local singleList = genList(pickList)

	local function songUnit(songid,text)
		if not songDiffDesigner[songid] then return '' end
	    local data = songDiffDesigner[songid]
	    local name =  songTitle(songid) or Args[songid .. '.title'] or '???'
	    local nameBYD = {songTitle(songid,true)}
	    table.insert(nameBYD, bydAppendInfo[songid] and songTitle(bydAppendInfo[songid].id))
	    local pack = songPack(songid) or Args[songid .. '.pack'] or '/'
	    if data[1][3]==#data then
	    	local times = #data
	    	local row = #nameBYD+1
	    	local rowspan = 'rowspan='.. row ..'|'
	    	-- local diffTag = color(diffList[1],'全')..color(diffList[2],'难')..color(diffList[3],'度')
	    	local diffTag = color(data[times][1],'全难度')
	    	local style = '|style="height: 35px"'
	    	local Text = '|-\n'.. style ..'|[['..name..']]||'..rowspan..pack..'||'..rowspan..diffTag..'||'..rowspan..data[1][2]..'\n|'..rowspan..text..'\n|-\n'
			if nameBYD[1] then
				for _,bydName in ipairs(nameBYD) do
				Text = Text .. '|[['..bydName..']]\n|-\n'
				end
			end
	    	return 	 Text   end
	    local row = #data
	    local wikiText = ''
	    local rowspanSong = nameBYD and ('|rowspan='.. row-#nameBYD ..'|') or ('|rowspan='.. #data ..'|')
	    local rowspan ='|rowspan='.. row ..'|'
	    wikiText = wikiText .. '|-\n'..rowspanSong ..'[['..name..']]'..'\n'
	    wikiText = wikiText .. rowspan ..pack ..'\n'
	    local j = 1
	    local style='|style="height: 15px" width="10%"'
	    for num, i in ipairs(data) do
	    	wikiText = wikiText ..style
	    	if nameBYD[1] and i[1] == 'BYD' then
	    		wikiText = wikiText ..'|'..'[['..(nameBYD[j] or '')..']]'..'\n'
	    		j = j + 1
	    	end
	    	local diffFormat = '| '..(i[1] and color(i[1]) or '')
	    	local designerFormat = i[3] and '||rowspan='.. i[3] ..'|' ..i[2]  or (i[2] and '||'..i[2] or '')
	        wikiText = wikiText .. diffFormat ..designerFormat..'\n'
	    	wikiText = wikiText .. (num == 1 and rowspan .. (text or '')..'\n' or '')
	    	wikiText = wikiText ..'\n|-\n'
	    end
	    return wikiText
	end
	
	local function cateText(cate, titelStr, formatJa)
		local theText = ''
		local sectionCode = {unknown = 100, free = 1, archive = 2, mainstory = 3, sidestory = 4, collab = 5, single = 6}
		function sort_fun(a, b)
			a, b = a.sort, b.sort
			for i = 1, 3 do
				local d = a[i] - b[i]
				if d ~= 0 then return d < 0 end
			end
			return a[4]<b[4]
		end
		local function getSongSort(songs)
			local songSort = {}
			for songid, diff in pairs(songs) do
				local packItem = mad.packQueryWrap(queryMO(songid, 'set'), 'mobile')
				local sortLevel = ratingSort(queryMO(songid, 'ftrRating') or 0)
				table.insert(songSort, {
					id=songid,
					sort={
						sectionCode[packItem['section']], 
						packItem['numero'] or Args[songid..'.sortNum'] or 0, 
						sortLevel, 
						songid
						
					}})
			end
			table.sort(songSort, sort_fun)
			return songSort
		end
		local function writeText(designer, songs)
			local songSort = getSongSort(songs)
			local designerTitle = designer
			if formatJa and mw.ustring.match(designer,'[一-龠ぁ-ゔァ-ヴー々〆〤ヶ]+') then
				designerTitle = '-{<span lang="ja">' .. designer .. '</span>}-'
			end
			theText = theText ..titelStr.. designerTitle ..titelStr.."\n"
			theText = theText .. getDescription(designer)
			theText = theText .. head
			for _,data in ipairs(songSort) do
				local songid = data.id
				local text = getText(designer, songid)
				theText = theText .. songUnit(songid,text)
			end
			theText = theText .. '|}\n'
		end
		
		if cate then
			for _,designer in ipairs(cate) do
				local songs = singleList[designer] or {}
				writeText(designer, songs)
				singleList[designer]=nil
			end
		else
			for designer,songs in pairs(singleList) do
				writeText(designer, songs)
				singleList[designer]=nil
			end
		end
		return theText
	end

	local common = getOrder("common")
	local commonText = cateText(common, '==')
	
	local rare = getOrder("rare")
	local rareTitle = '非常驻谱师'
	local rareSpanid = '\n<span id="已确认的其他谱师名义及相关曲目名单" />'
	local rareText = rareSpanid.. '\n=='.. rareTitle .. '==\n' .. getDescription(rareTitle)
	rareText = rareText .. cateText(rare, '===')
	
	local uncommonTitle = '未确认谱师'
	local uncommonSpanid = '\n<span id="未采用常驻谱师名义的曲目名单及所用名义" />'
	local uncommonText = uncommonSpanid..'\n=='.. uncommonTitle .. '==\n' .. getDescription(uncommonTitle)
	local headText = cateText(getOrder("uncommon_head"), '===', true)
	local endText = cateText(getOrder("uncommon_end"), '===')
	uncommonText = uncommonText..headText..cateText(nil, '===')..endText

	return commonText..rareText..uncommonText
	-- return tableToString(appendList) ..'\n'..commonText..rareText..uncommonText
end

return p