全站通知:
模块:EventSummary
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:EventSummary/doc创建
local p = {}
local getArgs = require('Module:Arguments').getArgs
local inArray = require('Module:Util').inArray
function p._test(frame)
local query = {
['_id'] = {['$regex'] = '^Data:EventSummary2.tabx.'},
['EventBannerID'] = {['$exists'] = true},
}
local options = {
['sort'] = {
['cd'] = 1
}
}
local data = mw.huiji.db.find(query,options)
return mw.dumpObject(data)
end
function p.render(frame)
local args = frame.args
local query = {
['_id'] = {['$regex'] = '^Data:EventSummary2.tabx.'},
['EventBannerID'] = {['$exists'] = true},
}
local options = {
['sort'] = {
['cd'] = 1
}
}
local data = mw.huiji.db.find(query,options)
local html = mw.html.create()
local tempString = ""
local top_div = html
top_div = html
:tag('div')
:tag('div')
:tag('table'):addClass('flex shadow table-cd')
local server = args["server"] or ""
local startNum = args["startCD"] or 0
count = 0
featureCount = 0
for k,v in ipairs(data) do
local cd = v['cd'] or ""
if (v.cd==nil)then
local abc= "skipped"
elseif (tonumber(v.cd) > tonumber(startNum) ) then
--定义内容--
local FeatureID = tostring(v['FeatureID']) or "0"
local FeatureNameCN = v["FeatureNameCN"] or ""
local ScoutID = tostring(v["ScoutID"]) or "0"
local ScoutNameCN = v["ScoutNameCN"] or ""
local EventBannerID = tostring(v["EventBannerID"]) or ""
local EventNameCN = v["EventNameCN"] or ""
local EventType = v["EventType"] or ""
local livefes = v["livefes"] or ""
local livefesBannerID = tostring(v["livefesBannerID"]) or ""
local livefesType = v["livefesType"] or "Livefes"
if livefesType ~= "超育成" then
livefesType = livefesType:gsub("^%l", string.upper)
end
--定义活动背景样式--
local EventTypeClassName = "event-1"
local EventTypeWikitextName = "Unit"
if (EventType == "新曲活动") then
EventTypeClassName = "event-1"
EventTypeWikitextName = "Unit"
elseif (EventType == "洗牌活动") then
EventTypeClassName = "event-2"
EventTypeWikitextName = "Shuffle"
elseif (EventType == "巡演活动") then
EventTypeClassName = "event-3"
EventTypeWikitextName = "Tour"
end
--配置时间--
local timeFeatureString = p._getCampaignTime(tonumber(cd),"feature",nil)
local timeScoutString = p._getCampaignTime(tonumber(cd),"scout",nil)
local timeEventString = p._getCampaignTime(tonumber(cd),"event",nil)
local timeLivefesString = p._getCampaignTime(tonumber(cd),"livefes",livefesType)
if(server == "EN") then
timeFeatureString = p._getCampaignTimeEN(tonumber(cd),"feature",nil)
timeScoutString = p._getCampaignTimeEN(tonumber(cd),"scout",nil)
timeEventString = p._getCampaignTimeEN(tonumber(cd),"event",nil)
timeLivefesString = p._getCampaignTimeEN(tonumber(cd),"livefes",livefesType)
end
--feature轮空--
local ScoutIDCompare = tonumber(FeatureID) or 0
local featureText = ""
if( ScoutIDCompare < 1) then
FeatureID = "skipped"
timeFeatureString="本次轮空"
else
FeatureID = tostring(FeatureID)
featureCount = featureCount + 1
end
--配置Feature序号
if (math.ceil(featureCount/49)<=1) then
featureText = "Feature"
else
featureText = "Feature"..tostring(math.ceil(featureCount/49)) -- 向上取整
end
--配置图片
local feature = p._getImage('Gacha_banner_rectangle1_'..FeatureID..'.png',230,FeatureNameCN)
local scout=p._getImage('Gacha_banner_rectangle1_'..ScoutID..'.png',230,ScoutNameCN)
local event=p._getImage('Chapter_campaign_rectangle1_'..EventBannerID..'.png',230,EventNameCN)
local livefes=p._getImage('My_page_banner_rectangle1_'..livefesBannerID..'.png',230,livefes)
top_div:tag('tr')
:tag('td'):addClass('box0')
:tag('div')
:wikitext("第<br>"..cd.."<br>期")
:done()
:done()
:tag('td'):addClass('box1 feature')
:tag('div'):addClass('box-background-text'):wikitext(featureText):done()
:tag('div'):addClass('boxs'):wikitext(feature)
:tag('div'):addClass('time'):wikitext(timeFeatureString):done()
:done()
:done()
:tag('td'):addClass('box1 scout')
:tag('div'):addClass('box-background-text'):wikitext("Scout"):done()
:tag('div'):addClass('boxs'):wikitext(scout)
:tag('div'):addClass('time'):wikitext(timeScoutString):done()
:done()
:done()
:tag('td'):addClass('box1 '..EventTypeClassName)
:tag('div'):addClass('box-background-text'):wikitext(EventTypeWikitextName):done()
:tag('div'):addClass('boxs'):wikitext(event)
:tag('div'):addClass('time'):wikitext(timeEventString):done()
:done()
:done()
:tag('td'):addClass('box1 livefes')
:tag('div'):addClass('box-background-text'):wikitext(livefesType):done()
:tag('div'):addClass('boxs'):wikitext(livefes)
:tag('div'):addClass('time'):wikitext(timeLivefesString):done()
:done()
:done()
:done()
end
end
top_div:allDone()
return tostring(top_div)
end
function p._getCDJP(cd,type)
local startYear = 2020
local startMonth = 3
--确定开始日期
local lastTenDays = cd%2
local monthAdd = math.floor(cd/2)
local currentMonth = (startMonth + monthAdd)%12
if currentMonth == 0 then
currentMonth = 12
end
local yearAdd = math.floor((startMonth + monthAdd-1)/12)
local currentYear = startYear + yearAdd
local monthAllDay = os.date("%d",os.time({year=currentYear,month=currentMonth+1,day=0}))
lastTenDaysString = ""
local campaignStartDay = 0
local campaignStartMonth = currentMonth
local campaginStartYear = currentYear
local campaignEndDay = 0
local campaignEndMonth = currentMonth
local campaginEndYear = currentYear
if lastTenDays==1 then
lastTenDaysString = "上旬"
--算开始日期
if(type == "feature") then
campaignStartDay = 25
elseif(type == "scout") then
campaignStartDay = monthAllDay-1
elseif(type == "event") then
campaignStartDay = monthAllDay
elseif(type == "livefes") then
campaignStartDay = 9
campaignStartMonth = currentMonth +1
if(campaignStartMonth > 12) then
campaignStartMonth = campaignStartMonth - 12
campaginStartYear = currentYear + 1
end
end
--算结束日期
if(type == "feature") then
campaignEndDay = 10
campaignEndMonth = currentMonth +1
if(campaignEndMonth > 12) then
campaignEndMonth = campaignEndMonth - 12
campaginEndYear = currentYear + 1
end
elseif(type == "scout") then
campaignEndDay = 14
campaignEndMonth = currentMonth +1
if(campaignEndMonth > 12) then
campaignEndMonth = campaignEndMonth - 12
campaginEndYear = currentYear + 1
end
elseif(type == "event") then
campaignEndDay = 8
campaignEndMonth = currentMonth +1
if(campaignEndMonth > 12) then
campaignEndMonth = campaignEndMonth - 12
campaginEndYear = currentYear + 1
end
elseif(type == "livefes") then
campaignEndDay = 14
campaignEndMonth = currentMonth +1
if(campaignEndMonth > 12) then
campaignEndMonth = campaignEndMonth - 12
campaginEndYear = currentYear + 1
end
end
else
lastTenDaysString = "下旬"
--算开始日期
if(type == "feature") then
campaignStartDay = 10
elseif(type == "scout") then
campaignStartDay = 14
elseif(type == "event") then
campaignStartDay = 15
elseif(type == "livefes") then
campaignStartDay = 24
end
--算结束日期
if(type == "feature") then
campaignEndDay = 25
elseif(type == "scout") then
campaignEndDay = monthAllDay-1
elseif(type == "event") then
campaignEndDay = 23
elseif(type == "livefes") then
campaignEndDay = monthAllDay-1
end
end
local resultDateStart = string.format("%d.%02d.%02d",campaginStartYear,campaignStartMonth,campaignStartDay)
local resultDataEnd = string.format("%d.%02d.%02d",campaginEndYear,campaignEndMonth,campaignEndDay)
return(resultDateStart.."-"..resultDataEnd)
end
function p._getCDCN(cd,type,year,month,day)
return p._getCDBK(cd,type,2020,11,30)
end
function p._getCDEN(cd,type,year,month,day)
return p._getCDBK(cd,type,2022,6,20)
end
function p._getCDBK(cd,type,getYear,getMonth,getDay)
local startYear = getYear
local startMonth = getMonth
local startDay = getDay
--确定开始日期
startDate = os.date("*t",os.time({day=startDay,month=startMonth,year=startYear}))
startDate.day = startDate.day + (cd-1)*(7+7)
campaignStartDate = os.date("*t",os.time(startDate))
campaignEndDate = os.date("*t",os.time(startDate))
if(type =="feature")then
campaignStartDate = campaignStartDate
campaignEndDate.day = campaignEndDate.day + 7 + 7
elseif(type == "scout")then
campaignStartDate.day = campaignStartDate.day + 4
campaignEndDate.day = campaignEndDate.day +4 + 7 + 7
elseif(type == "event")then
campaignStartDate.day = campaignStartDate.day + 5
campaignEndDate.day = campaignEndDate.day +5 + 7 + 1
elseif(type == "livefes")then
campaignStartDate.day = campaignStartDate.day + 7 + 7
campaignEndDate.day = campaignEndDate.day + 7 + 7 + 5
end
local campaignStartDate = os.date("*t",os.time(campaignStartDate))
local campaignEndDate = os.date("*t",os.time(campaignEndDate))
local resultDateStart = string.format("%d.%02d.%02d",campaignStartDate.year,campaignStartDate.month,campaignStartDate.day)
local resultDateEnd = string.format("%d.%02d.%02d",campaignEndDate.year,campaignEndDate.month,campaignEndDate.day)
return(resultDateStart.."-"..resultDateEnd)
end
function p._getCampaignTime(cd,type,livefes)
JPtime = "【JP】"..p._getCDJP(cd,type)
CNtime = "【CN】"..p._getCDCN(cd,type)
if livefes == "Cover" then
return JPtime.."<br>".."【国服】skipped"
else
return JPtime.."<br>"..CNtime
end
end
function p._getCampaignTimeEN(cd,type,livefes)
JPtime = "【JP】"..p._getCDJP(cd,type)
CNtime = "【EN】"..p._getCDEN(cd,type)
if livefes == "Cover" then
return JPtime.."<br>".."【EN】skipped"
else
return JPtime.."<br>"..CNtime
end
end
function p._getImage(path,size,link)
local res = ''
if path ~= nil then
res = '[[file:'..path..'|'..size..'px'..'|link='..link..']]'
else
res = '[[file:Music_loading_card.png|'..size..'px'..'|link='..link..']]'
end
return res
end
return p