Browse Source

精英副本-一键领取 和 修改下发 通过关卡

SCFC 1 year ago
parent
commit
9d7595082c

+ 1 - 1
script/module/bag/SuipianLogic.lua

@@ -478,7 +478,7 @@ function SUIPIAN_SYNTHESIS(human, itemID, itemUseCnt)
 				print("[SUIPIAN_SYNTHESIS] 获取目标ID失败 dropID = "..dropID)
 				return
 			end
-			
+
 			outItemIDList = outItemIDList or {}
 			outItemIDList[targetID] = outItemIDList[targetID] or 0
 			outItemIDList[targetID] = outItemIDList[targetID] + 1

+ 106 - 42
script/module/battle/BattleLogic.lua

@@ -861,6 +861,21 @@ function setGetReward(human, id)
     tBattleRewards[intIndex] = Util.setBit(tBattleRewards[intIndex], byteIndex)
 end
 
+-- 通过类型设置领取
+function setGetRewardByType(human, id, nBattleType)
+    local tBattleRewards =  BattleLogic_GetBattleRewardsByType(human, nBattleType)
+    if not tBattleRewards then
+        Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "BattleLogic_GetBattleRewards 参数不正确")
+        print("[setGetReward] 不存在对应的 奖励配置")
+        return
+    end
+  
+    local intIndex = math.ceil(id / WeiLen)
+    local byteIndex = id % WeiLen
+    tBattleRewards[intIndex] = tBattleRewards[intIndex] or 0
+    tBattleRewards[intIndex] = Util.setBit(tBattleRewards[intIndex], byteIndex)
+end
+
 -- 是否有可领取的
 function hasCanGetReward(human)
     local tBattleConfig = BattleLogic_GetBattleConfig(human)
@@ -1232,7 +1247,8 @@ function query(human)
     
     local nBattleAdopt = BattleLogic_GetBattleAdopt(human, nBattleType)
     if nBattleAdopt == 1 then
-        print("[query] nNowBattleID 为最大值 nNowBattleID = "..nNowBattleID.." nNowGuaJiID = "..nNowGuaJiID)
+        print("[query] nNowBattleID 为最大值 nNowBattleID = "
+                ..nNowBattleID.." nNowGuaJiID = "..nNowGuaJiID.." nBattleType = "..nBattleType)
         msgRet.nowBattleID = configNode + 1
     end
     
@@ -1252,10 +1268,11 @@ function query(human)
     end
 
     local nJudeNum = nNowGuaJiID
-    if nNowGuaJiID ~= nNowBattleID then
-        if nNowGuaJiID + 1 < nNowBattleID then
-            nJudeNum = nNowBattleID - 1
-        end
+    -- 已通关
+    if nBattleAdopt == 1 then
+        nJudeNum = configNode
+    else
+        nJudeNum = nNowBattleID - 1
     end
 
     msgRet.maxBattleID = configNode
@@ -2022,7 +2039,7 @@ local function hangExpGet(human,isDiamond)
 
     -- 检测装备数量
     if tBattleOut.equip then
-        local equipCnt = #htBattleOut.equip
+        local equipCnt = #tBattleOut.equip
         if not EquipLogic.checkEmptyCnt(human, equipCnt) then
             return
         end
@@ -3270,10 +3287,12 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
 
     -- 判断ID得用战斗ID-1, 因为挂机ID可以设置
     local nJudeNum = nGuaJiID
-    if nGuaJiID ~= nBattleID then
-        if nGuaJiID + 1 < nBattleID then
-            nJudeNum = nBattleID - 1
-        end
+    local nBattleAdopt = BattleLogic_GetBattleAdopt(human, nBattleType)
+    -- 已通过
+    if nBattleAdopt == 1 then
+        nJudeNum = battleNumber
+    else
+        nJudeNum = nBattleID - 1
     end
 
     print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
@@ -3353,8 +3372,6 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
                             msgRet.curIndex=curTotalNumber
                             -- curIndex = 1
                             Msg.send(msgRet, human.fd)
-                            
-                            print("[BattleLogic_GetNorewardReceived] send client msgRet.curIndex:"..msgRet.curIndex.." msgRet.isEnd:"..msgRet.isEnd.." msgRet.list[0]:"..msgRet.list[0])
 
                             --local info=Util.printTable(msgRet)
                             --print("getNorewardReceived0->>:"..info)
@@ -3404,53 +3421,100 @@ function CG_ELITE_SELECT(human, nSelectDiff)
 end
 
 -- 客户端请求领取奖励
-function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human, nBattleType, nBattleID)
+function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human, nBattleType)
     local tBattleConfig = BattleLogic_GetBattleConfig(human)
     local nGuaJiID = BattleLogic_GetBattleGuaJiIDByType(human, nBattleType)
-    if not tBattleConfig or -1 >= nGuaJiID then
+    local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
+    if not tBattleConfig or -1 >= nGuaJiID or -1 >= nBattleID then
         return
     end
+
     local tMsgRet = Msg.gc.GC_BATTLE_TONGGUAN_REWARD_GET_COPY
-    local tConfig = tBattleConfig.node[nBattleID].tongguan
-    if #tConfig < 1 then
+    local nChoseLen = nBattleID - 1
+    local nConfigLen = #tBattleConfig.node
+    if 0 >= nChoseLen or nChoseLen > nConfigLen then
         tMsgRet.status = 0
         Msg.send(tMsgRet, human.fd)
         return
     end
 
+    print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] nChoseLen = "..nChoseLen.. " nBattleID = "..nBattleID)
+
     tMsgRet.status = 1
+    local tItemList = {}
+    for id = 1, nChoseLen, 1 do
+        local tNodeCofig = tBattleConfig.node[id]
+        if tNodeCofig and #tNodeCofig.tongguan >= 1 then
+            -- 未领取
+            if false == isGetRewardByType(human, id, nBattleType) then
+                print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 未领取的 id = "..id)
+                if #tNodeCofig.tongguan == 1 and tNodeCofig.tongguan[1][3] then
+                    -- 英雄
+                    if HeroLogic.getEmptyCnt(human) < 1 then
+                        return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
+                    end
+                    local heroID = tNodeCofig.tongguan[1][1]
+                    local cnt = tNodeCofig.tongguan[1][2]
+                    local star = tNodeCofig.tongguan[1][3]
+                    if cnt > 0 then
+                        -- 设置已领取
+                        setGetRewardByType(human, id, nBattleType)
+    
+                        local msg = Msg.gc.GC_SUIPIAN_SUMMON
+                        for i = 1, cnt do
+                            local heroGrid = HeroGrid.createHeroGrid(heroID, star)
+            
+                            HeroLogic.addHeroByGrid(human, heroGrid, "battle_extra_reward")
+            
+                            SuipianLogic.makeResultItemData(msg.heroList[i], heroID, 1, 1)
+                        end
+            
+                        msg.isHero = 1
+                        msg.list[0] = 0
+                        msg.heroList[0] = cnt
+                        msg.fenJieList[0] = 0
+            
+                        Msg.send(msg, human.fd)
+                    else
+                        Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 领取奖励配置的英雄cnt为<= 0 id = "..human.db.name)
+                        print("[CG_BATTLE_TONGGUAN_REWARD_GET_COPY] 不正确的 英雄碎片数量")
+                    end
+                else
+                    setGetRewardByType(human, id, nBattleType)
 
-    getTongGuanReward(human, nBattleID)
-
-    tMsgRet.tongguan[0] = 0
-    if #tConfig ~= 0 then
-        tMsgRet.tongguan[0] = 1
-        local tNet = tMsgRet.tongguan[1]
-        tNet.status = STATUS_NONE
-        tNet.levelName = getBattleNameByType(nBattleID, nBattleType)
-        tNet.index = nBattleID
-        tNet.nowBattle = getBattleNameByType(nGuaJiID, nBattleType)
-        tNet.reward[0] = 0
-        tNet.heroReward[0] = 0
-
-        if tConfig[1][3] then
-            tNet.heroReward[0] = 1
-            local other = { }
-            other.star = tConfig[1][3]
-            HeroGrid.makeHeroSimpleByID(tNet.heroReward[1], tConfig[1][1], nil, other, human)
-            HeroGrid.makeHeroSimpleByGeneral(tNet.heroReward[1], tConfig[1][1])
-        else
-            tNet.reward[0] = 1
-            for i = 1, tNet.reward[0] do
-                local itemID = tConfig[i][1]
-                local itemCnt = tConfig[i][2]
-                Grid.makeItem(tNet.reward[i], itemID, itemCnt)
+                    for k, v in ipairs(tNodeCofig.tongguan) do
+                        local nItemID = v[1]
+                        local nItemNum = v[2]
+                        tItemList[nItemID] = tItemList[nItemID] or 0
+                        tItemList[nItemID] = tItemList[nItemID] + nItemNum
+                    end
+                    
+                    --BagLogic.addItemList(human, tNodeCofig.tongguan, "tongguan")
+                end
+
+                -- 触发国王君临奖励
+                ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE5, id)
+
+                RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
+                if id == 80 then
+                    KingWorldLogic.setState(human, 1)
+                end
             end
         end
     end
 
-    Msg.send(tMsgRet, human.fd)
+    if nil ~= _G.next(tItemList) then
+        local tPrize = {}
+        for k, v in pairs(tItemList) do
+            table.insert(tPrize, {k,v})
+        end
 
+        BagLogic.addItemList(human, tPrize, "tongguan")
+    end
+    
+    query(human)
+
+    Msg.send(tMsgRet, human.fd)
 end
 
 -- 客户端请求查询所有未领取奖励

+ 1 - 3
script/module/battle/Handler.lua

@@ -84,7 +84,5 @@ function CG_BATTLE_QUERY_ALL(human,msg)
 end
 
 function CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human,msg)
-    --print("1:CG_BATTLE_TONGGUAN_REWARD_GET_COPY")
-    BattleLogic.CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human,msg.index,msg.id)
-    --print("2:CG_BATTLE_TONGGUAN_REWARD_GET_COPY")
+    BattleLogic.CG_BATTLE_TONGGUAN_REWARD_GET_COPY(human,msg.index)
 end

+ 0 - 2
script/module/battle/Proto.lua

@@ -318,13 +318,11 @@ GC_ELITE_SELECT ={
 -- 通关奖励领取
 CG_BATTLE_TONGGUAN_REWARD_GET_COPY = { 
     {"index",1,"int"}, --查询副本类型
-	{"id",1,"int"}, --领取副本关卡ID
 }
 
 GC_BATTLE_TONGGUAN_REWARD_GET_COPY =
 {
 	{"status",		1,		"int"},					-- 领取状态(0、失败, 1、成功)
-	{"tongguan",	2,		Tongguan},              -- 通关奖励
 }
 
 --查询所有未领取奖励关卡奖励

+ 7 - 0
script/module/present/OpenServerActPowerUp.lua

@@ -0,0 +1,7 @@
+--------------------------------
+-- 文件名       :  OpenServerActPowerUp.lua
+-- 文件说明     :  开服7天活动 - 战力冲刺
+-- 创建时间     :   2024/11/14
+-- 创建人       :   FC
+--------------------------------
+