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

+ 12 - 0
script/module/bag/ItemLogic.lua

@@ -29,6 +29,7 @@ local HeroGrowUp = require("absAct.HeroGrowUp")
 local BuyExcel = require("excel.buy")
 local LostTempleLogic = require("lostTemple.lostTempleLogic")
 local SkinLogic = require("skin.SkinLogic")
+local BattleLogic = require("battle.BattleLogic")
 
 cmd 		= {}
 
@@ -342,6 +343,17 @@ function cmd.skinGen(data,human,skinId)
     return true
 end
 
+ -- 使用增加主线关卡扫荡次数道具
+ function cmd.AddFreeMopup(data, human)
+    if 0 >= data.left then
+        return false
+    end
+
+    BattleLogic.BattleLogic_AddMopup(human, data.id, data.cnt)
+
+    -- 把剩余数量改成0,才能消耗
+    data.left = 0
+ end
 -----------------------------------------------------------------------------
 
 -- 仅使用道具,不扣道具

+ 93 - 4
script/module/battle/BattleLogic.lua

@@ -690,6 +690,33 @@ local function BattleLogic_GetBattleAdopt(human, nBattleType)
     end
 end
 
+-- 获取额外增加扫荡次数
+local function BattleLogic_GetAddFreeMopupNum(human)
+    if not human then
+        return -1
+    end
+
+    if not human.db.mopupAddFreeCnt then
+        human.db.mopupAddFreeCnt = 0
+    end
+
+    return human.db.mopupAddFreeCnt
+end
+
+-- 设置额外增加扫荡次数
+local function BattleLogic_SetAddFreeMopupNum(human, nValue)
+    if not human then
+        return
+    end
+
+    print("[BattleLogic_SetAddFreeMopupNum] 消耗的额外次数 nValue = "..nValue)
+    human.db.mopupAddFreeCnt = human.db.mopupAddFreeCnt + nValue
+
+    if 0 > human.db.mopupAddFreeCnt then
+        human.db.mopupAddFreeCnt = 0
+    end
+end
+
 function getBattleRoleList(nBattleType, worldMapId)
     if not BATTLE_LEVEL_PLAYER_LIST then
         BATTLE_LEVEL_PLAYER_LIST = {}
@@ -1370,6 +1397,11 @@ function query(human)
         msgRet.canMopup = human.db.mopupDoCnt < BATTLE_MOPUP_CNT and 1 or 0
     end
 
+    -- 判断额外增加的扫荡次数
+    if 0 < BattleLogic_GetAddFreeMopupNum(human) and 0 == msgRet.canMopup then
+        msgRet.canMopup = 1
+    end
+
     local monsterOutId = nowNodeConfig.monsterOutID
     if not monsterOutId then
         print("[BattleLogic query] monsterOutId 为空")
@@ -2613,6 +2645,7 @@ function mopupQuery(human)
     end
     human.db.mopupDoCnt = human.db.mopupDoCnt or 0
     local nextDoCnt = human.db.mopupDoCnt + 1
+    nextDoCnt = nextDoCnt >= EliteDefine.BATTLE_MOPUP_MAX_LEN and EliteDefine.BATTLE_MOPUP_MAX_LEN or nextDoCnt
     -- local nodeConfig = BattleExcel.node[guajiID]
     local nodeConfig = tBattleConfig.node[guajiID]
     local dropID = nodeConfig.dropID
@@ -2644,11 +2677,18 @@ function mopupQuery(human)
     local mapConfig = tBattleConfig.map[nodeConfig.mapID]
     msgRet.name = mapConfig.name
     msgRet.item[0] = dropCnt
+    local nNowAddFreeCnt = BattleLogic_GetAddFreeMopupNum(human)
     if TequanShopLogic.isActiveMopup(human) then
         msgRet.leftCnt = BATTLE_MOPUP_CNT_VIP - human.db.mopupDoCnt
     else
         msgRet.leftCnt = BATTLE_MOPUP_CNT - human.db.mopupDoCnt
     end
+
+    -- 剩余次数小于0则为0,再加额外的
+    msgRet.leftCnt = msgRet.leftCnt < 0 and 0 or msgRet.leftCnt
+
+    -- 增加额外次数
+    msgRet.leftCnt = msgRet.leftCnt + nNowAddFreeCnt
     
     -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
     local mupopExcel = tBattleConfig.mupop[nextDoCnt]
@@ -2667,6 +2707,12 @@ function mopupQuery(human)
     else
         msgRet.need = 0
     end
+
+    -- 如果有额外增加次数则需要为0
+    if 0 < nNowAddFreeCnt then
+        msgRet.need = 0
+    end
+
     msgRet.vip = TequanShopLogic.isActiveMopup(human) and 1 or 0
     msgRet.nowCnt = human.db.mopupDoCnt
     msgRet.exp = nodeConfig.hangExp
@@ -2692,27 +2738,34 @@ function mopupFight(human)
     human.db.mopupDoCnt = human.db.mopupDoCnt or 0
     human.db.mopupFreeCnt = human.db.mopupFreeCnt or 0
     local nextDoCnt = human.db.mopupDoCnt + 1
+    nextDoCnt = nextDoCnt >= EliteDefine.BATTLE_MOPUP_MAX_LEN and EliteDefine.BATTLE_MOPUP_MAX_LEN or nextDoCnt
     -- local mupopExcel = BattleExcel.mupop[nextDoCnt]
     local mupopExcel = tBattleConfig.mupop[nextDoCnt]
+    local nNowAddFreeCnt = BattleLogic_GetAddFreeMopupNum(human)
+
     if not mupopExcel then
         return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
     end
+
+    local bUseFree = false
     if not TequanShopLogic.isActiveMopup(human) then
-        if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT then
+        if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT and 0 >= nNowAddFreeCnt then
             return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
         end
         need = mupopExcel.cost
         -- 如果免费次数小于1次,则按免费算
         if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT then
+            bUseFree = true
             need = 0
         end
     else
-        if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP then
+        if human.db.mopupDoCnt >= BATTLE_MOPUP_CNT_VIP and 0 >= nNowAddFreeCnt then
             return Broadcast.sendErr(human, Lang.BATTLE_MOPUP_CNT_OVER)
         end
         need = mupopExcel.vipCost
         -- 如果免费次数小于3次,则按免费算
         if human.db.mopupFreeCnt < BATTLE_MOPUP_FREE_CNT_VIP then
+            bUseFree = true
             need = 0
         end
     end
@@ -2721,13 +2774,20 @@ function mopupFight(human)
         return
     end
 
-    if need <= 0 then
+    local bUseAddFree = false
+    if need <= 0 and bUseFree == true then
         human.db.mopupFreeCnt = human.db.mopupFreeCnt + 1
+    else
+        if nNowAddFreeCnt > 0 then
+            need = 0
+            BattleLogic_SetAddFreeMopupNum(human, -1)
+            bUseAddFree = true
+        end
     end
 
     ObjHuman.decZuanshi(human, - need, "battleMopup")
 
-    human.db.mopupDoCnt = human.db.mopupDoCnt + 1
+    human.db.mopupDoCnt = bUseAddFree == true and human.db.mopupDoCnt or human.db.mopupDoCnt + 1
 
     -- local guajiID = human.db.guajiID > #BattleExcel.node and #BattleExcel.node or human.db.guajiID
     local guajiID = nNowGuaJiID > #tBattleConfig.node and #tBattleConfig.node or nNowGuaJiID
@@ -2810,6 +2870,7 @@ end
 function updateDaily(human)
     human.db.mopupFreeCnt = 0
     human.db.mopupDoCnt = 0
+    human.db.mopupAddFreeCnt = 0
 end
 
 function getTongGuanReward(human, id)
@@ -3592,4 +3653,32 @@ function BattleLogic_IsLastLevels(human, nBattleType)
 
     local nValue = BattleLogic_GetBattleAdopt(human, nBattleType)
     return nValue == 1
+end
+
+-- 增加扫荡次数
+function BattleLogic_AddMopup(human, nGoodsID, nGoodsNum)
+    if not human or 0 >= nGoodsID or 0 >= nGoodsNum then
+        return
+    end
+
+    if EliteDefine.BATTLE_ADD_MOPUP_GOODID ~= nGoodsID then
+        return
+    end
+
+    -- 检测数量
+    if false == BagLogic.checkItemCnt(human, nGoodsID, nGoodsNum) then
+        return
+    end
+
+    -- 消耗物品
+    BagLogic.delItem(human, nGoodsID, nGoodsNum, "battle")
+
+    -- 增加次数
+    BattleLogic_SetAddFreeMopupNum(human, nGoodsNum)
+
+    Log.write(Log.LOGID_OSS_BATTLE_MAINGATE, "[BattleLogic_AddMopup] 增加扫荡次数 name = "
+                ..human.db.name.." nAddNum ="..nGoodsNum)
+
+    print("[BattleLogic_AddMopup] 玩家增加扫荡次数 name = "
+            ..human.db.name.." nAddNum ="..nGoodsNum)
 end

+ 5 - 0
script/module/battle/EliteDefine.lua

@@ -19,3 +19,8 @@ COPY_SELECT_SUCC = 0
 COPY_SELECT_LEV = 1
 --未完成通过主线第80关
 COPY_SELECT_MAIN = 2
+
+-- 增加扫荡次数道具
+BATTLE_ADD_MOPUP_GOODID = 1012
+-- 最大扫荡配置
+BATTLE_MOPUP_MAX_LEN = 12

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

@@ -279,6 +279,7 @@ function createDefaultRole(account)
 
         mopupDoCnt = nil,                       -- 战役已扫荡次数
         mopupFreeCnt = nil,                     -- 战役已免费扫荡次数
+		mopupAddFreeCnt = nil,					-- 战役额外增加扫荡次数
 		topupAcount = nil,                      -- 玩家充值总额
 		topupAcountDaily = nil,					-- 玩家每日充值总额
 		topupAccountMonth = nil,				-- 玩家每月充值总额