gitxsm 1 год назад
Родитель
Сommit
6e4fa30c8b
2 измененных файлов с 87 добавлено и 6 удалено
  1. 79 6
      script/module/battle/BattleLogic.lua
  2. 8 0
      script/module/chat/Gm.lua

+ 79 - 6
script/module/battle/BattleLogic.lua

@@ -433,6 +433,23 @@ local function getIndexByRand(totalWeight, randList)
 end
 
 
+--获得与当前ID同类型的最低级ID
+-- local function getLowestIDByType(attrId)
+--     local cfg = battleRougeCfg[attrId]
+--     if cfg.lv == 1 then
+--         return attrId
+--     end
+
+--     local tp = cfg.type
+--     for k,v in ipairs(battleRougeCfg) do
+--         if v.type == tp and v.lv == 1 then
+--             return k
+--         end
+--     end
+-- end
+
+
+
 --生成老号不同闯关模式的属性加成
 local function generateDiffBattleAttr(human, battleType)
     local config
@@ -457,17 +474,27 @@ local function generateDiffBattleAttr(human, battleType)
     end
 
     if times > 0 then
-        local attrList = {}
         local totalWeight, randList = generateCfgWeightInfo()
     
         if totalWeight <= 0 then
             return
         end
 
+        local type2Id = {}
+        local attrList = {}
+
         for i=1, times do
             local id = getIndexByRand(totalWeight, randList)
             local cfg = battleRougeCfg[id]
-            attrList[id] = (attrList[id] or 0) + cfg.lv
+
+            local targetId = type2Id[cfg.type]
+
+            if targetId then
+                attrList[targetId] = attrList[targetId] + cfg.lv
+            else
+                attrList[id] = cfg.lv
+                type2Id[cfg.type] = id
+            end
         end
 
         return attrList
@@ -4127,7 +4154,13 @@ local function sendNowBattleModeAllAttr(human, chosenAttrList)
     msgRet.attrInfo[0] = 0
     msgRet.isEnd = 0
 
+    local num = 0
     local itemCnt = 100
+    for _, _ in pairs(chosenAttrList) do
+        num = num + 1
+    end
+
+
     for id, nowLv in pairs(chosenAttrList) do
         len = len + 1
         local cfg = battleRougeCfg[id]
@@ -4143,6 +4176,12 @@ local function sendNowBattleModeAllAttr(human, chosenAttrList)
         if len >= max_len then
             msgRet.attrInfo[0] = len
             Grid.makeItem(msgRet.refreshCost, ItemDefine.ITEM_ZUANSHI_ID, itemCnt)
+
+            num = num - max_len
+            if num <= 0 then
+                msgRet.isEnd = 1
+            end
+
             Msg.send(msgRet, human.fd)
             len = 0
         end
@@ -4175,9 +4214,28 @@ function ChooseAttr(human, id)
         return Broadcast.sendErr(human, Lang.BATTLE_NO_ATTR)
     end
 
-    local lv = attrAddData.unSelectedAttrList[id]
     attrAddData.chosenAttrList = attrAddData.chosenAttrList or {}
-    attrAddData.chosenAttrList[id] = (attrAddData.chosenAttrList[id] or 0) + lv
+    local chosenAttrList = attrAddData.chosenAttrList
+
+
+    local targetId = 0
+    local targetType = battleRougeCfg[id].type
+    local lv = attrAddData.unSelectedAttrList[id]
+
+    for attrId in pairs(chosenAttrList) do
+        local cfg = battleRougeCfg[attrId]
+        if cfg.type == targetType then
+            targetId = attrId
+            break
+        end
+    end
+
+    if targetId ~= 0 then
+        chosenAttrList[targetId] = chosenAttrList[targetId] + lv
+    else
+        chosenAttrList[id] = lv
+    end
+
     attrAddData.unSelectedAttrList = nil
 
     sendNowBattleModeAllAttr(human, attrAddData.chosenAttrList)
@@ -4185,8 +4243,6 @@ function ChooseAttr(human, id)
     QueryDiffBattleUnSelectAttr(human)
 end
 
-
-
 --刷新属性
 function RefreshAttr(human, type_m, targetId)
     local nBattleType = BattleLogic_GetBattleType(human)
@@ -4265,3 +4321,20 @@ function RefreshAttr(human, type_m, targetId)
 
     end
 end
+
+--GM, 清理当前闯关模式的加成属性数据
+function GM_ClearNowModelAttrData(human)
+    -- local battleType = BattleLogic_GetBattleType(human)
+
+    -- if EliteDefine.COPY_ELITE_NORMAL == battleType then
+    --     human.db.normalBattleAttrData = nil
+    -- elseif EliteDefine.COPY_LEVEL_ELITE == battleType then
+    --     human.db.eliteBattleAttrData = nil
+    -- elseif EliteDefine.COPY_ELITE_DIFFICULTY == battleType then
+    --     human.db.hardBattleAttrData = nil
+    -- end
+
+    human.db.normalBattleAttrData = nil
+    human.db.eliteBattleAttrData = nil
+    human.db.hardBattleAttrData = nil
+end

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

@@ -578,6 +578,14 @@ function d3.setbattle(human,val)
 	BattleLogic.setBattleByGm(human, param[1], param[2])
 end
 
+
+function d3.clattr(human)
+	local BattleLogic = require("battle.BattleLogic")
+	BattleLogic.GM_ClearNowModelAttrData(human)
+end
+
+
+
 function d3.overmonth(human, val)
 	val = math.max(tonumber(val) or 0, 10)
 	human.db.actMonthEndTime = os.time() + val