本WIKI由cl的光玊申请于2021年08月04日创建。本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~

全站通知:

模块:日历函数

来自偶像荣耀/idoly prideWIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:日历函数/doc创建

local d = require('模块:日历数据')
local colorTb = {
    ["通常卡池"] = "#87CEFA",
    ["限定卡池"] = "#FF7C80",
    ["复刻卡池"] = "#FF9C9F",
    ["生日卡池"] = "#FF7C80",
    ["VENUS对战"] = "#EAC3FF",
    ["联合对战"] = "#B6FFB6",
    ["定例活动"] = "#FFFF99",
    ["links活动"] = "#66FF66",
    ["multi links活动"] = "#66FF66",
    ["VENUS赛事活动"] = "#66FF66",
    ["摄影活动"] = "#66FF66",
    ["私信任务活动"] = "#66FF66",
    ["合宿活动"] = "#66FF66",
    ["形象训练活动"] = "#66FF66",
    ["若恋活动"] = "#66FF66",
    ["VENUS联赛"] = "#808069",
    ["medley live活动"] = "#66FF66",
    ["双六活动"] = "#66FF66"
}

local p = {}

function p.getAllData(frame)
	local dtTb = d.tb
	local outStr = ""
	
	for _, mTb in pairs(dtTb) do
		for i=1,#mTb do
			outStr = outStr .. p.getSpanStr(mTb,i)
		end
	end
	return outStr
end

function p.getDataForWeekCalendar(frame)
	local baseY = frame.args[1]
	local baseM = frame.args[2]
	local outStr = ""
	--当月
	outStr = outStr ..p.getDataByMonth(baseY .. string.format("%02d",baseM))

	--前月
	baseM = frame.args[2] -1
	if baseM == 0 then
		baseM = 12
		baseY = frame.args[1] -1
	end
	outStr = outStr ..p.getDataByMonth(baseY .. string.format("%02d",baseM))
	
	--下月
	baseM = frame.args[2] +1
	if baseM > 12 then
		baseM = 1
		baseY = frame.args[1] +1
	end
	outStr = outStr ..p.getDataByMonth(baseY .. string.format("%02d",baseM))
	
	return outStr
end

function p.getDataByMonth(strYM)
	local dtTb = d.tb
	local outStr = ""
	if dtTb[strYM] ~= nil then 
		for i=1,#dtTb[strYM] do
			outStr = outStr .. p.getSpanStr(dtTb[strYM],i)
		end
	end
	return outStr
end

function p.getSpanStr(dt,i)
	local spanStr = "{0},{1},{2},{3},{4},{5};"
	spanStr=spanStr:gsub("{0}", dt[i]["start"])
	spanStr=spanStr:gsub("{1}", dt[i]["end"])
	spanStr=spanStr:gsub("{2}", dt[i]["title"])
	spanStr=spanStr:gsub("{3}", dt[i]["type"])
	spanStr=spanStr:gsub("{4}", dt[i]["link"])
	if colorTb[dt[i]["type"]] ~= nil then
		spanStr=spanStr:gsub("{5}", colorTb[dt[i]["type"]])
	else
		spanStr=spanStr:gsub("{5}", "")
	end
		
	return spanStr
end

return p