Parcourir la source

feat:6号单,战意回退

flowerpig il y a 5 mois
Parent
commit
4b63dfd53e
1 fichiers modifiés avec 29 ajouts et 29 suppressions
  1. 29 29
      script/module/fuwen/BattleWillLogic.lua

+ 29 - 29
script/module/fuwen/BattleWillLogic.lua

@@ -329,17 +329,13 @@ end
 
 -- 执行回退
 function rollback(human, heroID, heroIndex, index)
-    Log.write(Log.LOGID_DEBUG, "[rollback] 收到回退请求: heroID="..(heroID or "nil")..", heroIndex="..(heroIndex or "nil")..", index="..(index or "nil"))
-    
     local heroGrid = HeroLogic.getHeroGrid(human, heroID, heroIndex)
     if not heroGrid then
-        Log.write(Log.LOGID_DEBUG, "[rollback] 英雄不存在")
         return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
     end
     
     -- 检查index范围(1-BINGSHU_MAXCNT)
     if index and (index < 1 or index > BingshuLogic.BINGSHU_MAXCNT) then
-        Log.write(Log.LOGID_DEBUG, "[rollback] index超出范围: index="..(index or "nil")..", 有效范围: 1-"..BingshuLogic.BINGSHU_MAXCNT)
         return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
     end
     
@@ -351,14 +347,8 @@ function rollback(human, heroID, heroIndex, index)
     end
     
     if not grid then
-        if index then
-            Log.write(Log.LOGID_DEBUG, "[rollback] index="..index.."不是战意或为空,尝试查找战意所在位置")
-        else
-            Log.write(Log.LOGID_DEBUG, "[rollback] index为nil,尝试查找战意所在位置")
-        end
         battleWillIndex = findBattleWillIndex(heroGrid)
         if not battleWillIndex then
-            Log.write(Log.LOGID_DEBUG, "[rollback] 未找到战意技能")
             return Broadcast.sendErr(human, "当前战意格子为空,无法回退")
         end
         grid = heroGrid.bingshu[battleWillIndex]
@@ -368,23 +358,19 @@ function rollback(human, heroID, heroIndex, index)
     local currentSkillID = grid.skillID
     local currentSkillConfig = FuwenExcel.skill[currentSkillID]
     if not currentSkillConfig then
-        Log.write(Log.LOGID_DEBUG, "[rollback] 技能配置不存在: skillID="..currentSkillID)
         return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
     end
     
     -- 检查是否是战意技能
     if not isBattleWillSkill(currentSkillConfig) then
-        Log.write(Log.LOGID_DEBUG, "[rollback] 不是战意技能: skillID="..currentSkillID..", groupID="..(currentSkillConfig.groupID or "nil"))
         return Broadcast.sendErr(human, "当前格子不是战意技能,无法回退")
     end
     
     -- 从技能配置中获取等级(更可靠)
     local currentLevel = currentSkillConfig.lv or 0
-    Log.write(Log.LOGID_DEBUG, "[rollback] 当前战意等级: "..currentLevel..", index="..battleWillIndex..", skillID="..currentSkillID)
     
     -- 检查等级是否可回退
     if currentLevel == 0 or currentLevel < 1 or currentLevel > 4 then
-        Log.write(Log.LOGID_DEBUG, "[rollback] 当前等级不可回退: level="..currentLevel)
         return Broadcast.sendErr(human, "当前战意格子为空,无法回退")
     end
     
@@ -410,14 +396,12 @@ function rollback(human, heroID, heroIndex, index)
     end
     
     if not BagLogic.checkItemCnt(human, config.needItemID, config.needItemCnt) then
-        Log.write(Log.LOGID_DEBUG, "[rollback] 消耗道具不足: needItemID="..config.needItemID..", needItemCnt="..config.needItemCnt)
         return Broadcast.sendErr(human, Lang.COMMON_NO_ITEM)
     end
     
     -- 扣除消耗道具
-    BagLogic.delItem(human, config.needItemID, config.needItemCnt, "battleWill_rollback")
-    Log.write(Log.LOGID_DEBUG, "[rollback] 扣除消耗道具: needItemID="..config.needItemID..", needItemCnt="..config.needItemCnt)
-    
+    BagLogic.delItem(human, config.needItemID, config.needItemCnt, "bingshu")
+ 
     -- 收集返还物品(根据配置)
     local returnItemList = {}
     
@@ -438,11 +422,7 @@ function rollback(human, heroID, heroIndex, index)
     
     -- 发放返还物品(使用通用道具发放逻辑)
     if next(returnItemList) then
-        BagLogic.addItemList(human, returnItemList, "battleWill_rollback")
-        Log.write(Log.LOGID_DEBUG, "[rollback] 发放返还物品")
-        for itemID, cnt in pairs(returnItemList) do
-            Log.write(Log.LOGID_DEBUG, "[rollback]   返还道具: itemID="..itemID..", cnt="..cnt)
-        end
+        BagLogic.addItemList(human, returnItemList, "bingshu")
     end
     
     -- 更新战意等级为0(清空)- 删除bingshu中的战意技能
@@ -455,19 +435,39 @@ function rollback(human, heroID, heroIndex, index)
         if skillConfig and isBattleWillSkill(skillConfig) then
             -- 这是战意技能,删除它
             heroGrid.bingshu[battleWillIndex] = nil
-            Log.write(Log.LOGID_DEBUG, "[rollback] 删除战意技能: index="..battleWillIndex..", skillID="..bingshuGrid.skillID..", groupID="..(skillConfig.groupID or "nil"))
         else
             Log.write(Log.LOGID_DEBUG, "[rollback] WARNING: bingshu["..battleWillIndex.."]不是战意技能, skillID="..(bingshuGrid.skillID or "nil"))
         end
-    else
-        Log.write(Log.LOGID_DEBUG, "[rollback] bingshu["..battleWillIndex.."]不存在")
     end
     
-    Log.write(Log.LOGID_DEBUG, "[rollback] 回退完成: 等级从 "..currentLevel.." 变为 0")
-    
-    -- 重新计算英雄属性
     ObjHuman.doCalcHero(human, heroIndex)
     
     -- 发送英雄数据更新(如果需要)
     HeroLogic.sendHeroBagDynamic(human, heroID, heroIndex)
+    
+    -- 发送GC_BINGSHU_QUERY刷新所有兵书状态
+    BingshuLogic.sendQuery(human, heroID, heroIndex)
+    
+    -- 发送GC_BINGSHU_LEVELUP_QUERY刷新单个格子状态(格子已清空)
+    -- 由于格子已清空,需要构造一个表示空格子的消息
+    local msgRet = Msg.gc.GC_BINGSHU_LEVELUP_QUERY
+    msgRet.heroID = heroID
+    msgRet.heroIndex = heroIndex
+    
+    -- 构造空格子的bingshu数据(skillID=0表示空格子)
+    local emptyGrid = {skillID = 0}
+    BingshuGrid.makeBingshuNet(msgRet.bingshu, emptyGrid, battleWillIndex)
+    
+    -- 没有下一级数据
+    msgRet.upData[0] = 0
+    
+    -- 遗忘费用为0(因为格子已空)
+    msgRet.forgetCost = 0
+    
+    -- 没有返还物品(因为格子已空)
+    msgRet.returnItems[0] = 0
+    
+    if human.fd then
+        Msg.send(msgRet, human.fd)
+    end
 end