local MonthactExcel = require("excel.monthAct")
local Msg = require("core.Msg")
local Grid = require("bag.Grid")
local MonthDrunkery = require("monthAct.MonthDrunkery")
local MonthHecJuex = require("monthAct.MonthHecJuex")
local MonthHzz = require("monthAct.MonthHzz")
local MonthSummon = require("monthAct.MonthSummon")  

MONTH_ACT_TYPE_1 = 1 -- 好战者活动 龙争虎斗  竞技高手
MONTH_ACT_TYPE_2 = 2 -- 酒馆达标 悬赏大师
MONTH_ACT_TYPE_3 = 3 -- 合成与觉醒 百炼成神
MONTH_ACT_TYPE_6 = 6 -- 转盘高抽 猛将如虎 招贤纳士

-- 检查月度活动是否到期(创角开始每30天一轮)
function checkActEndTime(human)    
    local now  = os.time()
    if human.db.actMonthEndTime and now < human.db.actMonthEndTime  then
        return
    end

    local initTime = human.db.actMonthEndTime or human.db.createTime     
    local subTime = now - initTime + 1
    local subMonth = math.ceil(subTime/2592000)    -- 86400 * 30   30天秒数
    local addTime =  2592000 * subMonth
    human.db.actMonthEndTime = initTime + addTime 
    -- 清空任务进度等
    human.db.actMonthTask = nil 
end

function getActLeftTime(human)
    checkActEndTime(human) 
    return human.db.actMonthEndTime - os.time()
end

-- 查询指定月度活动数据
function query(human, actType)
    checkActEndTime(human)
    
    if actType == MONTH_ACT_TYPE_1 then
		MonthHzz.query(human)
	elseif actType == MONTH_ACT_TYPE_2 then
        MonthDrunkery.query(human)
	elseif actType == MONTH_ACT_TYPE_3 then
        MonthHecJuex.query(human)
    elseif actType == MONTH_ACT_TYPE_6 then
        MonthSummon.query(human)
	end
end


