Module:DesignerSong:修订间差异
Economy666(讨论 | 贡献) 小无编辑摘要 |
Economy666(讨论 | 贡献) (test table) |
||
第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: | local CL = require 'Module: 沙盒/Economy666/CL' | ||
local CDL = DL.complex | local CDL = DL.complex | ||
第14行: | 第14行: | ||
local queryMO = data.allSongInformation("id", "mobile") | local queryMO = data.allSongInformation("id", "mobile") | ||
local queryNS = data.allSongInformation("id", "ns") | local queryNS = data.allSongInformation("id", "ns") | ||
local diffList = {'PST', 'PRS', 'FTR', 'BYD', 'ETR'} | |||
local songDiffDesigner={} | |||
local specialDesigner ={} | |||
local LinkedDesignerList={} | |||
local function readList() | local function readList() | ||
local function linkDesigner(designer, songid) | |||
if LinkedDesignerList[designer] then return LinkedDesignerList[designer] end | |||
local Linked = CL.designerLink(designer, songid) | |||
LinkedDesignerList[designer] = Linked | |||
return Linked | |||
end | |||
local pickList = {} | local pickList = {} | ||
local mobileList = {} | local mobileList = {} | ||
for _, song in ipairs(mad.listOf('songs', 'mobile')) do | for _, song in ipairs(mad.listOf('songs', 'mobile')) do | ||
songDiffDesigner[song.id]={} | |||
local lastDesigner='' | |||
local sameCount=1 | |||
for _,level in ipairs(song.difficulties) do | for _,level in ipairs(song.difficulties) do | ||
local designer = level.chartDesigner | local designer = level.chartDesigner | ||
local diff = level.ratingClass | local diff = level.ratingClass | ||
if not pickList[designer] then | -- if lastDesigner ~= designer then | ||
if not pickList[designer] then | |||
pickList[designer] = {} | |||
end | |||
if not pickList[designer][song.id] then | |||
pickList[designer][song.id] = {} | |||
end | |||
pickList[designer][song.id][diffList[diff+1]]=true | |||
mobileList[song.id]=true | |||
table.insert(songDiffDesigner[song.id], {diffList[diff+1], linkDesigner(designer, song.id)}) | |||
-- songDiffDesigner[song.id]={diffList[diff+1], linkDesigner(designer, song.id)} | |||
if specialSong[song.id] then | |||
specialDesigner[designer]=true | |||
end | |||
lastDesigner=designer | |||
-- else | |||
-- sameCount=sameCount+1 | |||
-- local theTable = diffList[diff+1-sameCount] | |||
-- table.insert(songDiffDesigner[song.id].data, {diffList[diff+1], nil}) | |||
-- if theTable then | |||
-- songDiffDesigner[song.id][theTable]=sameCount | |||
-- end | |||
-- end | |||
end | end | ||
end | end | ||
第56行: | 第80行: | ||
end | end | ||
end | end | ||
return pickList | return pickList | ||
end | end | ||
local function genList(pickList | local function genList(pickList) | ||
local function cate(singleList, cArtist, artist) | local function cate(singleList, cArtist, artist) | ||
local artist = artist or cArtist | local artist = artist or cArtist | ||
if not singleList[artist] then singleList[artist] = {} end | if not singleList[artist] then singleList[artist] = {} end | ||
for id,diff in pairs(pickList[cArtist]) do | for id,diff in pairs(pickList[cArtist]) do | ||
singleList[artist][id] = diff | singleList[artist][id]=diff | ||
end | end | ||
return singleList | return singleList | ||
end | end | ||
local singleList = {} | local singleList = {} | ||
for cDesigner,songids in pairs(pickList) do | for cDesigner,songids in pairs(pickList) do | ||
local designerList={} | local designerList={} | ||
第148行: | 第162行: | ||
return toPrint | return toPrint | ||
end | 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 function songUnit(songid) | |||
local data = songDiffDesigner[songid] | |||
local pack = '' | |||
local text = '' | |||
text = text .. '|-\n|rowspan='.. #data ..'|'..songid ..'\n' | |||
text = text .. '|rowspan='.. #data ..'|'..pack ..'\n' | |||
for _, i in ipairs(data) do | |||
-- local row = 'rowspan="2"|' | |||
text = text .. '| '.. (i[1] or '') ..' || '.. (i[2] or '') .. '\n' | |||
text = text .. '|-\n' | |||
end | |||
return text | |||
end | |||
function p.main() | function p.main() | ||
pickList | pickList = readList() | ||
singleList = genList(pickList | singleList = genList(pickList) | ||
local | local text ='' | ||
for | for designer,songs in pairs(singleList) do | ||
text = text .."'''".. designer.."'''\n" | |||
for | text = text .. head | ||
for songid,diff in pairs(songs) do | |||
text = text .. songUnit(songid) | |||
end | end | ||
text = text .. '|}' | |||
end | end | ||
-- return tableToString( | -- for i,ii in pairs(songDiffDesigner) do | ||
return list1 | -- text = text .. songUnit(i) | ||
-- end | |||
-- return tableToString(songDiffDesigner) | |||
-- return list1 | |||
return text | |||
end | end | ||
return p | return p |
2024年7月24日 (三) 23:07的版本
可在Module:DesignerSong/doc创建此模块的帮助文档
p={}
local DL = mw.loadJsonData 'User:Economy666/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:沙盒/Economy666/CL'
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 songDiffDesigner={}
local specialDesigner ={}
local LinkedDesignerList={}
local function readList()
local function linkDesigner(designer, songid)
if LinkedDesignerList[designer] then return LinkedDesignerList[designer] end
local Linked = CL.designerLink(designer, songid)
LinkedDesignerList[designer] = Linked
return Linked
end
local pickList = {}
local mobileList = {}
for _, song in ipairs(mad.listOf('songs', 'mobile')) do
songDiffDesigner[song.id]={}
local lastDesigner=''
local sameCount=1
for _,level in ipairs(song.difficulties) do
local designer = level.chartDesigner
local diff = level.ratingClass
-- if lastDesigner ~= designer then
if not pickList[designer] then
pickList[designer] = {}
end
if not pickList[designer][song.id] then
pickList[designer][song.id] = {}
end
pickList[designer][song.id][diffList[diff+1]]=true
mobileList[song.id]=true
table.insert(songDiffDesigner[song.id], {diffList[diff+1], linkDesigner(designer, song.id)})
-- songDiffDesigner[song.id]={diffList[diff+1], linkDesigner(designer, song.id)}
if specialSong[song.id] then
specialDesigner[designer]=true
end
lastDesigner=designer
-- else
-- sameCount=sameCount+1
-- local theTable = diffList[diff+1-sameCount]
-- table.insert(songDiffDesigner[song.id].data, {diffList[diff+1], nil})
-- if theTable then
-- songDiffDesigner[song.id][theTable]=sameCount
-- end
-- end
end
end
for _, song in ipairs(mad.listOf('songs', 'ns')) do
if not mobileList[song.id] and not multiId[song.id] then
for _,level in ipairs(song.difficulties) do
local designer = level.chartDesigner
local diff = level.ratingClass
if not pickList[designer] then
pickList[designer] = {}
end
if not pickList[designer][song.id] then
pickList[designer][song.id] = {}
end
pickList[designer][song.id][diffList[diff+1]]=true
if specialSong[song.id] then
specialDesigner[designer]=true
end
end
end
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 tableToString(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 = tableToString(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 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 function songUnit(songid)
local data = songDiffDesigner[songid]
local pack = ''
local text = ''
text = text .. '|-\n|rowspan='.. #data ..'|'..songid ..'\n'
text = text .. '|rowspan='.. #data ..'|'..pack ..'\n'
for _, i in ipairs(data) do
-- local row = 'rowspan="2"|'
text = text .. '| '.. (i[1] or '') ..' || '.. (i[2] or '') .. '\n'
text = text .. '|-\n'
end
return text
end
function p.main()
pickList = readList()
singleList = genList(pickList)
local text =''
for designer,songs in pairs(singleList) do
text = text .."'''".. designer.."'''\n"
text = text .. head
for songid,diff in pairs(songs) do
text = text .. songUnit(songid)
end
text = text .. '|}'
end
-- for i,ii in pairs(songDiffDesigner) do
-- text = text .. songUnit(i)
-- end
-- return tableToString(songDiffDesigner)
-- return list1
return text
end
return p