SCFC 1 год назад
Родитель
Сommit
b29b0477c8

+ 1 - 0
script/common/Log.lua

@@ -64,6 +64,7 @@ function init()
     --[[遗迹探险插入DB]] LOGID_OSS_YJTX_DB = lua_log.reg("log/oss_yjtx_db", "",0)
     --[[竟技场-王者争霸]] LOGID_JJC_GODWAR = lua_log.reg("log/jjc_godwar","",0)
     --[[开服活动]] LOGID_OSS_OPENSERVER_ACT = lua_log.reg("log/oss_openserver_act","",300)
+    --[[周循环活动]] LOGID_OSS_WEEKLOOP_ACT = lua_log.reg("log/week_loop_act","",300)
 end
 init()
 

+ 1 - 0
script/common/LogDefine.lua

@@ -244,6 +244,7 @@ DEFINE = {
     abs_sign_reward = 248,                   -- 浪漫邂逅签到礼包
     abs_sign_gift = 249,                     -- 浪漫邂逅购买礼包
 	open_server_PowerUpPrize = 250,			 -- 开服活动-战力冲刺
+	week_loop_act			= 251,			 -- 周活动
 	abs_totalReach          = 500,           -- 周期性活动累计
     abs_singleReach         = 501,           -- 周期性活动单次
     draw_ad_reward         = 601,           -- 观看广告送召唤券

+ 7 - 0
script/common/ProtoID.lua

@@ -1271,6 +1271,13 @@ _ENV[1270]="CG_PRESENT_OPEN_POWERUP_QUERY"
 _ENV[1271]="GC_PRESENT_OPEN_POWERUP_QUERY"
 _ENV[1272]="CG_PRESENT_OPEN_POWERUP_GETPRIZE"
 _ENV[1273]="GC_PRESENT_OPEN_POWERUP_GETPRIZE"
+_ENV[1274]="GC_WEEKLOOP_ACT_ALLINFO"
+_ENV[1275]="CG_WEEKLOOP_ACT_HEROQUERY"
+_ENV[1276]="GC_WEEKLOOP_ACT_HEROQUERY"
+_ENV[1277]="CG_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO"
+_ENV[1278]="GC_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO"
+_ENV[1279]="CG_WEEKLOOP_ACT_HEROCHOSEHERO"
+_ENV[1280]="CG_WEEKLOOP_ACT_HERPGETPRIZE"
 _ENV[1301]="CG_XIANZHI_SHOP_QUERY"
 _ENV[1302]="GC_XIANZHI_SHOP_QUERY"
 _ENV[1303]="CG_XIANZHI_SHOP_BUY"

+ 35 - 0
script/common/WeekendLoopActDefine.lua

@@ -0,0 +1,35 @@
+--------------------------------
+-- 文件名       :  WeekendLoopActDefine.lua
+-- 文件说明     :  周末冲刺-活动通用定义
+-- 创建时间     :   2024/11/25
+-- 创建人       :   FC
+--------------------------------
+
+-- WEEKACT_OPENDAY = 7         -- 开启日期 周六
+WEEKACT_OPENDAY = 4         -- 开启日期 周六
+WEEKACT_ENDDAY = 6          -- 结束日期 周三
+WEEKACT_TIME = 0            -- 开启结束时间
+
+WEEKACT_STATE_NONE    =   0       -- 不可领取
+WEEKACT_STATE_CANGET  =   1       -- 可领取
+WEEKACT_STATE_FINISH  =   2       -- 已领取
+
+WEEKACT_HEROSTAR_MAILID = 7009
+WEEKACT_HEROSTAR_HREOLEN = 30
+
+-- 忽略下发的英雄ID
+TWEEKACT_HEROSTAR_IGNORE = 
+{
+    [8] = 1,
+    [9] = 1,
+    [88] = 1,
+    [888] = 1,
+    [8888] = 1,
+}
+
+-- 下发的英雄稀有度要求
+TWEEKACT_HEROSTAR_RARITY = 
+{
+    [4] =   1,
+    [5] =   1,
+}

+ 22 - 0
script/module/WeekendLoopActivity/Handler.lua

@@ -0,0 +1,22 @@
+local WeekendLoopActManger = require("WeekendLoopActivity.WeekendLoopActManager")
+local WeekLoopActHeroStar = require("WeekendLoopActivity.WeekendLoopActHeroStar")
+
+-- 请求英雄升星活动信息
+function CG_WEEKLOOP_ACT_HEROQUERY(human, msg)
+    WeekLoopActHeroStar.WeekActHeroStar_Query(human)
+end
+
+-- 英雄升星- 请求所有英雄简略信息
+function CG_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO(human, msg)
+    WeekLoopActHeroStar.WeekActHeroStar_GetAllHeroInfo(human)
+end
+
+-- 英雄升星 - 选择英雄
+function CG_WEEKLOOP_ACT_HEROCHOSEHERO(human, msg)
+    WeekLoopActHeroStar.WeekActHeroStar_ChoseHero(human, msg.nID)
+end
+
+-- 英雄升星 - 领取奖励
+function CG_WEEKLOOP_ACT_HERPGETPRIZE(huamn, msg)
+    WeekLoopActHeroStar.WeekActHeroStar_GetPrize(huamn)
+end

+ 69 - 0
script/module/WeekendLoopActivity/Proto.lua

@@ -0,0 +1,69 @@
+local ItemData = require("bag.Proto").ItemData
+local HeroSimple = require("hero.Proto").HeroSimple
+
+tActInfo = 
+{
+    {"ID",          1,      "short"},           -- 子活动ID
+    {"name",        1,      "string"},          -- 子活动名
+    {"nSortID",	    1,		"short"},		    -- 排序id
+    {"nPanelID",	1,		"short"},		    -- 面板id
+	{"nIcon",		1,		"int"},			    -- 活动图标
+    {"nRed",        1,      "byte"},            -- 是否有红点 1 存在 0 不存在
+}
+
+-- 玩家登录主动下发活动信息(活动开启时)
+GC_WEEKLOOP_ACT_ALLINFO = {
+    {"nStartTime",       1,     "int"},     -- 开启时间
+    {"nEendTime",        1,     "int"},     -- 结束时间
+    {"tActID",          10,     tActInfo},   -- 活动信息
+}
+
+---------------------- 英雄升星 ----------------------
+HeroPrize = {
+    {"nID",             1,      "int"},        -- 奖励编号
+    {"nState",          1,      "byte"},        -- 0 不可领取 1 - 可领取 2- 已领取
+    {"item",            5,      ItemData},      -- 奖励信息
+}
+
+SimplifyHero = {
+    {"id",			1,		"int"},	 	        --id
+	{"icon",        1,      "int"},   	        --头像
+	{"camp",        1,      "byte"},	        --阵营
+	{"star",        1,      "byte"},            --星级
+	{"grade",       1,      "byte"},	        --品阶:初始为0
+    {"name",		1,		"string"},	        -- 英雄名
+}
+
+-- 请求英雄升星活动信息
+CG_WEEKLOOP_ACT_HEROQUERY = {}
+
+
+-- 英雄升星 - 活动信息回复协议
+GC_WEEKLOOP_ACT_HEROQUERY = 
+{
+    {"list",        17,   HeroPrize},        -- 奖励信息
+    {"HeroData",    2,   HeroSimple},       -- 英雄信息
+}
+
+-- 英雄升星- 请求所有英雄简略信息
+CG_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO = {
+}
+
+-- 英雄升星- 请求所有英雄简略信息-回复
+GC_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO = 
+{
+    {"tHeroData",   40,     HeroSimple},  -- 简略英雄信息
+}
+
+-- 英雄升星 - 选择英雄
+CG_WEEKLOOP_ACT_HEROCHOSEHERO = 
+{
+    {"nID",     1,      "int"},             -- 英雄ID
+}
+
+-- 回复 GC_WEEKLOOP_ACT_HEROQUERY
+
+-- 英雄升星 - 领取奖励
+CG_WEEKLOOP_ACT_HERPGETPRIZE = {}
+
+-- 回复 GC_WEEKLOOP_ACT_HEROQUERY

+ 34 - 0
script/module/WeekendLoopActivity/WeekendLoopActDefine.lua

@@ -0,0 +1,34 @@
+--------------------------------
+-- 文件名       :  WeekendLoopActDefine.lua
+-- 文件说明     :  周末冲刺-活动通用定义
+-- 创建时间     :   2024/11/25
+-- 创建人       :   FC
+--------------------------------
+
+WEEKACT_OPENDAY = 7         -- 开启日期 周六
+WEEKACT_ENDDAY =  4         -- 结束日期 周三
+WEEKACT_TIME = 0            -- 开启结束时间
+
+WEEKACT_STATE_NONE    =   0       -- 不可领取
+WEEKACT_STATE_CANGET  =   1       -- 可领取
+WEEKACT_STATE_FINISH  =   2       -- 已领取
+
+WEEKACT_HEROSTAR_MAILID = 7009
+WEEKACT_HEROSTAR_HREOLEN = 30
+
+-- 忽略下发的英雄ID
+TWEEKACT_HEROSTAR_IGNORE = 
+{
+    [8] = 1,
+    [9] = 1,
+    [88] = 1,
+    [888] = 1,
+    [8888] = 1,
+}
+
+-- 下发的英雄稀有度要求
+TWEEKACT_HEROSTAR_RARITY = 
+{
+    [4] =   1,
+    [5] =   1,
+}

+ 363 - 0
script/module/WeekendLoopActivity/WeekendLoopActHeroStar.lua

@@ -0,0 +1,363 @@
+--------------------------------
+-- 文件名       :  WeekendLoopActHeroStar.lua
+-- 文件说明     :  周末冲刺活动-英雄升星
+-- 创建时间     :   2024/11/26
+-- 创建人       :   FC
+--------------------------------
+local Util = require("common.Util")
+local Lang = require("common.Lang")
+local Broadcast = require("broadcast.Broadcast")
+local MailExcel = require("excel.mail")
+local Msg = require("core.Msg")
+local ObjHuman = require("core.ObjHuman")
+local WeekLoopActDef = require("WeekendLoopActivity.WeekendLoopActDefine")
+local WeekLoopActCof = require("excel.WeekLoopAct")
+local CommonDB = require("common.CommonDB")
+local MailManager = require("mail.MailManager")
+local Grid = require("bag.Grid")
+local HeroGrid = require("hero.HeroGrid")
+local HeroLogic = require("hero.HeroLogic")
+local BagLogic = require("bag.BagLogic")
+local Log = require("common.Log")
+local HeroExcel = require("excel.hero")
+local WeekendLoopActManger = require("WeekendLoopActivity.WeekendLoopActManager")
+
+----------------------------------------- 内部处理开始 -------------------------------------
+-- 下发数据
+local function WeekActHeroStar_SendData(tMsgData, fd)
+    Msg.send(tMsgData, fd)
+end
+
+-- 获取配置
+local function WeekActHeroStar_GetConfig()
+    if not WeekLoopActCof then
+        return nil
+    end
+
+    return WeekLoopActCof.HeroStarUp
+end
+
+-- 获取选择的英雄ID
+local function WeekActHeroStar_GetHeroID(human)
+    if not human then
+        return -1
+    end
+
+    if not human.db.nWeekHeroID then
+        return -1
+    end
+    
+    return human.db.nWeekHeroID
+end
+
+-- 设置英雄ID
+local function WeekActHeroStar_SetHeroID(human, nHeroID)
+    if not human or not nHeroID then
+        print("[WeekActHeroStar_SetHeroID] 设置英雄ID失败 nHeroID = "..nHeroID)
+        return
+    end
+
+    human.db.nWeekHeroID = nHeroID
+end
+
+-- 初始化奖励信息
+local function WeekActHeroStar_ResetPrize(human)
+    if not human then
+        return false
+    end
+
+    local tConfig = WeekActHeroStar_GetConfig()
+    if not tConfig then
+        return false
+    end
+
+    if not human.db.tWeekHeroPrize then
+        human.db.tWeekHeroPrize = {}
+    end
+
+    for nID, v in pairs(tConfig) do
+        human.db.tWeekHeroPrize[nID] = WeekLoopActDef.WEEKACT_STATE_NONE
+    end
+    
+    return true
+end
+
+-- 获取奖励表
+local function WeekActHeroStar_GetDBPrize(human)
+    if not human then
+        return nil
+    end
+
+    if not human.db.tWeekHeroPrize then
+        return nil
+    end
+    
+    return human.db.tWeekHeroPrize
+end
+
+-- 获取奖励ID状态
+local function WeekActHeroStar_GetPrizeStatus(human, nID)
+    if not human then
+        return WeekLoopActDef.WEEKACT_STATE_NONE
+    end
+
+    local tPrize = WeekActHeroStar_GetDBPrize(human)
+    if not tPrize or not tPrize[nID] then
+        return WeekLoopActDef.WEEKACT_STATE_NONE
+    end
+    
+    return human.db.tWeekHeroPrize[nID]
+end
+
+-- 设置奖励ID状态
+local function WeekActHeroStar_SetPrizeStatus(human, nID, nStatus)
+    if not human then
+        return false
+    end
+
+    local tPrize = WeekActHeroStar_GetDBPrize(human)
+    if not tPrize or not tPrize[nID] then
+        return false
+    end
+
+    tPrize[nID] = nStatus
+
+    return true
+end
+
+----------------------------------------- 外部调用 -------------------------------------
+-- 重置数据
+function WeekActHeroStar_ResetData(human)
+    if not human then
+        return
+    end
+
+    if false == WeekActHeroStar_ResetPrize(human) then
+        print("[WeekActHeroStar_ResetData] 重置英雄升星数据失败")
+        return
+    end
+
+    WeekActHeroStar_SetHeroID(human, 0)
+
+    print("[WeekActHeroStar_ResetData] 英雄升星 数据重置结束 ")
+end
+
+-- 活动结束
+function WeekActHeroStar_End(human)
+    if not human then
+        return
+    end
+
+    print("[WeekActHeroStar_End] 英雄升星 活动结束处理开始")
+
+    local tPrize = WeekActHeroStar_GetDBPrize(human)
+    local tPrizeConfig = WeekActHeroStar_GetConfig()
+    if not tPrize or not tPrizeConfig then
+        return
+    end
+
+    local tMailConfig = MailExcel.mail[WeekLoopActDef.WEEKACT_HEROSTAR_MAILID]
+    if not tMailConfig then
+        return
+    end
+
+    local items = { }
+    for nID, v in pairs(tPrizeConfig) do
+        if WeekLoopActDef.WEEKACT_STATE_CANGET == tPrize[nID] then
+            for _, data in pairs(v.prize) do
+                items[#items + 1] = { data[1], data[2] }
+            end
+            WeekActHeroStar_SetPrizeStatus(human, nID, WeekLoopActDef.WEEKACT_STATE_FINISH)
+        end
+    end
+
+    local title = tMailConfig.title
+    local content = tMailConfig.content
+    local senderName = tMailConfig.senderName
+    MailManager.add(MailManager.SYSTEM, human.db._id, title, content, items, senderName)
+
+    print("[WeekActHeroStar_End] 英雄升星 活动结束处理完成")
+end
+
+----------------------------------------- 客户端请求 -------------------------------------
+-- 请求英雄升星活动信息
+function WeekActHeroStar_Query(human)
+    if not human then
+        return
+    end
+
+    local tPrizeConfig = WeekActHeroStar_GetConfig()
+    local tPrize = WeekActHeroStar_GetDBPrize(human)
+
+    if not tPrizeConfig or not tPrize then
+        return
+    end
+    
+    local tMsgData = Msg.gc.GC_WEEKLOOP_ACT_HEROQUERY
+
+    -- 奖励信息
+    tMsgData.list[0] = 0
+    for nID, v in pairs(tPrizeConfig) do
+        tMsgData.list[0] = tMsgData.list[0] + 1
+
+        local tPrizeData = tMsgData.list[tMsgData.list[0]]
+        tPrizeData.nID = nID
+        tPrizeData.nState = WeekActHeroStar_GetPrizeStatus(human, nID)
+
+        local nPrizeLne = #v.prize
+        tPrizeData.item[0] = nPrizeLne
+        --print("[WeekActHeroStar_Query] nItemLen = "..tPrizeData.item[0].." nID = "..nID)
+
+        for j = 1, nPrizeLne do
+            local nGoodsID = v.prize[j][1]
+            local nGoodsNum = v.prize[j][2]
+
+            --print("[WeekActHeroStar_Query] nGoodsID = "..nGoodsID.. " nGoodsNum = "..nGoodsNum)
+            Grid.makeItem(tPrizeData.item[j], nGoodsID, nGoodsNum)
+        end
+    end
+    --print("[WeekActHeroStar_Query] ListLen = ".. tMsgData.list[0])
+
+    local nChoseHeroID = WeekActHeroStar_GetHeroID(human)
+    if 0 < nChoseHeroID then
+        tMsgData.HeroData[0] = 1
+        HeroGrid.makeHeroSimpleByID(tMsgData.HeroData[1], nChoseHeroID)
+    else
+        tMsgData.HeroData[0] = 0
+    end
+
+    WeekActHeroStar_SendData(tMsgData, human.fd)
+    print("[WeekActHeroStar_Query] 消息发送完成 ")
+end
+
+-- 英雄升星- 请求所有英雄简略信息
+function WeekActHeroStar_GetAllHeroInfo(human)
+    if not human then
+        return
+    end
+
+    local tMsgData = Msg.gc.GC_WEEKLOOP_ACT_HEROGETSIMPLIFYINFO
+
+	local tHeroData = HeroExcel.hero
+	tMsgData.tHeroData[0] = 0
+
+	print("[getACTHeroInfo] 获取数据开始 ")
+
+    for nID, v in pairs(tHeroData) do
+        if not WeekLoopActDef.TWEEKACT_HEROSTAR_IGNORE[nID] then
+            -- ssr 和 ur
+            if WeekLoopActDef.TWEEKACT_HEROSTAR_RARITY[v.grade] then
+                tMsgData.tHeroData[0] = tMsgData.tHeroData[0] + 1
+
+                HeroGrid.makeHeroSimpleByID(tMsgData.tHeroData[tMsgData.tHeroData[0]], nID)
+            end
+        end
+    end
+   
+    WeekActHeroStar_SendData(tMsgData, human.fd)
+end
+
+-- 英雄升星 - 选择英雄
+function WeekActHeroStar_ChoseHero(human, nID)
+    if not human or 0 >= nID then
+        return
+    end
+
+    WeekActHeroStar_SetHeroID(human, nID)
+
+    WeekActHeroStar_Query(human)
+end
+
+
+-- 请求领取奖励
+function WeekActHeroStar_GetPrize(human)
+    if not human then
+        return
+    end
+
+    local tPrize = WeekActHeroStar_GetConfig()
+    if not tPrize then
+        return
+    end
+
+    local tItemList = {}
+    for nID, v in pairs(tPrize) do
+        if WeekLoopActDef.WEEKACT_STATE_CANGET == WeekActHeroStar_GetPrizeStatus(human, nID) then
+            if false == WeekActHeroStar_SetPrizeStatus(human, nID, WeekLoopActDef.WEEKACT_STATE_FINISH) then
+                print("[WeekActHeroStar_GetPrize] 奖励领取失败 nID = "..nID)
+                Log.write(Log.LOGID_OSS_WEEKLOOP_ACT, "[WeekActHeroStar_GetPrize] 设置奖励状态失败 nID = "..nID.." _id = "..human.db._id.." "..human.db.name)
+                break
+            end
+
+            for _, data in ipairs(v.prize) do
+                local nItemID = data[1]
+                local nItemNum = data[2]
+
+                tItemList[nItemID] = tItemList[nItemID] or 0
+                tItemList[nItemID] = tItemList[nItemID] + nItemNum
+            end
+        end
+    end
+
+    if nil ~= _G.next(tItemList) then
+        local tGoodsInfo = {}
+        for k, v in pairs(tItemList) do
+            table.insert(tGoodsInfo, {k,v})
+
+            -- 获取奖励写日志
+            Log.write(Log.LOGID_OSS_WEEKLOOP_ACT, "[WeekActHeroStar_GetPrize] 玩家获取到奖励 name = "
+                    ..human.db.name.." _id = "..human.db._id.." nGoodsID = "..k.." nGoodsNum = "..v)
+        end
+
+        BagLogic.addItemList(human, tGoodsInfo, "week_loop_act")
+
+        BagLogic.sendItemGetList(human, tItemList, "week_loop_act")
+    end
+
+    WeekActHeroStar_Query(human)
+    WeekendLoopActManger.WeekLoopACT_SendActInfo(human)
+end
+
+-- 英雄升星
+function WeekActHeroStar_HeroStarUp(human, nHeroID, nStar)
+    if not human or 0 >= nHeroID or 0 >= nStar then
+        return
+    end
+
+    local nChoseHeroID = WeekActHeroStar_GetHeroID(human)
+    local tConfig = WeekActHeroStar_GetConfig()
+    if -1 >= nChoseHeroID or not tConfig then
+        return
+    end
+
+    if nHeroID ~= nChoseHeroID then
+        return
+    end
+
+    for nID, v in pairs(tConfig) do
+        if nID == nStar then
+            local nStatus = WeekActHeroStar_GetPrizeStatus(human, nID)
+            if WeekLoopActDef.WEEKACT_STATE_NONE == nStatus then
+                WeekActHeroStar_SetPrizeStatus(human, nID, WeekLoopActDef.WEEKACT_STATE_CANGET)
+            end
+        end
+    end
+
+    WeekActHeroStar_Query(human)
+    WeekendLoopActManger.WeekLoopACT_SendActInfo(human)
+end
+
+function isRed(human)
+    local tPrize = WeekActHeroStar_GetConfig()
+    if not tPrize then
+        return false
+    end
+
+    for nID, v in pairs(tPrize) do
+        if WeekLoopActDef.WEEKACT_STATE_CANGET == WeekActHeroStar_GetPrizeStatus(human, nID) then
+            return true
+        end
+    end
+
+    return false
+end

+ 374 - 0
script/module/WeekendLoopActivity/WeekendLoopActManager.lua

@@ -0,0 +1,374 @@
+--------------------------------
+-- 文件名       :  WeekendLoopActManger.lua
+-- 文件说明     :  周末冲刺-活动模板管理
+-- 创建时间     :   2024/11/25
+-- 创建人       :   FC
+--------------------------------
+
+local Util = require("common.Util")
+local Lang = require("common.Lang")
+local Broadcast = require("broadcast.Broadcast")
+local MailExcel = require("excel.mail")
+local Msg = require("core.Msg")
+local ObjHuman = require("core.ObjHuman")
+local MailManager = require("mail.MailManager")
+local BagLogic = require("bag.BagLogic")
+local Grid = require("bag.Grid")
+local PanelDefine = require("broadcast.PanelDefine")
+local CommonDB = require("common.CommonDB")
+local BuyLogic = require("topup.BuyLogic")
+local GuideLogic = require("guide.GuideLogic")
+local Log = require("common.Log")
+local WeekLoopActDef = require("WeekendLoopActivity.WeekendLoopActDefine")
+local WeekLoopActCof = require("excel.WeekLoopAct")
+local WeekLoopActHeroStar = require("WeekendLoopActivity.WeekendLoopActHeroStar")
+
+-- 活动信息
+tWeekActInfo = nil
+-- {
+--     nStartTime = nil,       -- 开始时间
+--     nEendTime = nil,        -- 结束时间
+--     isRun = nil,            -- 是否在活动中
+-- }
+
+-- 加载的模块
+tWeekActModuel = {}
+
+----------------------------------------- 内部处理开始 -------------------------------------
+-- 下发数据
+local function WeekLoopACT_SendData(tMsgData, fd)
+    Msg.send(tMsgData, fd)
+end
+
+-- 下发活动数据
+function WeekLoopACT_SendActInfo(human)
+    if not human or not tWeekActInfo then
+        return
+    end
+
+    print("[WeekLoopACT_SendActInfo] 下发活动数据 开始 ")
+
+    local tMsgData = Msg.gc.GC_WEEKLOOP_ACT_ALLINFO
+    tMsgData.nStartTime = tWeekActInfo.nStartTime
+    tMsgData.nEendTime = tWeekActInfo.nEendTime
+
+    tMsgData.tActID[0] = #WeekLoopActCof.WeekLoopAct
+
+    local nIndex = 1
+    for id, v in pairs(WeekLoopActCof.WeekLoopAct) do
+        local tActData = tMsgData.tActID[nIndex]
+        nIndex = nIndex + 1
+        tActData.ID = id
+        tActData.name = v.name
+        tActData.nSortID = v.sortID
+        tActData.nIcon = v.icon
+        tActData.nPanelID = v.panelID
+        local bRed = false
+        if tWeekActModuel[id] and tWeekActModuel[id].isRed then
+            bRed = tWeekActModuel[id].isRed(human)
+        end
+
+        tActData.nRed = bRed and 1 or 0
+    end
+
+    WeekLoopACT_SendData(tMsgData, human.fd)
+
+    print("[WeekLoopACT_SendActInfo] 下发活动数据 结束 ")
+end
+
+-- 获取记录在人物身上的结束时间
+local function WeekLoopACT_GetHumanEndTime(human)
+    if not human then
+        return -1
+    end
+
+    if not human.db.nWeekLoopEndTime then
+        return -1
+    end
+
+    return human.db.nWeekLoopEndTime
+end
+
+-- 设置记录在人物身上的结束时间
+local function WeekLoopACT_SetHumanEndTime(human, nTime)
+    if not human or 0 >= nTime then
+        return
+    end
+
+    human.db.nWeekLoopEndTime = nTime
+end
+
+-- 获取记录在人物身上的奖励处理标识
+local function WeekLoopACT_GetHumanEndMail(human)
+    if not human then
+        return true
+    end
+
+    -- 没有 则认为未参加上一次活动
+    if not human.db.nWeekLoopEndMail then
+        return true
+    end
+
+    return human.db.nWeekLoopEndMail
+end
+
+-- 设置记录在人物身上的奖励处理标识
+local function WeekLoopACT_SetHumanEndMail(human, nValue)
+    if not human or not nValue then
+        return
+    end
+
+    human.db.nWeekLoopEndMail = nValue
+end
+
+-- 各个子活动重置活动数据
+local function WeekLoopACT_ResetData(human)
+    if not human then
+        return
+    end
+
+    WeekLoopActHeroStar.WeekActHeroStar_ResetData(human)
+end
+
+-- 各个子活动处理结束数据
+local function WeekLoopACT_HandleEndData(human)
+    if not human then
+        return
+    end
+
+    WeekLoopActHeroStar.WeekActHeroStar_End(human)
+end
+
+-- 所有活动初始化数据开始
+local function WeekLoopACT_BeginAllAct(human)
+    if not human or not tWeekActInfo then
+        return
+    end
+
+    local nEndTime = tWeekActInfo.nEendTime
+    
+    print("[WeekLoopACT_BeginAllAct] 所有活动初始化数据开始 ")
+
+    -- 设置时间
+    WeekLoopACT_SetHumanEndTime(human, nEndTime)
+    -- 设置标记
+    WeekLoopACT_SetHumanEndMail(human, false)
+
+    -- 各个子活动重置数据
+    WeekLoopACT_ResetData(human)
+
+    -- 最后下发活动数据
+    WeekLoopACT_SendActInfo(human)
+
+    print("[WeekLoopACT_BeginAllAct] 所有活动初始化数据结束 ")
+end
+
+-- 结束所有活动
+local function WeekLoopACT_EndAllAct(human)
+    -- 各个子活动处理数据
+    WeekLoopACT_HandleEndData(human)
+
+    WeekLoopACT_SetHumanEndMail(human, true)
+end
+
+-- 活动开始
+local function WeekLoopACT_Begin()
+    if not tWeekActInfo then
+        return
+    end
+
+    -- 遍历在线玩家
+    for uuid, human in pairs(ObjHuman.onlineUuid) do
+        WeekLoopACT_BeginAllAct(human)
+    end
+end
+
+-- 活动结束
+local function WeekLoopACT_End()
+    -- 遍历在线玩家
+    for uuid, human in pairs(ObjHuman.onlineUuid) do
+        WeekLoopACT_EndAllAct(human)
+    end
+end
+
+----------------------------------------- 外部调用开始 -------------------------------------
+function onZeroAll(funcID)
+    local nNowTime = os.time()
+    local tDate = os.date("*t",nNowTime)
+    
+    local nOpenServerDay = CommonDB.getServerOpenDay()
+    if nOpenServerDay < 7 then
+        return
+    end
+
+    if WeekLoopActDef.WEEKACT_TIME ~= tDate.hour then
+        return
+    end
+
+    if WeekLoopActDef.WEEKACT_OPENDAY == tDate.wday then
+        print("[WeekLoopACT_OnTimer] 周末活动开始打印")
+
+        tWeekActInfo = {}
+        tWeekActInfo.isRun = true
+        tWeekActInfo.nStartTime = nNowTime
+
+        -- 计算过期时间,转成0时0分
+        local nNextTime = nNowTime + 4 * 86400
+        local tEndDate = os.date("*t",nNextTime)
+        tEndDate.hour = 0
+        tEndDate.min = 0
+        tEndDate.sec = 0
+
+        local nEndTime = os.time(tEndDate)
+        tWeekActInfo.nEendTime = nEndTime
+
+        -- 活动开始
+        WeekLoopACT_Begin()
+
+        print("[WeekLoopACT_OnTimer] 时间打印 nStartTime = ".. tWeekActInfo.nStartTime.." nEendTime = "..tWeekActInfo.nEendTime)
+    elseif WeekLoopActDef.WEEKACT_ENDDAY == tDate.wday then
+        print("[WeekLoopACT_OnTimer] 周末活动结束打印")
+ 
+        WeekLoopACT_End()
+
+        tWeekActInfo = nil
+    end
+end
+
+-- 起服初始化
+function WeekLoopACT_Init()
+    local nNowTime = os.time()
+    local tDate = os.date("*t",nNowTime)
+
+    local nOpenServerDay = CommonDB.getServerOpenDay()
+    if nOpenServerDay < 7 then
+        return
+    end
+
+    print("[WeekLoopACT_Init] 起服初始化 wday = "..tDate.wday.." m = "..tDate.month.." d = "..tDate.day.." h = "..tDate.hour)
+
+    -- 等于星期六 或者 小于星期三
+    if WeekLoopActDef.WEEKACT_OPENDAY == tDate.wday or  WeekLoopActDef.WEEKACT_ENDDAY > tDate.wday then
+        if not tWeekActInfo then
+            tWeekActInfo = {}
+            tWeekActInfo.isRun = true
+            
+            local nDiffDay = WeekLoopActDef.WEEKACT_OPENDAY == tDate.wday and 0 or tDate.wday
+
+            local nTime = nNowTime - nDiffDay * 86400
+            local tCalDate = os.date("*t",nTime)
+            tCalDate.hour = 0
+            tCalDate.min = 0
+            tCalDate.sec = 0
+            tWeekActInfo.nStartTime = os.time(tCalDate)
+
+            local nEndTime =  tWeekActInfo.nStartTime + 4 * 86400
+            tCalDate = os.date("*t",nEndTime)
+            tCalDate.hour = 0
+            tCalDate.min = 0
+            tCalDate.sec = 0
+
+            tWeekActInfo.nEendTime = os.time(tCalDate)
+
+            print("[WeekLoopACT_Init] 时间打印 nStartTime = ".. tWeekActInfo.nStartTime.." nEendTime = "..tWeekActInfo.nEendTime)
+        end
+    end
+
+    for nID, v in pairs(WeekLoopActCof.WeekLoopAct) do
+        local moduleFn = load("return require(\"" .. v.moduleFn .. "\")")()
+        tWeekActModuel[nID] = moduleFn
+    end
+end
+
+-- 是否还在活动期间
+function WeekLoopACT_IsRun()
+    if not tWeekActInfo then
+        return false
+    end
+
+    return tWeekActInfo.isRun
+end
+
+-- 玩家登录
+function onLogin(human, funcID)
+    if not human then
+        return
+    end
+
+    local nOpenServerDay = CommonDB.getServerOpenDay()
+    if nOpenServerDay < 7 then
+        print("[onLogin] 玩家登录,当前服务器开放时间不足,直接返回 nOpenServerDay = "..nOpenServerDay)
+        return
+    end
+
+    local nLastEndTime = WeekLoopACT_GetHumanEndTime(human)
+    local nState = WeekLoopACT_GetHumanEndMail(human)
+
+    -- 未开始
+    if false == WeekLoopACT_IsRun() then
+        if true == nState or -1 >= nLastEndTime then
+            return
+        end
+
+        -- 各个子活动处理结束数据
+        WeekLoopACT_HandleEndData(human)
+
+        -- 设置奖励处理标识
+        WeekLoopACT_SetHumanEndMail(human, true)
+        return
+    end
+
+    -- 当前活动开启,记录的结束时间比当前开始的时间都小说明是新活动
+    if nLastEndTime < tWeekActInfo.nStartTime then
+        if false == nState then
+            -- 处理上一次的奖励数据
+            WeekLoopACT_HandleEndData(human)
+        end
+
+        WeekLoopACT_BeginAllAct(human)
+        
+        return
+    end
+
+    -- 下发活动基础数据
+    if true == WeekLoopACT_IsRun() then
+        WeekLoopACT_SendActInfo(human)
+    end
+end
+
+function onHeroStarChange(human, funcID, parameter, parameter2)
+    if not human or "table" ~= type(parameter) then
+        return
+    end
+
+    if false == WeekLoopACT_IsRun() then
+        return
+    end
+
+    WeekLoopActHeroStar.WeekActHeroStar_HeroStarUp(human, parameter[1], parameter[2])
+end
+
+-- 是否开启
+function isOpen(human, YYInfo, funcConfig)
+    local bRet = WeekLoopACT_IsRun()
+    local nRet = bRet and 1 or 0
+    print("WeekLoopACT_isOpen 结束 nRet = "..nRet)
+    return bRet
+end
+
+-- 
+function isActive(human, YYInfo, funcConfig)
+    return not isOpen(human, YYInfo, funcConfig)
+end
+
+function isRed(human, YYInfo, funcConfig)
+    print("[isRed] 获取红点")
+    local bRet = WeekLoopActHeroStar.isRed(human)
+    if bRet then
+        print("[isRed] 存在红点")
+        return bRet
+    end
+
+    print("[isRed] 不存在红点")
+    return false
+end

+ 24 - 25
script/module/lostTemple/lostTempleCombatLogic.lua

@@ -1,6 +1,5 @@
 --[[
-    ʧ������ ս��ģ��
-
+    失落神庙 战斗模块
 ]]
 local Msg = require("core.Msg")
 local LuaMongo = _G.lua_mongo
@@ -30,7 +29,7 @@ local ItemDefine = require("bag.ItemDefine")
 
 
 -------------------------------------- combat -----------------------------------------
--- ��ȡ����
+-- 获取属性
 function getHeroAttrs(human, index)
     human.lostTempleAttr = human.lostTempleAttr or { }
     if not human.lostTempleAttr[index] then
@@ -39,7 +38,7 @@ function getHeroAttrs(human, index)
     return human.lostTempleAttr[index]
 end
 
--- ����uuid ��ȡheroGrid
+-- 根据uuid 获取heroGrid
 function getHeroGridByUuid(human, uuid)
     if not uuid or uuid == "" or uuid == "0" then return end
 
@@ -52,7 +51,7 @@ function getHeroGridByUuid(human, uuid)
         end
     end
 
-    -- ��ȡ��ʱ������
+    -- 获取临时背包的
     if human.lostTemple and human.lostTemple.summonHero then
         for i = 1, human.lostTemple.summonHero[0] do
             local heroGrid = human.lostTemple.summonHero[i]
@@ -67,7 +66,7 @@ function getHeroGridByUuid(human, uuid)
     return nil
 end
 
--- �����趨
+-- 阵容设定
 function checkUpdatePos(human, msg)
     if not human.lostTemple then return end
 
@@ -78,17 +77,17 @@ function checkUpdatePos(human, msg)
     local useList = { }
     local fatherList = { }
 
-    -- ȷ��Ӣ�۴治����
+    -- 确定英雄存不存在
     for i = 1, CombatDefine.COMBAT_HERO_CNT do
         local uuid = heroList[i] or ""
         if uuid ~= "0" and uuid ~= "" then
             if i == CombatDefine.COMBAT_HERO_CNT and CombatPosLogic.canBackup(human) == 0 then
-                -- Ԯ��δ����
+                -- 援军未激活
                 return
             end
 
             if posList[i] == nil and i ~= CombatDefine.COMBAT_HERO_CNT then
-                -- վλ������
+                -- 站位不可用
                 return
             end
 
@@ -97,7 +96,7 @@ function checkUpdatePos(human, msg)
 
             local heroConfig = HeroExcel.hero[heroGrid.id]
             if useList[uuid] or fatherList[heroGrid.id] then
-                -- ͬ����Ӣ���ظ�
+                -- 同父类英雄重复
                 return
             else
                 cnt = cnt + 1
@@ -107,10 +106,10 @@ function checkUpdatePos(human, msg)
         end
     end
     if cnt == 0 then
-        -- ����Ӣ�ۿ�
+        -- 上阵英雄空
         return
     end
-    -- ��鸨�������Ƿ񼤻� todo
+    -- 检查辅助对象是否激活 todo
 
     return true, heroList, helpList
 end
@@ -119,7 +118,7 @@ end
 
 
 
--- ս��ǰ������
+-- 战斗前加属性
 function onFightBegin(human, cbParam, combatType, param)
     local putY = tonumber(param[1])
     if not putY then return end
@@ -129,12 +128,12 @@ function onFightBegin(human, cbParam, combatType, param)
     if not grid.monsterOutID then return end
 
     for index = 1, CombatDefine.COMBAT_HERO_CNT do
-        -- ����Ѫ��
+        -- 攻方血量
         local atkPos = CombatLogic.getPos(CombatDefine.ATTACK_SIDE, index)
         local atkObj = CombatImpl.objList[atkPos]
 
         if atkObj ~= nil then
-           -- Ӣ��״̬
+           -- 英雄状态
            if human.lostTemple.heroStatus then
               local hpRate = human.lostTemple.heroStatus[atkObj.uuid] or 1.0
               local hpMax = CombatObj.getHpMax(atkObj)
@@ -148,7 +147,7 @@ function onFightBegin(human, cbParam, combatType, param)
               end
            end
 
-           -- ����
+           -- 属性
            if human.lostTemple.summonTree then
               atkObj.isSysAttrChange = true
               for key, value in pairs(human.lostTemple.summonTree) do
@@ -157,7 +156,7 @@ function onFightBegin(human, cbParam, combatType, param)
            end
         end
 
-        -- �ط�Ѫ��
+        -- 守方血量
         local defPos = CombatLogic.getPos(CombatDefine.DEFEND_SIDE, index)
         local defObj = CombatImpl.objList[defPos]
         local objStatus = grid.objStatus and grid.objStatus[defPos] or nil
@@ -169,7 +168,7 @@ function onFightBegin(human, cbParam, combatType, param)
 end
 
 
--- ����Ӣ�۱���������ʱ����
+-- 根据英雄背包创建临时对象
 function createHumanObj(human, uuid)
     if not uuid then return end
     local heroGrid = getHeroGridByUuid(human, uuid)
@@ -178,7 +177,7 @@ function createHumanObj(human, uuid)
     return CombatLogic.createHeroObjByHeroGrid(human, heroGrid)
 end
 
--- ��ȡӢ������
+-- 获取英雄阵容
 function getHumanObjList(human, combatType)
     local teamType = CombatPosLogic.getTeamType(combatType)
     if not teamType then return end
@@ -214,7 +213,7 @@ function getHumanObjList(human, combatType)
 end
 
 
--- ��ȡ������id
+-- 获取怪物组id
 function getCombatMonsterOutID(human, side, args, combatType)
     if side == CombatDefine.ATTACK_SIDE then return end
 
@@ -228,7 +227,7 @@ function getCombatMonsterOutID(human, side, args, combatType)
     return grid.monsterOutID
 end
 
--- ս��
+-- 战斗
 function fight(human, args)
     if not human.lostTemple then return end
 
@@ -243,7 +242,7 @@ function fight(human, args)
 end
 
 
--- ս������
+-- 战斗结束
 function onFightEnd(human, result, combatType, cbParam, combatInfo, param)
     if not human.lostTemple then return end
 
@@ -289,7 +288,7 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo, param)
         end
     else
         grid.objStatus = grid.objStatus or { }
-        -- ���·��ط�Ѫ��
+        -- 更新防守方血量
         for index = 1, CombatDefine.COMBAT_HERO_CNT do
             local defPos = CombatLogic.getPos(CombatDefine.DEFEND_SIDE, index)
             local defObj = combatInfo.objList[defPos]
@@ -303,7 +302,7 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo, param)
         end
     end
 
-    -- ���¹�����Ѫ��
+    -- 更新攻击方血量
     local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE24)
     human.lostTemple.heroStatus = human.lostTemple.heroStatus or { }
     for index = 1, CombatDefine.COMBAT_HERO_CNT do
@@ -317,7 +316,7 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo, param)
                human.lostTemple.heroStatus[atkObj.uuid] = hpRate
             end
 
-            -- ����Ӣ������
+            -- 阵上英雄下阵
             if combatHero and hp <= 0 then  
                for pos, uuid in pairs(combatHero) do
                   if uuid == atkObj.uuid then

+ 5 - 0
script/module/role/RoleDBLogic.lua

@@ -408,6 +408,11 @@ function createDefaultRole(account)
 
         isTip  = nil ,                         --钻石加速孵化今日是否提示
 
+		nWeekLoopEndTime =  nil,				-- 周循环活动结束时间戳
+		nWeekLoopEndMail = nil,					-- 周循环活动结束处理奖励标识
+		nWeekHeroID = nil,						-- 周活动-升星英雄ID
+		tWeekHeroPrize = nil,					-- 周活动-升星奖励信息
+
         mergeInfo = {},   --融合信息 {mergeStartTime: 0 , mergeTime: 0, mergeEndTime: 0, heroId: 0}
 		gift = {
 			unlock = {},

+ 2 - 0
script/module/yunying/YunYingLogic.lua

@@ -37,6 +37,7 @@ local MiddleConnect = require("middle.MiddleConnect")
 local InnerMsg = require("core.InnerMsg")
 local AbsReachRankDB = require("absAct.AbsReachRankDB")
 local OpenServerActPowerUp = require("present.OpenServerActPowerUp")
+local WeekendLoopActManger = require("WeekendLoopActivity.WeekendLoopActManager")
 
 ID2YYInfo = ID2YYInfo or { } -- 每个id是一个主界面上方运营活动大图标入口
 PANELID2OPENLV = PANELID2OPENLV or { }
@@ -183,6 +184,7 @@ function init()
     -- 活动初始化后 才能去实始化ABS排名活动
     AbsReachRankDB.init()
     OpenServerActPowerUp.Init()
+    WeekendLoopActManger.WeekLoopACT_Init()
 end