Prechádzať zdrojové kódy

新增商业活动相关代码

gitxsm 1 rok pred
rodič
commit
cf10c7bf52

+ 1 - 0
script/common/Lang.lua

@@ -42,6 +42,7 @@ COMMON_ITEM_NOT_ENOUGH = [[道具不足]]
 COMMON_TYPE_ERROR = [[类型错误]]
 COMMON_TIME_NOT_ENOUGH = [[时间不足]]
 COMMON_DAY_RECHARGE_NOT_ENOUGH = [[当日充值金额不足]]
+COMMON_FINISH = [[已完成]]
 
 --------------------------------------------------
 

+ 1 - 0
script/common/ProtoID.lua

@@ -1356,3 +1356,4 @@ _ENV[1391]="GC_LOTTERYCARD_RESET"
 _ENV[1392]="CG_EXCELLENTGIFT_GET_REWARD"
 _ENV[1393]="GC_ITEM_SKIN_INFO"
 _ENV[1394]="CG_ITEM_CHOSE_SKIN"
+_ENV[1397]="CG_EXCELLENTGIFT_FINISH_TASK"

+ 12 - 10
script/module/absAct/AbsDiscountStoreLogic.lua

@@ -25,15 +25,13 @@ function isOpen(human, YYInfo, funcConfig)
     return state, endTime, startTime
 end
 
-
 function isActive(human, YYInfo, funcConfig)
     local state = isOpen(human, YYInfo, funcConfig)
     return not state
 end
 
-
 --查询
-function Query(human, id)
+function Query(human, id, isBuy)
     local state = AbsActLogic.isStarted(human, id)
     if not state then
         return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
@@ -47,6 +45,8 @@ function Query(human, id)
     local buyRecord = actData.buyRecord
     local msgRet = Msg.gc.GC_DISCOUNTSTORE_QUERY
 
+    msgRet.isBuy = isBuy and 1 or 0
+
     local itemVec = msgRet.itemVec
     itemVec[0] = #Config
 
@@ -58,7 +58,7 @@ function Query(human, id)
         Grid.makeItem(singleItem.item, v.item[1], v.item[2])
         -- singleItem.currencyId = v.currencyInfo[1]
         -- singleItem.currencyCnt = v.currencyInfo[2]
-        Grid.makeItem(singleItem.currency, v.currencyInfo[1], v.currencyInfo[2])
+        Grid.makeItem(singleItem.currencyInfo, v.currencyInfo[1], v.currencyInfo[2])
     end
 
     Msg.send(msgRet, human.fd)
@@ -89,10 +89,11 @@ function BuyItem(human, id, itemIdx, buyCnt)
     end
 
     local currencyInfo = itemCfg.currencyInfo
-    if BagLogic.getItemCnt(human, currencyInfo[1]) < currencyInfo[2] then
+    local cnt = currencyInfo[2] * buyCnt
+    if BagLogic.getItemCnt(human, currencyInfo[1]) < cnt then
         return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
     end
-    BagLogic.delItem(human, currencyInfo[1], currencyInfo[2], LOGTAG)
+    BagLogic.delItem(human, currencyInfo[1], cnt, LOGTAG)
 
     --更新数据
     buyRecord = buyRecord or {}
@@ -104,8 +105,9 @@ function BuyItem(human, id, itemIdx, buyCnt)
     BagLogic.addItemList(human, {{itemInfo[1], itemInfo[2] * buyCnt}}, LOGTAG)
 
     --下发数据
-    local msgRet = Msg.gc.GC_DISCOUNTSTORE_BUY
-    msgRet.idx = itemIdx
-    msgRet.nowBuyCnt = itemCfg.buyRecord[itemIdx]
-    Msg.send(msgRet, human.fd)
+    -- local msgRet = Msg.gc.GC_DISCOUNTSTORE_BUY
+    -- msgRet.idx = itemIdx
+    -- msgRet.nowBuyCnt = buyRecord[itemIdx]
+    -- Msg.send(msgRet, human.fd)
+    Query(human, id, true)
 end

+ 505 - 0
script/module/absAct/AbsExcellentGiftLogic.lua

@@ -0,0 +1,505 @@
+--新商业化活动——超值豪礼
+--db
+--[=[
+    human.db.absAct[id] = {
+        recordData = {
+            [1] = {             --key为任务ID
+                [1] = 10,       --key为触发事件Id, value为进度
+                [0] = 1,        --key为需要充值的ID, value为充值次数。key为0时, 表示免费
+                isGet = nil,    --有值时表示已领取
+            },
+        }
+    }
+]=]--
+
+local Msg = require("core.Msg")
+local Grid = require("bag.Grid")
+local BagLogic = require("bag.BagLogic")
+local AbsActLogic = require("absAct.AbsActLogic")
+local Broadcast = require("broadcast.Broadcast")
+local Lang = require("common.Lang")
+local YunYingLogic = require("yunying.YunYingLogic")
+local AbsActExcel = require("excel.absAct")
+local BuyLogic = require("topup.BuyLogic")
+local CommonDefine = require("common.CommonDefine")
+local ItemDefine = require("bag.ItemDefine")
+
+--本活动ID
+local ACTID = 753
+--日志标识
+local LOGTAG = "AbsExcellentGiftLogic"
+--完成任务消耗道具ID
+local FINISH_TASK_COST_ID = ItemDefine.ITEM_ZUANSHI_ID
+--完成任务消耗道具数量
+local FINISH_TASK_COST_CNT = 500
+
+
+local BATTLE_MOP_UP = 1            --冒险闯关扫荡
+local LOSTTEMPLE_PASS = 2          --失落神庙通关
+local YJTREASURE_PASS_LEVEL = 3    --遗迹探险层数
+local FRIEND_COMBAT = 4            --好友切磋次数
+local CHAT_TIMES = 5               --所有聊天频道发言次数
+local MOZHU_CHALLENGE = 6         --魔王梼杌参数次数
+local DRAWCALL_SERNIOR_CNT = 7      --高级召唤次数
+local FUWEN_RECASTING = 8          --符文重铸次数
+local UNION_DONATE = 9             --公会捐献次数
+local ZHANBU_SYNTHESIS = 10         --占卜合成次数
+
+
+---------------------------------各类事件处理接口----------------------------------
+function onMopup(human, funcID, value)
+    TriggerCbFunc(human, BATTLE_MOP_UP, value, true)
+end
+
+function friendCombat(human, funcID, value)
+    TriggerCbFunc(human, FRIEND_COMBAT, value, true)
+end
+
+
+function lostTempleCombat(human, funcID, value)
+    TriggerCbFunc(human, LOSTTEMPLE_PASS, value, true)
+end
+
+function YJTreasurePass(human, funcID, value)
+    TriggerCbFunc(human, YJTREASURE_PASS_LEVEL, value, true)
+end
+
+
+function ChatTimes(human, funcID, value)
+    TriggerCbFunc(human, CHAT_TIMES, value, true)
+end
+
+function MoZhuCombat(human, funcID, value)
+    TriggerCbFunc(human, MOZHU_CHALLENGE, value, true)
+end
+
+function onDrawCard(human, funcID, value)
+    TriggerCbFunc(human, DRAWCALL_SERNIOR_CNT, value, true)
+end
+
+
+function onFuwenChongZhu(human, funcID, value)
+    TriggerCbFunc(human, FUWEN_RECASTING, value, true)
+end
+
+function onUnionDonate(human, funcID, value)
+    TriggerCbFunc(human, UNION_DONATE, value, true)
+end
+
+function ZhanBuHecheng(human, funcID, value)
+    TriggerCbFunc(human, ZHANBU_SYNTHESIS, value, true)
+end
+
+-----------------------------------------------------------------------------------
+
+
+
+-- --订阅触发事件
+-- local function registerTrigger(human)
+--     local len = 0
+--     local triggerTagVec = {}
+
+--     local config = AbsActExcel.AbsExcellentGiftLogic
+--     for _, v in ipairs(config) do
+--         len = len + 1
+--         triggerTagVec[len] = v.taskId
+--     end
+
+--     TriggerLogic.RegisterMoniter(triggerTagVec, TriggerCbFunc, human.db.newUniqueTag)
+-- end
+
+--获取任务ID
+local function getTaskIdVec(triggerId, buyId)
+    local ids = {}
+    local len = 0
+    local config = AbsActExcel.AbsExcellentGiftLogic
+    for id, cfg in ipairs(config) do
+        if triggerId and cfg.taskId == triggerId then
+            len = len + 1
+            ids[len] = id
+        end
+
+        if buyId and cfg.buyId == buyId then
+            len = len + 1
+            ids[len] = id
+        end
+    end
+    return ids
+end
+
+--是否完成任务, 0-未完成, 1-可领取,2-已领取
+local function getTaskState(taskId, taskData)
+    if not taskData then
+        return CommonDefine.COMMON_PRIZE_STATE_NOGET
+    end
+
+    if taskData.isGet then
+        return CommonDefine.COMMON_PRIZE_STATE_GET
+    end
+
+    local config = AbsActExcel.AbsExcellentGiftLogic
+    local singleCfg = config[taskId]
+    local triggerId = singleCfg.taskId
+    local triggerVal = singleCfg.taskVal
+
+    local isFinish = true
+    if not taskData[triggerId] or taskData[triggerId] < triggerVal then
+        isFinish = false
+    end
+
+    if not isFinish then
+        return CommonDefine.COMMON_PRIZE_STATE_NOGET
+    end
+
+    local condBuyId = singleCfg.buyId
+    if condBuyId ~= 0 and not taskData[condBuyId] then
+        return CommonDefine.COMMON_PRIZE_STATE_NOGET
+    end
+
+    if isFinish and not taskData.isGet then
+        return CommonDefine.COMMON_PRIZE_STATE_CANGET
+    end
+end
+
+--红点检查
+local function redDotCheck(recordData)
+    local redDotPageTb = {}
+    local taskState = 0
+    local config = AbsActExcel.AbsExcellentGiftLogic
+    for taskId, data in pairs(recordData) do
+        taskState = getTaskState(taskId, data)
+        if taskState == CommonDefine.COMMON_PRIZE_STATE_CANGET then
+            local taskCfg = config[taskId]
+            redDotPageTb[taskCfg.page] = '1'
+        end
+    end
+
+    if not next(redDotPageTb) then
+        return false
+    end
+
+    return redDotPageTb
+end
+
+
+-- function onLogin(human, id)
+--     local state = AbsActLogic.isStarted(human, id)
+--     if not state then
+--         return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+--     end
+
+--     local actData = human.db.absAct[id]
+--     if not actData then
+--         return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+--     end
+
+--     --registerTrigger(human)
+-- end
+
+
+--充值处理接口
+function onCharge(human, price, funcID, buyID)
+    local state = AbsActLogic.isStarted(human, funcID)
+    if not state then
+        return
+    end
+
+    local isChange = false
+    local taskState = COMMON_PRIZE_STATE_NOGET
+    local actData = human.db.absAct[ACTID]
+    actData.recordData = actData.recordData or {}
+    local recordData = actData.recordData
+
+    local ids = getTaskIdVec(nil, buyID)
+    local config = AbsActExcel.AbsExcellentGiftLogic
+
+    for _, id in ipairs(ids) do
+        if  not recordData[id] or not recordData[id].isGet then
+            local singleCfg = config[id]
+            local needBuyId = singleCfg.buyId
+
+            recordData[id] = recordData[id] or {}
+            recordData[id][needBuyId] = (recordData[id][needBuyId] or 0) + 1
+
+            isChange = true
+            if taskState ~= CommonDefine.COMMON_PRIZE_STATE_CANGET then
+                taskState = getTaskState(id, recordData[id])
+            end
+        end
+    end
+
+    if isChange then
+        Query(human, ACTID, human.nowPage or 0)
+    end
+
+    if taskState == CommonDefine.COMMON_PRIZE_STATE_CANGET then
+        --红点刷新
+        YunYingLogic.sendBanner(human)
+        local config = AbsActExcel.absActivity[ACTID]
+        YunYingLogic.sendGroupUpdate(YYInfo[ACTID], human, config.panelID)
+    end
+end
+
+--事件触发接口
+function TriggerCbFunc(human, triggerTag, val, isAdd)
+    local state = AbsActLogic.isStarted(human, ACTID)
+    if not state then
+        return
+    end
+
+    --local isChange = false
+    local taskState = COMMON_PRIZE_STATE_NOGET
+    local actData = human.db.absAct[ACTID]
+    actData.recordData = actData.recordData or {}
+    local recordData = actData.recordData
+    local ids = getTaskIdVec(triggerTag)
+
+    for _, id in ipairs(ids) do
+        if not recordData[id] or not recordData[id].isGet then
+            recordData[id] = recordData[id] or {}
+
+            if isAdd then
+                recordData[id][triggerTag] = (recordData[id][triggerTag] or 0) + val
+            else
+                recordData[id][triggerTag] = val
+            end
+
+            --isChange = true
+            if taskState ~= CommonDefine.COMMON_PRIZE_STATE_CANGET then
+                taskState = getTaskState(id, recordData[id])
+            end
+        end
+    end
+
+    -- if isChange then
+    --     Query(human, ACTID, nowPage)
+    -- end
+
+    if taskState == CommonDefine.COMMON_PRIZE_STATE_CANGET then
+        --红点刷新
+        YunYingLogic.sendBanner(human)
+        local config = AbsActExcel.absActivity[ACTID]
+        YunYingLogic.sendGroupUpdate(YYInfo[ACTID], human, config.panelID)
+    end
+end
+
+
+--红点判断
+function isRed(human, YYInfo, funcConfig)
+    local actData = human.db.absAct[funcConfig.funcID]
+    if not actData then
+        return false
+    end
+
+    local recordData = actData.recordData
+    if not recordData then
+        return false
+    end
+
+    if not redDotCheck(recordData) then
+        return false
+    end
+
+    return true
+end
+
+function isOpen(human, YYInfo, funcConfig)
+    local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
+    return state, endTime, startTime
+end
+
+
+function isActive(human, YYInfo, funcConfig)
+    local state = isOpen(human, YYInfo, funcConfig)
+    return not state
+end
+
+--查询
+function Query(human, id, page)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    actData.recordData = actData.recordData or {}
+    local recordData = actData.recordData
+    local config = AbsActExcel.AbsExcellentGiftLogic
+    local msgRet = Msg.gc.GC_EXCELLENTGIFT_QUERY
+    local len = 0
+    local taskList = msgRet.taskList
+
+    for taskId, v in ipairs(config) do
+        if v.page == page then
+            len = len + 1
+            local taskData = recordData[taskId]
+            taskList[len].state = getTaskState(taskId, taskData)
+            taskList[len].idx = len
+            taskList[len].taskDesc = v.taskDes
+    
+            taskList[len].taskMaxProgress = v.taskVal
+            taskList[len].taskNowProgress = taskData and taskData[v.taskId] or 0
+    
+            BuyLogic.fontBuyItem(human, taskList[len].buyMsg, v.buyId)
+            taskList[len].buyState = taskData and taskData[v.buyId] or 0
+            if v.buyId == 0 then
+                taskList[len].buyState = 1
+            end
+    
+            local awardVec = taskList[len].award
+            awardVec[0] = #v.award
+            for j, itemInfo in ipairs(v.award) do
+                Grid.makeItem(awardVec[j], itemInfo[1], itemInfo[2])
+            end
+        end
+    end
+    taskList[0] = len
+
+    --完成任务消耗
+    Grid.makeItem(msgRet.finishTaskCost, FINISH_TASK_COST_ID, FINISH_TASK_COST_CNT)
+
+    --红点
+    local redDotList = msgRet.redDotList
+    redDotList[0] = 0
+    local redDotPageTb = redDotCheck(recordData)
+    if redDotPageTb then
+        len = 0
+        for redPage in pairs(redDotPageTb) do
+            len = len + 1
+            redDotList[len] = redPage
+        end
+        redDotList[0] = len
+    end
+
+    Msg.send(msgRet, human.fd)
+
+    human.nowPage = page
+end
+
+--领奖
+function GetReward(human, id, taskIdx, page)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local len = 0
+    local taskIdList = {}
+    local recordData = actData.recordData
+    local config = AbsActExcel.AbsExcellentGiftLogic
+
+    -- for k, v in ipairs(config) do
+    --     if v.page == page then
+    --         len = len + 1
+    --         if len == taskIdx then
+    --             taskId = k
+    --             break
+    --         end
+    --     end
+    -- end
+
+    for k, v in ipairs(config) do
+        if v.page == page then
+            if getTaskState(k, recordData and recordData[k]) == CommonDefine.COMMON_PRIZE_STATE_CANGET then
+                len = len + 1
+                taskIdList[len] = k
+            end
+        end
+    end
+
+    if len == 0 then
+        return Broadcast.sendErr(human, Lang.ABS_ANSWER_ITEM_IS_GET)
+    end
+
+
+    local awardtbl = {}
+
+    for _, taskId in ipairs(taskIdList) do
+        recordData[taskId].isGet = '1'
+        local taskCfg = config[taskId]
+        for _, itemInfo in ipairs(taskCfg.award) do
+            awardtbl[#awardtbl+1] = itemInfo
+        end
+    end
+
+    BagLogic.addItemList(human, awardtbl, LOGTAG)
+
+
+    --BagLogic.addItemList(human, taskCfg.award, LOGTAG)
+
+    Query(human, id, page)
+
+    --红点
+    if not redDotCheck(recordData) then
+        YunYingLogic.sendBanner(human)
+        local otherConfig = AbsActExcel.absActivity[ACTID]
+        YunYingLogic.sendGroupUpdate(YYInfo[ACTID], human, otherConfig.panelID)
+    end
+end
+
+--消耗古玉完成任务
+function FinishTaskByDiamond(human, id, taskIdx, page)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local recordData = actData.recordData
+    local len = 0
+    local taskId = 0
+    local taskCfg = nil
+    local config = AbsActExcel.AbsExcellentGiftLogic
+    for k, v in ipairs(config) do
+        if v.page == page then
+            len = len + 1
+            if len == taskIdx then
+                taskId = k
+                taskCfg = v
+                break
+            end
+        end
+    end
+
+    if taskId == 0 then
+        return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
+    end
+
+    if recordData and recordData[taskId] and recordData[taskId].isGet then
+        return Broadcast.sendErr(human, Lang.FRIEND_HEART_GET_HAD)
+    end
+
+    if getTaskState(taskId, recordData and recordData[taskId]) == CommonDefine.COMMON_PRIZE_STATE_CANGET then
+        return Broadcast.sendErr(human, Lang.COMMON_FINISH)
+    end
+
+    if BagLogic.getItemCnt(human, FINISH_TASK_COST_ID) < FINISH_TASK_COST_CNT then
+        return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
+    end
+    --扣消耗
+    BagLogic.delItem(human, FINISH_TASK_COST_ID, FINISH_TASK_COST_CNT, LOGTAG)
+
+    recordData[taskId] = recordData[taskId] or {}
+    recordData[taskId][taskCfg.taskId] = taskCfg.taskVal
+
+    --红点
+    YunYingLogic.sendBanner(human)
+    local otherConfig = AbsActExcel.absActivity[ACTID]
+    YunYingLogic.sendGroupUpdate(YYInfo[ACTID], human, otherConfig.panelID)
+
+    --更新
+    Query(human, id, page)
+end

+ 6 - 12
script/module/absAct/AbsLoginRewardLogic.lua

@@ -13,7 +13,6 @@ local BagLogic = require("bag.BagLogic")
 local AbsActLogic = require("absAct.AbsActLogic")
 local Broadcast = require("broadcast.Broadcast")
 local Lang = require("common.Lang")
-local Config = require("excel.absAct").AbsLoginReward
 local AbsActExcel = require("excel.absAct")
 local YunYingLogic = require("yunying.YunYingLogic")
 
@@ -39,13 +38,11 @@ function isOpen(human, YYInfo, funcConfig)
     return state, endTime, startTime
 end
 
-
 function isActive(human, YYInfo, funcConfig)
     local state = isOpen(human, YYInfo, funcConfig)
     return not state
 end
 
-
 --红点判断
 function isRed(human, YYInfo, funcConfig)
     local actData = human.db.absAct[funcConfig.funcID]
@@ -87,8 +84,6 @@ function onLogin(human, id)
     end
 end
 
-
-
 --跨天函数
 function updateDaily(human, id)
     local state = AbsActLogic.isStarted(human, id)
@@ -109,7 +104,6 @@ function updateDaily(human, id)
     YunYingLogic.sendGroupUpdate(YYInfo[id], human, config.panelID)
 end
 
-
 --查询
 function Query(human, id)
     local state = AbsActLogic.isStarted(human, id)
@@ -125,12 +119,12 @@ function Query(human, id)
     local msgRet = Msg.gc.GC_LOGINREWARD_QUERY
     local dayRewardData = msgRet.dayRewardData
 
-
-    dayRewardData[0] = #Config
+    local config = AbsActExcel.AbsLoginReward
+    dayRewardData[0] = #config
     local loginDay = actData.loginDay
     local getRewardRecord = actData.getRewardRecord
 
-    for day, cfg in ipairs(Config) do
+    for day, cfg in ipairs(config) do
         dayRewardData[day].day = day
         dayRewardData[day].state = 0
         local isGet = check(getRewardRecord, day)
@@ -151,7 +145,6 @@ function Query(human, id)
     Msg.send(msgRet, human.fd)
 end
 
-
 --领奖
 function GetReward(human, id, dayIndex)
     local state = AbsActLogic.isStarted(human, id)
@@ -177,7 +170,8 @@ function GetReward(human, id, dayIndex)
         end
     end
 
-    if dayIndex > #Config then
+    local config = AbsActExcel.AbsLoginReward
+    if dayIndex > #config then
         return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
     end
 
@@ -187,7 +181,7 @@ function GetReward(human, id, dayIndex)
     actData.getRewardRecord = getRewardRecord
 
     --发放奖励
-    local targetDayReward = Config[dayIndex].item
+    local targetDayReward = config[dayIndex].item
     BagLogic.addItemList(human, targetDayReward, LOGTAG)
 
     --发下客户端更新数据

+ 526 - 0
script/module/absAct/AbsLotteryCardLogic.lua

@@ -0,0 +1,526 @@
+--新商业化活动——秘境翻牌
+--db
+--[=[
+    human.db.absAct[id] = {
+        freeCnt = nil, 当日免费抽取次数,为0时表示没有,为其他表示可以免费抽取一次
+        normalAwardIdxTbl --普通奖励,value为配置表的Index
+        normalAwardRecord = { --普通奖励获得记录,key为 normalAwardIdxTbl 中的索引,有值则表示获得了
+            [1] = '1',
+            [3] = '1',
+        },
+
+        lineAwardIdxTbl= = nil,  --当前横排(上方)大奖Index列表, value为配置表的Index
+        lineAwardRecord = {  --横排大奖(上方)获得记录,key为 lineAwardRecord 中的索引,有值则表示获得了
+            [1] = '1',
+            [3] = '1',
+        },
+
+        rowAwardIdxTbl = nil,  --当前竖排(右边)大奖Index列表, value为配置表的Index
+        rowAwardRecord = {  --竖排大奖(右边)获得记录,key为 rowAwardIdxTbl 中的索引,有值则表示获得了
+            [1] = '1',
+            [3] = '1',
+        }
+    }
+]=]--
+
+local Msg = require("core.Msg")
+local Grid = require("bag.Grid")
+local BagLogic = require("bag.BagLogic")
+local AbsActLogic = require("absAct.AbsActLogic")
+local Broadcast = require("broadcast.Broadcast")
+local Lang = require("common.Lang")
+local AbsActExcel = require("excel.absAct")
+local YunYingLogic = require("yunying.YunYingLogic")
+local ItemDefine = require("bag.ItemDefine")
+
+local LOGTAG = "AbsLotteryCardLogic"    --日志标识
+local LOTTERYCOSTTYPE = ItemDefine.ITEM_ZUANSHI_ID --抽奖消耗道具ID
+local LOTTERY1COSTCNT = 400            --单抽消耗的数量
+local LOTTERY10COSTCNT = 4000          --十连消耗的数量
+local RESETCOSTCNT = 1000               --重置需要消耗的数量
+local FOUR = 4
+
+--是否是GM模式, 为true时, 每次抽取只会获得没有抽到的奖励, 抽够一定次数, 则一定会获得所有奖励
+local isGmMode = false
+
+
+--生成奖励
+local function generateAwardByWeight(awardConfig, awardNum)
+    local totalWeight = 0
+    for _, v in pairs(awardConfig) do
+        totalWeight = totalWeight + v[3]
+    end
+
+    local weight, randWeight = 0, 0
+    local awardIdxTbl = {}
+
+    for i=1, awardNum do
+        weight = 0
+        randWeight = math.random(0, totalWeight)
+        for idx, cfg in ipairs(awardConfig) do
+            weight = weight + cfg[3]
+            if randWeight <= weight then
+                awardIdxTbl[i] = idx
+                break
+            end
+        end
+    end
+    return awardIdxTbl
+end
+
+--封装奖励协议数据结构
+local function populateAwardMsg(net, awardCfg, awardRecordData, indexTbl)
+    net[0] = #indexTbl
+    for k, awardIdx in ipairs(indexTbl) do
+        net[k].idx = k
+        net[k].getState = 0
+
+        if awardRecordData and awardRecordData[k] then
+            net[k].getState = 1
+        end
+
+        local itemInfo = awardCfg[awardIdx]
+        Grid.makeItem(net[k].item, itemInfo[1], itemInfo[2])
+    end
+end
+
+--封装协议数据结构
+local function populateMsg(msgRet, actData)
+    msgRet.freeCnt = 0
+    local freeCnt = actData.freeCnt
+    if not freeCnt or freeCnt ~= 0 then
+        msgRet.freeCnt = 1
+    end
+
+    local config = AbsActExcel.AbsLotteryCardLogic
+    --普通奖励
+    populateAwardMsg(msgRet.normalAwardInfo, config[1].award, actData.normalAwardRecord, actData.normalAwardIdxTbl)
+
+    --横排大奖
+    populateAwardMsg(msgRet.lineAwardInfo, config[2].award, actData.lineAwardRecord,  actData.lineAwardIdxTbl)
+
+    --竖排大奖
+    populateAwardMsg(msgRet.rowAwardInfo, config[3].award, actData.rowAwardRecord, actData.rowAwardIdxTbl)
+end
+
+--计算一个值在4 x 4 矩阵中 横排和竖排的位置
+local function calcLineRowPos(num)
+    local linePos, rowPos = 0, 0
+
+    rowPos = num % FOUR
+    if rowPos == 0 then
+        rowPos = FOUR
+    end
+
+    linePos = math.ceil(num / FOUR)
+    return linePos, rowPos
+end
+
+--判断是否获得横排(上方)大奖
+local function isGetLineAward(pos, awardRecordData)
+    -- if pos % FOUR == 0 then
+    --     pos = FOUR
+    -- end
+
+    local isGet = true
+    for i=1, FOUR do
+        if not awardRecordData[pos] then
+            isGet = false
+            break
+        end
+        pos = pos + FOUR
+    end
+    return isGet
+end
+
+--判断是否获得竖排(右边)大奖
+local function isGetRowAward(pos, awardRecordData)
+    local isGet = true
+    local startPos = (pos- 1) * FOUR + 1
+    for i=1, FOUR do
+        if not awardRecordData[startPos] then
+            isGet = false
+            break
+        end
+        startPos = startPos + 1
+    end
+    return isGet
+end
+
+--是否需要重置奖励
+local function isReset(lineTbl, rowTbl)
+    local lineNum, rowNum = 0,0
+    for _,_ in pairs(lineTbl or {}) do
+        lineNum = lineNum + 1
+    end
+
+    if lineNum < FOUR then
+        return false
+    end
+
+    for _,_ in pairs(rowTbl or {}) do
+        rowNum = rowNum + 1
+    end
+
+    if rowNum < FOUR then
+        return false
+    end
+    return true
+end
+
+--随机普通奖励,返回的是normalAwardIdxTbl的key
+local function randAwardIdx(normalAwardIdxTbl, normalAwardRecord, normalAwardCfg)
+    local weight, randIdx, randWeight, totalWeight = 0,0,0,0
+    local len = 0
+    local subAwardIdxVec = {}
+
+    for i, cfgIndex in ipairs(normalAwardIdxTbl) do
+        if isGmMode and normalAwardRecord then     --GM模式随机,剔除掉已经获得的奖励, 在剩下奖励中随机
+            if not normalAwardRecord[i] then
+                len = len + 1
+                totalWeight = totalWeight + normalAwardCfg[cfgIndex][3]
+                subAwardIdxVec[len] = {normalAwardCfg[cfgIndex][3], i}
+            end
+        else
+            len = len + 1
+            totalWeight = totalWeight + normalAwardCfg[cfgIndex][3]
+            subAwardIdxVec[len] = {normalAwardCfg[cfgIndex][3], i}
+        end
+    end
+
+    randWeight = math.random(0, totalWeight)
+    for _, data in ipairs(subAwardIdxVec) do
+        weight = weight + data[1]
+        if randWeight <= weight then
+            randIdx = data[2]
+            break
+        end
+    end
+
+    return randIdx
+end
+
+--重置奖励
+local function reset(actData)
+    actData.normalAwardRecord = nil
+    actData.lineAwardRecord = nil
+    actData.rowAwardRecord = nil
+
+    local config = AbsActExcel.AbsLotteryCardLogic
+    actData.lineAwardIdxTbl = generateAwardByWeight(config[2].award, FOUR)
+    actData.rowAwardIdxTbl = generateAwardByWeight(config[3].award, FOUR)
+end
+
+--抽奖
+local function lottery(human, actData, lotteryCnt, awardVec)
+    local config = AbsActExcel.AbsLotteryCardLogic
+    local normalAwardCfg = config[1].award
+    local normalAwardRecord = actData.normalAwardRecord
+    local normalAwardIdxTbl = actData.normalAwardIdxTbl
+
+    local subCnt = -1
+    local randPosList = {}
+    --local isRepeat = false
+    local repeatPosList = {}
+    local getNormalAwardCnt = 0
+    if normalAwardRecord then
+        for _,_ in pairs(normalAwardRecord) do
+            getNormalAwardCnt = getNormalAwardCnt + 1
+        end
+    end
+
+    for i=1, lotteryCnt do
+        local randPos = randAwardIdx(normalAwardIdxTbl, normalAwardRecord, normalAwardCfg)
+        randPosList[#randPosList+1] = randPos
+        local cfgIndex = normalAwardIdxTbl[randPos]
+        local itemInfo = normalAwardCfg[cfgIndex]
+        awardVec[#awardVec+1] = {itemInfo[1], itemInfo[2]}
+
+        getNormalAwardCnt = getNormalAwardCnt + 1
+
+        --当前抽得普通奖励大于4个且之前未抽到过该位置的奖励
+        if getNormalAwardCnt >= FOUR and not normalAwardRecord[randPos] then
+            local linePos, rowPos = calcLineRowPos(randPos)
+            local lineAwardRecord = actData.lineAwardRecord
+            local rowAwardRecord = actData.rowAwardRecord
+
+            --更新普通奖励获得记录
+            normalAwardRecord[randPos] = '1'
+
+            local isGetLine, isGetRow = false, false
+
+            --是否获得横排(上方的)大奖
+            if not lineAwardRecord or not lineAwardRecord[rowPos] then
+                isGetLine = isGetLineAward(rowPos, normalAwardRecord)
+                if isGetLine then
+                    local cfgIdx = actData.lineAwardIdxTbl[rowPos]
+                    local lineAwardItem = config[2].award[cfgIdx]
+                    awardVec[#awardVec+1] = {lineAwardItem[1], lineAwardItem[2]}
+                    actData.lineAwardRecord = actData.lineAwardRecord or {}
+                    actData.lineAwardRecord[rowPos] = '1'
+                end
+            end
+
+            --是否获得竖排(右方的)大奖
+            if not rowAwardRecord or not rowAwardRecord[linePos] then
+                isGetRow = isGetRowAward(linePos, normalAwardRecord)
+                if isGetRow then
+                    local cfgIdx = actData.rowAwardIdxTbl[linePos]
+                    local rowAwardItem = config[3].award[cfgIdx]
+                    awardVec[#awardVec+1] = {rowAwardItem[1], rowAwardItem[2]}
+                    actData.rowAwardRecord = actData.rowAwardRecord or {}
+                    actData.rowAwardRecord[linePos] = '1'
+                end
+            end
+
+            --是否所有奖励都领完, 需要重置奖励
+            if isGetLine or isGetRow then
+                if isReset(actData.lineAwardRecord, actData.rowAwardRecord) then
+                    reset(actData)
+
+                    subCnt = lotteryCnt - i
+                    break
+                end
+            end
+        else
+            if normalAwardRecord and normalAwardRecord[randPos] then
+                --isRepeat = true
+                repeatPosList[#repeatPosList+1] = randPos
+            else
+                normalAwardRecord = normalAwardRecord or {}
+                normalAwardRecord[randPos] = '1'
+                actData.normalAwardRecord = normalAwardRecord
+            end
+        end
+    end
+    return randPosList, repeatPosList, subCnt
+end
+
+
+--GM接口,设置本活动是否使用GM模式, val > 0 表示使用GM模式
+function SetMode(val)
+    if val > 0 then
+        isGmMode = true
+    else
+        isGmMode = false
+    end
+end
+
+function isOpen(human, YYInfo, funcConfig)
+    local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
+    return state, endTime, startTime
+end
+
+function isActive(human, YYInfo, funcConfig)
+    local state = isOpen(human, YYInfo, funcConfig)
+    return not state
+end
+
+--红点判断
+function isRed(human, YYInfo, funcConfig)
+    local actData = human.db.absAct[funcConfig.funcID]
+    if not actData then
+        return false
+    end
+
+    local freeCnt = actData.freeCnt
+    if freeCnt and freeCnt == 0 then
+        return false
+    end
+
+    return true
+end
+
+--跨天函数
+function updateDaily(human, id)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return
+    end
+
+    actData.freeCnt = 1
+
+    --红点刷新
+    YunYingLogic.sendBanner(human)
+    local config = AbsActExcel.absActivity[id]
+    YunYingLogic.sendGroupUpdate(YYInfo[id], human, config.panelID)
+end
+
+--查询
+function Query(human, id)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local msgRet = Msg.gc.GC_LOTTERYCARD_QUERY
+
+    local config = AbsActExcel.AbsLotteryCardLogic
+    if not actData.lineAwardIdxTbl then
+        actData.lineAwardIdxTbl = generateAwardByWeight(config[2].award, FOUR)
+        actData.rowAwardIdxTbl = generateAwardByWeight(config[3].award, FOUR)
+        actData.normalAwardIdxTbl = generateAwardByWeight(config[1].award, 16)
+    end
+
+    populateMsg(msgRet, actData)
+
+    Grid.makeItem(msgRet.lottery1Spend, LOTTERYCOSTTYPE, LOTTERY1COSTCNT)
+    Grid.makeItem(msgRet.lottery10Spend, LOTTERYCOSTTYPE, LOTTERY10COSTCNT)
+    Grid.makeItem(msgRet.resetSpend, LOTTERYCOSTTYPE, RESETCOSTCNT)
+
+    Msg.send(msgRet, human.fd)
+end
+
+--抽奖, 可抽到重复奖励, 某行/列的普通奖励都获得时,自动获得对应行列的大奖,所有普通和大奖都获得时,重置奖励
+function Lottery(human, id, lotteryCnt)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    if lotteryCnt ~= 1 and lotteryCnt ~= 10 then
+        return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
+    end
+
+    local itemSpendCnt = LOTTERY1COSTCNT
+    if lotteryCnt == 1 then
+        if not actData.freeCnt or actData.freeCnt ~= 0 then
+            itemSpendCnt = 0
+            actData.freeCnt = 0
+        end
+    else
+        itemSpendCnt = LOTTERY10COSTCNT
+    end
+
+    if itemSpendCnt > 0 then
+        if BagLogic.getItemCnt(human, LOTTERYCOSTTYPE) < itemSpendCnt then
+            return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
+        end
+        --扣消耗
+        BagLogic.delItem(human, LOTTERYCOSTTYPE, itemSpendCnt, LOGTAG)
+    end
+
+    --抽奖
+    local awardVec = {}
+    local randPosList, repeatPosList, subCnt = lottery(human, actData, lotteryCnt, awardVec)
+
+    --全部奖励已获得,还有抽奖次数,需要先重置奖励
+    if subCnt > 0 then
+        local msgRet = Msg.gc.GC_LOTTERYCARD_RESET
+        populateMsg(msgRet, actData)
+        Msg.send(msgRet, human.fd)
+
+        randPosList, repeatPosList = lottery(human, actData, subCnt, awardVec)
+    end
+    --发放抽到的道具
+    BagLogic.addItemList(human, awardVec, LOGTAG)
+
+    local config = AbsActExcel.AbsLotteryCardLogic
+    local awardCfg = config[1].award
+
+    local msgRet = Msg.gc.GC_LOTTERYCARD_LOTTERY
+    local normalAwardInfo = msgRet.normalAwardInfo
+    normalAwardInfo[0] = #randPosList
+
+    --小奖卡牌重复被翻到后,更换该牌的奖励
+    local  normalAwardIdxTbl = actData.normalAwardIdxTbl
+    local newAwardPosList = generateAwardByWeight(config[1].award, #randPosList)
+
+    for i, dbIdx in ipairs(repeatPosList) do
+        print(string.format("重复随机到奖励位置: %d, 新奖励在配置中位置: %d\n", dbIdx, newAwardPosList[i]))
+        local cfgIdx = newAwardPosList[i]
+        normalAwardIdxTbl[dbIdx] = cfgIdx
+    end
+
+
+    for i, dbIdx in ipairs(randPosList) do
+        normalAwardInfo[i].idx = dbIdx
+        normalAwardInfo[i].getState = 1
+
+        local cfgIdx = normalAwardIdxTbl[dbIdx]
+        local itemInfo = awardCfg[cfgIdx]
+        Grid.makeItem(normalAwardInfo[i].item, itemInfo[1], itemInfo[2])
+    end
+
+
+    --下发数据
+    msgRet.isRepeat = #repeatPosList > 0 and 1 or 0
+    msgRet.freeCnt = 0
+    local freeCnt = actData.freeCnt
+    if not freeCnt or freeCnt ~= 0 then
+        msgRet.freeCnt = 1
+    end
+
+    --普通奖励
+    --populateAwardMsg(msgRet.normalAwardInfo, config[1].award, actData.normalAwardRecord, actData.normalAwardIdxTbl)
+
+    --横排大奖
+    populateAwardMsg(msgRet.lineAwardInfo, config[2].award, actData.lineAwardRecord, actData.lineAwardIdxTbl)
+
+    --竖排大奖
+    populateAwardMsg(msgRet.rowAwardInfo, config[3].award, actData.rowAwardRecord, actData.rowAwardIdxTbl)
+
+    Msg.send(msgRet, human.fd)
+
+    -- for i, idx in ipairs(randIds) do
+    --     local cfgIdx = newAwardPosList[i]
+    --     normalAwardIdxTbl[idx] = cfgIdx
+    -- end
+
+    --全部奖励已获得,没有抽奖次数,最后重置奖励
+    if subCnt == 0 then
+        local msgRet = Msg.gc.GC_LOTTERYCARD_RESET
+        populateMsg(msgRet, actData)
+        Msg.send(msgRet, human.fd)
+    end
+
+
+    --更新红点
+    if itemSpendCnt <= 0 then
+        YunYingLogic.sendBanner(human)
+        local config = AbsActExcel.absActivity[id]
+        YunYingLogic.sendGroupUpdate(YYInfo[id], human, config.panelID)
+    end
+end
+
+--重置
+function ResetAward(human, id)
+    local state = AbsActLogic.isStarted(human, id)
+    if not state then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local actData = human.db.absAct[id]
+    if not actData then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    if BagLogic.getItemCnt(human, LOTTERYCOSTTYPE) < RESETCOSTCNT then
+        return Broadcast.sendErr(human, Lang.COMMON_ITEM_NOT_ENOUGH)
+    end
+    --扣消耗
+    BagLogic.delItem(human, LOTTERYCOSTTYPE, RESETCOSTCNT, LOGTAG)
+
+    --重置
+    reset(actData)
+
+    --下发数据
+    local msgRet = Msg.gc.GC_LOTTERYCARD_RESET
+    populateMsg(msgRet, actData)
+    Msg.send(msgRet, human.fd)
+end

+ 4 - 0
script/module/absAct/Handler.lua

@@ -288,6 +288,10 @@ function CG_EXCELLENTGIFT_GET_REWARD(human, msg)
     AbsExcellentGiftLogic.GetReward(human, msg.id, msg.taskIdx, msg.page)
 end
 
+function CG_EXCELLENTGIFT_FINISH_TASK(human, msg)
+    AbsExcellentGiftLogic.FinishTaskByDiamond(human, msg.id, msg.taskIdx, msg.page)
+end
+
 -----------------------------------------------------新商业化活动——秘境翻牌--------------------------------------------------
 function CG_LOTTERYCARD_LOTTERY(human, msg)
     AbsLotteryCardLogic.Lottery(human, msg.id, msg.lotteryCnt)

+ 10 - 1
script/module/absAct/Proto.lua

@@ -1101,6 +1101,8 @@ CG_EXCELLENTGIFT_QUERY = {
 --查询返回协议
 GC_EXCELLENTGIFT_QUERY = {
     {"taskList",                        10,       TASK_INFO},          --所有任务数据
+    {"finishTaskCost",                   1,       ItemData},
+    {"redDotList",                       7,       "byte"},
 }
 
 --请求领奖协议
@@ -1111,6 +1113,13 @@ CG_EXCELLENTGIFT_GET_REWARD = {
 }
 
 
+--请求通过消耗古玉完成任务
+CG_EXCELLENTGIFT_FINISH_TASK = {
+    {"id",			                    1,      "int"},                 -- 活动ID
+    {"taskIdx",                         1,       "byte"},               -- 任务索引
+    {"page",                            1,       "byte"},             -- 分页, 1-免费,2-30...
+}
+
 ---------------------秘境翻牌------------------
 REAWARD_INFO = {
     {"item",                            1,       ItemData},            -- 奖励信息
@@ -1139,7 +1148,7 @@ CG_LOTTERYCARD_LOTTERY = {
 
 --抽奖返回协议
 GC_LOTTERYCARD_LOTTERY = {
-    {"normalAwardInfo",                 16,      REAWARD_INFO},         --普通奖励数据
+    {"normalAwardInfo",                 10,      REAWARD_INFO},         --普通奖励数据
     {"lineAwardInfo",                   4,       REAWARD_INFO},         --横排(上方)大奖数据
     {"rowAwardInfo",                    4,       REAWARD_INFO},         --竖排(右边)大奖数据
     {"freeCnt",                         1,       "byte"},               --当日免费抽取次数,为0时表示没有,为其他表示可以免费抽取一次

+ 3 - 0
script/module/chat/ChatLogic.lua

@@ -20,6 +20,7 @@ local SettingLogic = require("setting.SettingLogic")
 local ObjHuman = require("core.ObjHuman")
 local InnerMsg = require("core.InnerMsg")
 local CommonDB = require("common.CommonDB")
+local YunYingLogic = require("yunying.YunYingLogic")
 
 local CHAT_SENDDOWN_RESON_LV = 1
 local CHAT_SENDDOWN_RESON_DAY = 2
@@ -249,6 +250,8 @@ function chat(human, recvMsg, isJson)
         end
     end
 	
+    YunYingLogic.onCallBack(human, "ChatTimes", 1)
+
     -- 上报消息到后台
 	ChatHandler.chatReport(human,recvMsg.msg)
     return true

+ 17 - 0
script/module/chat/Gm.lua

@@ -1951,4 +1951,21 @@ end
 
 function d3.delTreasure(human)
  	TreasureChestLogic.TreasureChestLogic_GmClear(human)
+end
+
+--新商业活动——秘境翻牌, value > 0 表示该活动抽卡时使用GM模式
+function d3.chouka(human, value)
+	value = tonumber(value)
+	local AbsLotteryCardLogic = require("absAct.AbsLotteryCardLogic")
+	AbsLotteryCardLogic.SetMode(value)
+end
+
+--事件GM,设置某个事件进度
+function d3.czhl(human, value)
+	local pos = string.find(value, " ", 1, true)
+	if pos == nil then return end
+	local triggerId = tonumber(string.sub(value, 1, pos - 1))
+	local progress = tonumber(string.sub(value,pos+1,#value))
+	local AbsExcellentGiftLogic = require("absAct.AbsExcellentGiftLogic")
+	AbsExcellentGiftLogic.TriggerCbFunc(human, triggerId, progress, true)
 end

+ 1 - 0
script/module/drawCard/DrawCardLogic.lua

@@ -54,6 +54,7 @@ local NewHeroLogic = require("absAct.NewHeroLogic")
 Json = Json or require("common.Json")
 local TalismanLogic = require("talisman.TalismanLogic")
 
+
 DRAWCARD_ID0 = 0	-- 积分召唤
 DRAWCARD_ID1 = 1	-- 基础召唤
 DRAWCARD_ID2 = 2	-- 高级召唤

+ 4 - 0
script/module/friend/FriendLogic.lua

@@ -29,6 +29,8 @@ local JjcDB = require("jjc.JjcDB")
 local ChatRecord = require("chat.ChatRecord")
 local CombatVideo = require("combat.CombatVideo")
 local Log = require("common.Log")
+local YunYingLogic = require("yunying.YunYingLogic")
+
 
 local fields = { name = 1, lv = 1, lastLogoutTime = 1, head = 1, headFrame = 1, chenghao = 1, zhandouli = 1}
 local tempHuman = { }
@@ -454,6 +456,8 @@ function fight(human, args)
 	-- 开打
     local targetUuid = args[1]
 	CombatLogic.combatBegin(human, 1001, args, CombatDefine.COMBAT_TYPE14, targetUuid)
+
+	YunYingLogic.onCallBack(human, "friendCombat", 1)
 end
 
 

+ 2 - 1
script/module/fuwen/FuwenLogic.lua

@@ -24,7 +24,6 @@ local MailManager = require("mail.MailManager")
 local MailExcel = require("excel.mail")
 local HeroGrowUp = require("absAct.HeroGrowUp")
 local YunYingLogic = require("yunying.YunYingLogic")
-
 --发送所有符文列表 onLogin
 function sendFuwenRefineList(human)
 	local msgRet = Msg.gc.GC_FUWEN_ALL_LIST
@@ -681,6 +680,8 @@ function fuwenRefreshDo(human,fuwenID,fuwenIndex,heroID,heroIndex,pos)
     Msg.send(msgRet,human.fd)
 
     fuwenRefreshQuery(human,fuwenID,fuwenIndex,pos,heroID,heroIndex)
+
+    YunYingLogic.onCallBack(human, "onFuwenChongZhu",1)
 end
 
 local function cmpSkill(a, b)

+ 7 - 1
script/module/lostTemple/lostTempleCombatLogic.lua

@@ -28,7 +28,7 @@ local RoleAttr = require("role.RoleAttr")
 local ItemDefine = require("bag.ItemDefine")
 local Broadcast = require("broadcast.Broadcast")
 local Lang = require("common.Lang")
-
+local YunYingLogic = require("yunying.YunYingLogic")
 
 -------------------------------------- combat -----------------------------------------
 -- 获取属性
@@ -290,9 +290,15 @@ function onFightEnd(human, result, combatType, cbParam, combatInfo, param)
             Grid.makeItem(msgRet.randomReward[1], randomItem[1], randomItem[2])
         end
 
+
         -- BOOS
         if not LostTempleLogic.putSet(human, putY, elementConfig.cmd) then
             LostTempleLogic.nextGrid(human, putY)
+        else
+            --通关判断
+            if LostTempleLogic.IsPass(human) then
+                YunYingLogic.onCallBack(human, "lostTempleCombat", 1)
+            end
         end
     else
         grid.objStatus = grid.objStatus or { }

+ 42 - 1
script/module/lostTemple/lostTempleLogic.lua

@@ -650,6 +650,48 @@ local function makeGridNet(human, net)
     return true
 end
 
+--通关
+function IsPass(human)
+    initDB(human)
+    if not human.lostTemple then return end
+
+    local startX = human.lostTemple.x + 1
+    local endX = human.lostTemple.x + QUEUE_LEN
+
+    local layer = human.lostTemple.layer
+    local random = human.lostTemple.random
+    local LostTempleConfig = LostTempleExcel[layer]
+    if not LostTempleConfig then return end
+
+    local LostTemple = LostTempleConfig[random]
+    if not LostTemple then return end
+
+    local type = 0
+    local len = 0
+    for x = startX, endX do
+        if human.lostTemple.grid[x] then
+            for y = 1, LostTemple.vertical do
+                if human.lostTemple.grid[x][y] then
+                    len = len + 1
+                    local grid = human.lostTemple.grid[x][y]
+                    local element = ElementExcel[grid.id]
+                    if not element then
+                        return false
+                    end
+                    type = element.type
+                end
+            end
+        end
+    end
+
+    if len == 1 and type == 6 and layer >= 3 then
+        return true
+    end
+    return false
+end
+
+
+
 -- ��ѯ
 function query(human)  
     if not isOpen(human) then
@@ -673,7 +715,6 @@ function query(human)
     msgRet.playerY = human.lostTemple.y
     msgRet.layer = human.lostTemple.layer
     msgRet.leftTime = leftTime
-
     Msg.send(msgRet, human.fd)
 
     sendHeroStatus(human)

+ 3 - 0
script/module/mozhu/MoZhuLogic.lua

@@ -41,6 +41,8 @@ local JjcActLogic = require("jjc.JjcActLogic")
 local DragonNestLogic = require("copy.DragonNestLogic")
 local HeroLogic = require("hero.HeroLogic")
 local MozhuMiddleLogic = require("mozhu.MoZhuMiddleLogic")
+local YunYingLogic = require("yunying.YunYingLogic")
+
 
 MOZHU_OPEN_DAY = {[1]= 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1, [7] = 1}
 MOZHU_OPEN_DAY_2 = {1, 7}
@@ -868,6 +870,7 @@ function onFightEnd(human,result, combatType, cbParam , combatInfo)
     --InnerMsg.sendMsg(0, msgInner)
     MozhuMiddleLogic.LW_MOZHU_FIGHT_END(0,msgInner)
 
+    YunYingLogic.onCallBack(human, "MoZhuCombat", 1)
 end
 
 

+ 33 - 0
script/module/trigger/TriggerDefine.lua

@@ -0,0 +1,33 @@
+
+
+--定义事件标识
+BATTLE_MOP_UP = 1            --冒险闯关扫荡
+LOSTTEMPLE_PASS = 2          --失落神庙通关
+YJTREASURE_PASS_LEVEL = 3    --遗迹探险层数
+FRIEND_COMBAT = 4            --好友切磋次数
+CHAT_TIMES = 5               --所有聊天频道发言次数
+MOZHU_CHALLENGE = 6         --魔王梼杌参数次数
+DRAWCALL_SERNIOR_CNT = 7      --高级召唤次数
+FUWEN_RECASTING = 8          --符文重铸次数
+UNION_DONATE = 9             --公会捐献次数
+ZHANBU_SYNTHESIS = 10         --占卜合成次数
+
+
+--触发事件后, 新值与旧值相加
+
+TRIGGERADDTB = {
+    [BATTLE_MOP_UP] = BATTLE_MOP_UP,
+    [LOSTTEMPLE_PASS] = LOSTTEMPLE_PASS,
+    [YJTREASURE_PASS_LEVEL] = YJTREASURE_PASS_LEVEL,
+    [FRIEND_COMBAT] = FRIEND_COMBAT,
+    [CHAT_TIMES] = CHAT_TIMES,
+    [MOZHU_CHALLENGE] = MOZHU_CHALLENGE,
+    [DRAWCALL_SERNIOR_CNT] = DRAWCALL_SERNIOR_CNT,
+    [FUWEN_RECASTING] = FUWEN_RECASTING,
+    [UNION_DONATE] = UNION_DONATE,
+    [ZHANBU_SYNTHESIS] = ZHANBU_SYNTHESIS,
+}
+
+--触发事件后, 用新值替换旧值
+TRIGGERUPDATETB = {
+}

+ 95 - 0
script/module/trigger/TriggerLogic.lua

@@ -0,0 +1,95 @@
+--触发事件处理模块
+--需要保证订阅在前, 触发在后
+
+
+local TriggerDefine = require("trigger.TriggerDefine")
+
+
+--订阅列表
+local moniterTbl = {}
+
+
+--检测触发事件是否正确
+local function checkTrigger(arg)
+    local errTag = nil
+    if type(arg) == "table" then
+        for _, tag in ipairs(arg) do
+            if not TriggerDefine.TRIGGERADDTB[tag] and not TriggerDefine.TRIGGERUPDATETB[tag] then
+                errTag = tag
+                break
+            end
+        end
+    else
+        if not TriggerDefine.TRIGGERADDTB[arg] and not TriggerDefine.TRIGGERUPDATETB[arg] then
+            errTag = arg
+        end
+    end
+
+    if errTag then
+        assert(false, string.format("注册事件不存在, tag = %s", errTag))
+    end
+    return true
+end
+
+
+--注册订阅
+function RegisterMoniter(triggerArr, cbFunc)
+    checkTrigger(triggerArr)
+
+    local handler = #moniterTbl+1
+    moniterTbl[handler] = {
+        triggerArr = triggerArr,
+        cbFunc = cbFunc,
+    }
+
+    return handler
+end
+
+--移除订阅
+function RemoveMoniter(handler)
+    if not handler then
+        return
+    end
+
+    table.remove(moniterTbl, handler)
+end
+
+
+--广播
+function Broadcast(human, triggerTag, val, isAdd)
+    for tag, v in ipairs(moniterTbl) do
+        if table.find(v.triggerArr, triggerTag) then
+            local f = v.cbFunc
+            local res = pcall(f, human, triggerTag, val, isAdd)
+            if not res then
+                print(string.format("广播失败, handler = %s", tag))
+            end
+        end
+    end
+end
+
+
+--触发事件
+function Trigger(human, triggerTag, val)
+    local isAdd = false
+    if TriggerDefine.TRIGGERADDTB[triggerTag] then
+        isAdd = true
+    end
+
+    if not isAdd then
+        if not TriggerDefine.TRIGGERUPDATETB[triggerTag] then
+            assert(false, string.format("触发事件不存在, tag = %s", triggerTag))
+        end
+    end
+
+
+    Broadcast(human, triggerTag, val, isAdd)
+end
+
+
+
+
+
+
+
+

+ 2 - 1
script/module/union/UnionDonateLogic.lua

@@ -162,7 +162,8 @@ function donateDo(human,type)
     end
     MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_10,1)
     
-    YunYingLogic.onCallBack(human, "onUnionDonate",1)  
+    YunYingLogic.onCallBack(human, "onUnionDonate",1)
+
      
     UnionLogic.sendUnionChange(union)
     unionDonateQuery(human)

+ 3 - 0
script/module/yjTreasure/YjTreasureLogic.lua

@@ -25,6 +25,7 @@ local Timer = require("core.Timer")
 local MengxinLogic = require("present.MengxinLogic")
 local HeroGrowUp = require("absAct.HeroGrowUp")
 local Log = require("common.Log")
+local YunYingLogic = require("yunying.YunYingLogic")
 
 
 YJ_TREASURE_GRID_MAX = 25 --从左到右 从上到下 1-25个格子
@@ -902,6 +903,8 @@ function yjTreasure2NextLayer(human)
     --TODO:记录遗迹探险
     Log.write(Log.LOGID_OSS_BATTLE_RELIC, human.db._id, human.db.account, human.db.name, nowLayer + 1)
 
+    YunYingLogic.onCallBack(human, "YJTreasurePass", 1)
+
     CG_YJTREASURE_QUERY(human, 1)
 end
 

+ 4 - 0
script/module/zhanbu/ZhanbuLogic.lua

@@ -20,6 +20,8 @@ local AbsZhanbuLunpanLogic = require("absAct.AbsZhanbuLunpanLogic")
 local YunYingLogic = require("yunying.YunYingLogic")
 local TalismanLogic = require("talisman.TalismanLogic")
 local RecommendLineup = require("drawCard.RecommendLineup")
+
+
 --[[
     pool ����
     hand ����
@@ -342,6 +344,8 @@ function buyCard(human,index,heroID)
         
         HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE3, 1)
         MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_6,1)
+
+        YunYingLogic.onCallBack(human, "ZhanBuHecheng",1)
     else
         -- �ж������Ƿ�����
         -- if human.db.zhanbu.handCnt >= human.db.zhanbu.handMaxCnt then