「Module:Songtable」:修訂間差異

增加 810 位元組 、​ 2021年5月20日 (星期四)
無編輯摘要
無編輯摘要
無編輯摘要
行 1: 行 1:
local getArgs = require('Module:Arguments').getArgs
local p = {}
local p = {}


function Mergecheck(ta,tb,tc,td)
function timeCov(t)
-- 输入4个值,检查合并关系
return os.date("(%Y/%m/%d)", t)
--输出一个带两个值的table,分别为合并后的块数和一个带有“第几块向右合并几块“的table
end
 
function dateArg(v,d,t)
if not(v and d) then return nil end
local box,a,b,c = mw.html.create( 'div' ),mw.html.create( 'div' ),mw.html.create( 'div' ),mw.html.create( 'div' )
box:addClass( "date-box" )
a:wikitext(t)
b:wikitext(v..'<br>'..'('..tostring(d)..')')
box:wikitext(tostring(a))
  :wikitext(tostring(b))
  :wikitext(tostring(c))
return tostring(box)
end
function dateData(v,d,t)
if not(v and d) then return nil end
local box,a,b,c = mw.html.create( 'div' ),mw.html.create( 'div' ),mw.html.create( 'div' ),mw.html.create( 'div' )
box:addClass( "date-box" )
a:wikitext(t)
b:wikitext('v'..v..'<br>'..tostring(timeCov(d)))
box:wikitext(tostring(a))
  :wikitext(tostring(b))
  :wikitext(tostring(c))
return tostring(box)
end


local pst=tostring(ta)
function merge(list)
local prs=tostring(tb)
local merge
local ftr=tostring(tc)
if list[4] then merge={1,1,1,1} else merge={1,1,1} end
local byd=tostring(td)
local o
local blocksnum=nil --合并后有多少块
if list[4] then o=4 else o=3 end
local mergenum={1,1,1,1} --在哪块向右合并多少
local result={}


local trun1,trun2,trun3,bydyes=false,false,false,false
if list[4] then
if (pst==prs) then trun1=true  end
if list[4]==list[3] then merge[3]=merge[3]+merge[4] merge[4]=0 end
if (prs==ftr) then trun2=true  end
if (ftr==byd) then trun3=true  end
if (byd~=nil) then bydyes=true end
--trun1 aaxx trun2 xaax trun3 xxaa
--genre1:aaaa genre2:abbb genre3:aaab genre4:aabb
--genre5:aabc genre6:abbc genre7:abcc genre8:abcd
if bydyes then
if trun1    and trun2     and trun3    then blocksnum=1 mergenum[1]=4   end
if not(trun1)  and trun2    and trun3    then blocksnum=2 mergenum[2]=3  end
if trun1    and trun2     and not(trun3) then blocksnum=2 mergenum[1]=3   end
if trun1    and not(trun2)  and trun3    then blocksnum=2 mergenum[1]=2 mergenum[2]=2 end
if trun1    and not(trun2)  and not(trun3)  then blocksnum=3 mergenum[1]=2  end
if not(trun1)  and trun2    and not(trun3)  then blocksnum=3 mergenum[2]=2  end
if not(trun1)  and not(trun2)  and trun3    then blocksnum=3 mergenum[3]=2  end
if not(trun1)  and not(trun2)  and not(trun3) then blocksnum=4          end
else
if trun1  and trun2  then blocksnum=3 mergenum[1]=3 end
if not(trun1) and trun2  then blocksnum=2 mergenum[2]=2 end
if trun1  and not(trun2)  then blocksnum=2 mergenum[1]=2 end
if not(trun1) and not(trun2)  then blocksnum=3        end
end
end


if list[3]==list[2] then merge[2]=merge[2]+merge[3] merge[3]=0 end


result[1]=blocksnum
if list[2]==list[1] then merge[1]=merge[1]+merge[2] merge[2]=0 end
result[2]=mergenum


return result
for i=1,o do
 
if merge[i]==0 then
end
merge[i]='display:none'
 
else
function RegularText(text,byd)
merge[i]='grid-column-start: span '..merge[i]..';'
local o=1
end
local Secondarybox={}
local result=""
for i=1,11 do
Secondarybox[o] =mw.html.create("div")
Secondarybox[o]
:wikitext(text[o])
:addClass("Sbox"..o)
if byd==true and (o==1 or o==2) then Secondarybox[o]:cssText("grid-column: 1 / span 5;") end
if o==3 or o==5 or o==7 or o==9 or o==11 then Secondarybox[o]:cssText("grid-column: 1 / span 1;") end
if byd==true and (o==4 or o==6 or o==8 or o==10) then Secondarybox[o]:cssText("grid-column: 2 / span 4;") end
if byd==false and (o==1 or o==2) then Secondarybox[o]:cssText("grid-column: 1 / span 4;") end
if byd==false and (o==4 or o==6 or o==8 or o==10) then Secondarybox[o]:cssText("grid-column: 2 / span 3;") end
result=result..tostring(Secondarybox[o])
o=o+1
end
end
return result
return merge
end
end


function SplitText(text)
function p.main(frame)
local Mergecheck=Mergecheck(text[1],text[2],text[3],text[4]) --获取合成的转换信息
local args = getArgs(frame)
local Secondarybox={}
return p._main(args)
local result=""
for i=1,3 do
local op=1
for i=1,4 do
if text[op]==nil then text[op],text[op+1]=text[op+1],text[op] end
if text[op]==text[op-1] then text[op]=text[op+1] end
op=op+1
end
end
local c,p,o=1,1,12
for i=1,Mergecheck[1] do
local mergenumber=Mergecheck[2][p]
Secondarybox[o] =mw.html.create("div")
Secondarybox[o]
:wikitext(tostring(text[p]))
:addClass("Sbox"..o)
:cssText("grid-column: "..tostring(c+1).." / span "..mergenumber) --第几个块获取第几个块的合成信息
result=result..tostring(Secondarybox[o])
c=c+mergenumber
o=o+1
p=p+1
end
return tostring(result)
end
end


function EasySplitText(ain,byd)
function p._main(args)
text=ain
local data=require("Module:Sandbox/月汐月汐月/data").getMobile(args['曲名'])
local Secondarybox={}
local dataNs=require("Module:Sandbox/月汐月汐月/data").getNS(args['曲名'])
local result=""
local byd
if args['Beyond等级'] or data('bydRating') then byd=true else byd=false end
if byd==true
local pstCd,prsCd,ftrCd,bydCd
then
if args['note编写'] then
local o,p=1,21
pstCd,prsCd,ftrCd,bydCd=args['note编写'],args['note编写'],args['note编写'],args['note编写']
for i=1,15 do
Secondarybox[o]=mw.html.create("div")
Secondarybox[o]
:wikitext(tostring(text[o]))
:addClass("Sbox"..p)
result=result..tostring(Secondarybox[o])
o,p=o+1,p+1
end
else
else
local o,p=1,21
if args['FutureNote编写'] then
for i=1,14 do
pstCd,prsCd,ftrCd,bydCd=args['PastNote编写'],args['PresentNote编写'],args['FutureNote编写'],args['BeyondNote编写']
if o~=5 and o~=10
else
then
pstCd,prsCd,ftrCd,bydCd=data('pstChartDesigner'),data('prsChartDesigner'),data('ftrChartDesigner'),data('bydChartDesigner')
Secondarybox[o]=mw.html.create("div")
Secondarybox[o]
:wikitext(text[o])
:addClass("Sbox"..p)
result=result..tostring(Secondarybox[o])
end
o,p=o+1,p+1
end
end
end
end
Secondarybox[16]=mw.html.create("div")
local span
Secondarybox[16]
if byd then
:wikitext(text[16])
span=merge({ pstCd,prsCd,ftrCd,bydCd })
:addClass("Sbox36")
else
result=result..tostring(Secondarybox[16])
span=merge({ pstCd,prsCd,ftrCd })
 
end
if byd==true
local pstCdNs,prsCdNs,ftrCdNs,bydCdNs
then 
if args['note编写NS'] then
pstCdNs,prsCdNs,ftrCdNs=args['note编写'],args['note编写'],args['note编写']
if text[18]==nil
else
then
if args['PastNote编写NS'] and args['PresentNote编写NS'] and args['FutureNote编写NS'] then
Secondarybox[17]=mw.html.create("div")
pstCdNs,prsCdNs,ftrCdNs=args['PastNote编写NS'],args['PresentNote编写NS'],args['FutureNote编写NS']
Secondarybox[17]
:wikitext(text[17])
:addClass("Sbox37")
:cssText("grid-column: 2 / span 4;")
result=result..tostring(Secondarybox[17])
else
else
Secondarybox[17]=mw.html.create("div")
pstCdNs,prsCdNs,ftrCdNs=dataNs('pstChartDesigner'),dataNs('prsChartDesigner'),dataNs('ftrChartDesigner')
Secondarybox[17]
:wikitext(text[17])
:addClass("Sbox37")
:cssText("grid-column: 2 / span 3;")
result=result..tostring(Secondarybox[17])
Secondarybox[18]=mw.html.create("div")
Secondarybox[18]
:wikitext(text[18])
:addClass("Sbox38")
result=result..tostring(Secondarybox[18])
end
end
else
Secondarybox[17]=mw.html.create("div")
Secondarybox[17]
:wikitext(text[17])
:addClass("Sbox37")
:cssText("grid-column: 2 / span 3;")
result=result..tostring(Secondarybox[17])
end
end
local spanNs=merge({ pstCdNs,prsCdNs,ftrCdNs })
return tostring(result)
local infoList={
end
[1]={
args['曲名'],data('title'),{ ['id']='title' }
},
[2]={
'[[File:Wikipedia-Test_Administrator.png|256px]]','image',{ ['id']='top-image' }
},
[3]={
'[[File:Wikipedia-Test_Administrator.png|256px]]','image',{ ['id']='right-image' }
},
[4]={
'曲目信息','',{ ['class']='header' }
},
[5]={
'曲师','',{ ['class']='label' }
},
[6]={
args['编曲'],data('artist'),{ ['class']='data' }
},
[7]={
'曲包','',{ ['class']='label' }
},
[8]={
args['曲包'],data('set'),{ ['class']='data' }
},
[9]={
'时长','',{ ['class']='label' }
},
[10]={
args['时长'],'空',{ ['class']='data' }
},
[11]={
'BPM','',{ ['class']='label' }
},
[12]={
args['BPM'],data('bpm'),{ ['class']='data' }
},
[13]={
'触控和手柄 谱面信息','',{ ['id']='all-play-header' , ['class']='header' }
},
[14]={
'触控 谱面信息','',{ ['id']='mobile-play-header' , ['class']='header' }
},
[15]={
'难度','',{ ['class']='label' }
},
[16]={
'[Past]','',{ ['class']='pst-label' }
},
[17]={
'[Present]','',{ ['class']='prs-label' }
},
[18]={
'[Future]','',{ ['class']='ftr-label' }
},
[19]={
'[Beyond]','',{ ['class']='byd-label' }
},
[20]={
'等级','',{ ['class']='label' }
},
[21]={
args['Past等级'],data('pstRating'),{ ['class']='pst-data' }
},
[22]={
args['Present等级'],data('prsRating'),{ ['class']='prs-data' }
},
[23]={
args['Future等级'],data('ftrRating'),{ ['class']='ftr-data' }
},
[24]={
args['Beyond等级'],data('bydRating'),{ ['class']='byd-data' }
},
[25]={
'note数量','',{ ['class']='label' }
},
[26]={
args['PastNote'],'空',{ ['class']='pst-data' }
},
[27]={
args['PresentNote'],'空',{ ['class']='prs-data' }
},
[28]={
args['FutureNote'],'空',{ ['class']='ftr-data' }
},
[29]={
args['BeyondNote'],'空',{ ['class']='byd-data' }
},
[30]={
'谱面设计','',{ ['class']='label' }
},
[31]={
pstCd,data('pstChartDesigner'),{ ['class']='pst-data' },span[1]
},
[32]={
prsCd,data('prsChartDesigner'),{ ['class']='prs-data' },span[2]
},
[33]={
ftrCd,data('ftrChartDesigner'),{ ['class']='ftr-data' },span[3]
},
[34]={
bydCd,data('bydChartDesigner'),{ ['class']='byd-data' },span[4]
},
[35]={
'NS版手柄 谱面信息','',{ ['class']='header ns',['id']='ns-play-header' }
},
[36]={
'难度','',{ ['class']='label ns' }
},
[37]={
'[Past]','',{ ['class']='pst-label ns' }
},
[38]={
'[Present]','',{ ['class']='prs-label ns' }
},
[39]={
'[Future]','',{ ['class']='ftr-label ns' }
},
[40]={
'[Beyond]','',{ ['class']='byd-label ns' }
},
[41]={
'等级','',{ ['class']='label ns' }
},
[42]={
args['Past等级NS'],dataNs('pstRating'),{ ['class']='pst-data ns' }
},
[43]={
args['Present等级NS'],dataNs('prsRating'),{ ['class']='prs-data ns' }
},
[44]={
args['Future等级NS'],dataNs('ftrRating'),{ ['class']='ftr-data ns' }
},
[45]={
args['Beyond等级NS'],dataNs('bydRating'),{ ['class']='byd-data ns' }
},
[46]={
'note数量','',{ ['class']='label ns' }
},
[47]={
args['PastNoteNS'],args['PastNote'],{ ['class']='pst-data ns' }
},
[48]={
args['PresentNoteNS'],args['PresentNote'],{ ['class']='prs-data ns' }
},
[49]={
args['FutureNoteNS'],args['FutureNote'],{ ['class']='ftr-data ns' }
},
[50]={
'无','空',{ ['class']='byd-data ns' }
},
[51]={
'谱面设计','',{ ['class']='label ns' }
},
[52]={
pstCdNs,dataNs('pstChartDesigner'),{ ['class']='pst-data ns' },spanNs[1]
},
[53]={
prsCdNs,dataNs('prsChartDesigner'),{ ['class']='prs-data ns' },spanNs[2]
},
[54]={
frtCdNs,dataNs('ftrChartDesigner'),{ ['class']='ftr-data ns' },spanNs[3]
},
[55]={
'无','',{ ['class']='byd-data ns' },spanNs[4]
},
[56]={
'背景','',{ ['class']='label' }
},
[57]={
args['背景'],data('bg'),{ ['class']='data' }
},
[58]={
'更新时间','',{ ['id']='update-data-label',['class']='label' }
},
[59]={
dateArg(args['更新版本'] , args['更新时间'] , '移动版:' ) , dateData( data('version') , data('date') , '移动版:' ) ,{ ['id']='mobile-date-normal',['class']='data'}
},
[60]={
dateArg(args['Beyond更新版本'] , args['Beyond更新时间'] ,''  ) ,'空',{ ['id']='mobile-date-byd',['class']='data'}
},
[61]={
dateArg(args['更新版本NS'] , args['更新时间NS'] , 'NS版:' ),dateArg('1.0.0c' ,'2021/5/18' , 'NS版:' ),{ ['id']='ns-date-normal',['class']='data ns'}
},
[62]={
'无','',{ ['id']='ns-date-byd',['class']='data ns'}
}
}


function autoimage(image)
local box = mw.html.create( 'div' )
box:addClass( "songbox" )
end
if byd then box:addClass( "byd" ) end
if data('side')==1 then box:addClass( "conflict" ) else box:addClass( "light" ) end
if args['更新版本NS'] or dataNs('version') then
box:addClass( "ns-box" )
if
args['Past等级NS'] or args['Present等级NS'] or args['Future等级NS'] or args['PastNote编写NS'] or args['PresentNote编写NS'] or args['FutureNote编写NS'] or
args['PastNoteNS'] or args['PresentNoteNS'] or args['FutureNoteNS'] or
data('pstRating')~=dataNs('pstRating') or data('prsRating')~=dataNs('prsRating') or data('ftrRating')~=dataNs('ftrRating') or
data('pstChartDesigner')~=dataNs('pstChartDesigner') or data('prsChartDesigner')~=dataNs('prsChartDesigner') or data('ftrChartDesigner')~=dataNs('ftrChartDesigner')


function p.box(frame)
then else box:addClass( "ns-same" ) end
--主函数
end
local RegularGroup={} -- 不会进行拆分的组
if args['Beyond更新版本'] and args['Beyond更新时间'] then box:addClass( 'mobile-byd-date' ) end
local SplitGroup={} --会进行4等拆分的组
local EasySplitGroup={} --会进行2等拆分的组
local bydyes
local column=""
local byd=tonumber(frame:getParent().args["Beyond等级"])
if byd then bydyes=true else bydyes=false end
if bydyes==true then column="10% 22.5% 22.5% 22.5% 22.5%" else column="10% 30% 30% 30%" end
local songname=frame:getParent().args["曲名"]
local boxList={}
if frame:getParent().args["第二曲名"] then songname=songname..frame:getParent().args["第二曲名"] end
for i,o in ipairs(infoList) do
boxList[i] = mw.html.create( 'div' )
-- 1-11对应表 example: image class:Sbox1
boxList[i]
RegularGroup[1]="image"
:attr( infoList[i][3] )
RegularGroup[2]=songname
:cssText( infoList[i][4] )
RegularGroup[3]="编曲"
if infoList[i][1]
RegularGroup[4]=frame:getParent().args["编曲"]
then
RegularGroup[5]="曲包"
boxList[i]:wikitext( infoList[i][1] )
RegularGroup[6]=frame:getParent().args["曲包"]
else
RegularGroup[7]="时长"
boxList[i]:wikitext( infoList[i][2] )
RegularGroup[8]=frame:getParent().args["时长"]
end
RegularGroup[9]="BPM"
box:wikitext(tostring(boxList[i]))
RegularGroup[10]=frame:getParent().args["BPM"]
end
RegularGroup[11]="谱师"
local notewrite=frame:getParent().args["Note编写"] --临时转换
if notewrite~=nil then SplitGroup[1],SplitGroup[2],SplitGroup[3],SplitGroup[4]=notewrite,notewrite,notewrite,notewrite end
--如果没有分难度谱师参数输入,直接用谱师的值
-- 12-14 四谱师 如空留位
SplitGroup[1]=frame:getParent().args["PastNote编写"
SplitGroup[2]=frame:getParent().args["PresentNote编写"]
SplitGroup[3]=frame:getParent().args["FutureNote编写"]
SplitGroup[4]=frame:getParent().args["BeyondNote编写"
--依次对应21-33
EasySplitGroup[1]="难度"
EasySplitGroup[2]="Past"
EasySplitGroup[3]="Present"
EasySplitGroup[4]="Future"
EasySplitGroup[5]="Beyond"
EasySplitGroup[6]="等级"
EasySplitGroup[7]=frame:getParent().args["Past等级"]
EasySplitGroup[8]=frame:getParent().args["Present等级"]
EasySplitGroup[9]=frame:getParent().args["Future等级"]
EasySplitGroup[10]=frame:getParent().args["Beyond等级"]
EasySplitGroup[11]="物量"
EasySplitGroup[12]=frame:getParent().args["PastNote"]
EasySplitGroup[13]=frame:getParent().args["PresentNote"]
EasySplitGroup[14]=frame:getParent().args["FutureNote"]
EasySplitGroup[15]=frame:getParent().args["BeyondNote"]
EasySplitGroup[16]="画师"
EasySplitGroup[17]=frame:getParent().args["画师"]
EasySplitGroup[18]=frame:getParent().args["Beyond画师"]
EasySplitGroup[19]="更新时间"
EasySplitGroup[20]=frame:getParent().args["更新版本"]
EasySplitGroup[21]=frame:getParent().args["Beyond更新版本"]
EasySplitGroup[22]=frame:getParent().args["更新时间"]
EasySplitGroup[23]=frame:getParent().args["Beyond更新时间"]
 
local texta,textb,textc="","",""
texta=RegularText(RegularGroup,bydyes)
textb=SplitText(SplitGroup)
textc=EasySplitText(EasySplitGroup,bydyes)
--将参数封装为table变量,输入进函数返回转换后的字符串。
local endstring=texta..textb..textc
local box =mw.html.create("div")
box
:addClass("box")
:cssText("grid-template-columns:"..tostring(column))
:wikitext(endstring)
return tostring(box)
return box
end
end


return p
return p