From ca212ad097edfe324b5b6035e64cfbcf5146b044 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 09 十二月 2025 10:50:22 +0800
Subject: [PATCH] 121 【武将】武将系统-服务端(突破单独配置所需武将等级,不需要满级才能突破;突破消耗物品改为支持多种物品;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py |   68 ++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
index 20d85f8..82998ef 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -29,6 +29,8 @@
 import GameWorld
 import PlayerLLMJ
 import PlayerPrestigeSys
+import CrossServerPackLogic
+import PlayerSuccess
 import IpyGameDataPY
 import PlayerOnline
 import NPCCommon
@@ -47,7 +49,6 @@
 import random
 import time
 import json
-import shutil
 import os
 
 g_gmTestFightReq = []
@@ -457,6 +458,7 @@
         if self._isNeedReport:
             packBuff = clientPack.GetBuffer()
             buffLen = len(packBuff)
+            #GameWorld.DebugLog("回合战斗过程封包: %s, len:%s, %s" % (headStr, buffLen, CommFunc.B2Hex(packBuff)))
             GameWorld.DebugLog("回合战斗过程封包: %s, len:%s" % (headStr, buffLen))
             self.batBuffer += CommFunc.WriteWORD("", buffLen)
             self.batBuffer += packBuff
@@ -1137,21 +1139,31 @@
         # pvp 或 pve 必须要满足其中一种
         return
     
-    # 先默认本地图处理,后续优化多战斗地图支持
-    
     reqServerID = GameWorld.GetGameWorld().GetServerID()
-    reqInfo = [reqServerID, guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData]
-    OnMsg_BattleRequest(reqInfo)
+    reqInfo = [guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData]
+    multiMapSet = IpyGameDataPY.GetFuncCfg("TurnFightProcess", 1)
+    # 多地图战斗 0-本地图处理;1-多地图处理;2-debug模式默认本地图处理,非debug默认多地图处理
+    isMultiMap = False
+    if multiMapSet == 1:
+        isMultiMap = True
+    elif multiMapSet == 2:
+        if not GameWorld.GetGameWorld().GetDebugLevel():
+            isMultiMap = True
+            
+    if isMultiMap:
+        CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
+    else:
+        SSMsg_BattleRequest(reqInfo, reqServerID)
     return
 
-def OnMsg_BattleRequest(reqInfo):
+def SSMsg_BattleRequest(reqInfo, fromServerID):
     ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
-    reqServerID, guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
+    guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
     
     if npcLineupIDList:
-        turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, reqServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
+        turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, fromServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
     else:
-        turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, reqServerID)
+        turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, fromServerID)
         
     winFaction = None
     statMsg = {}
@@ -1164,16 +1176,15 @@
     retInfo = [guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData]
     
     # 本地图自己处理的
-    if reqServerID == GameWorld.GetGameWorld().GetServerID():
-        OnMsg_BattleResult(retInfo)
+    if fromServerID == GameWorld.GetGameWorld().GetServerID():
+        SSMsg_BattleResult(retInfo, fromServerID)
         
     # 其他服务器地图请求的,发送战斗结果回去
     else:
-        pass
-    
+        CrossServerPackLogic.SendToServer(ShareDefine.SSMsg_BattleResult, retInfo, [fromServerID], playerID=reqPlayerID)
     return
 
-def OnMsg_BattleResult(retInfo):
+def SSMsg_BattleResult(retInfo, fromServerID):
     ## 收到战斗结果信息
     
     guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
@@ -1315,6 +1326,7 @@
         PlayerLLMJ.AddUseZhanchui(curPlayer, useZhanchui)
         PlayerPrestigeSys.AddRealmTaskValue(curPlayer, PlayerPrestigeSys.RealmTaskType_UseXiantao, useZhanchui)
         PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_CutTree, useZhanchui)
+        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_OSACutTree, useZhanchui)
         PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_CutTree, useZhanchui)
         
     # 历练秘境额外经验
@@ -1327,6 +1339,7 @@
     if killNPCCnt > 0:
         PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_KillNPC, killNPCCnt)
         PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_KillNPC, killNPCCnt)
+        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_OSAKillNPC, killNPCCnt)
         
     # 结算逻辑最后重置数据
     mainFightMgr.resetMainFightExDataRec()
@@ -1992,7 +2005,7 @@
     funcLineID = turnFight.funcLineID
     GameWorld.DebugLog("--- 战斗结束处理 ---, winFaction=%s, costTime=%ss, %s" % (winFaction, turnFight.costTime, guid))
     if mapID != ChConfig.Def_FBMapID_Main:
-        GameWorld.Log("战斗耗时: %ss, mapID=%s,funcLineID=%s" % (turnFight.costTime, mapID, funcLineID))
+        GameWorld.Log("战斗耗时: %ss, mapID=%s,funcLineID=%s,turnNum=%s/%s" % (turnFight.costTime, mapID, funcLineID, turnFight.turnNum, turnFight.turnMax))
         
     # 统计明细
     batObjMgr = BattleObj.GetBatObjMgr()
@@ -2075,21 +2088,28 @@
     ReportRoot = "C:\TurnFightReport"
     
     dateStr = GameWorld.ChangeTimeNumToStr(int(time.time()), "%Y%m%d") 
-    ReportDir = os.path.join(ReportRoot, "S%s" % reqServerID, dateStr, "%s" % reqPlayerID)
-    
-    GameWorld.DebugLog("ReportDir=%s" % ReportDir)
+    ReportDir = os.path.join(ReportRoot, "S%s" % reqServerID, dateStr, "%s" % reqPlayerID, "%s" % turnFight.mapID)
     if not os.path.exists(ReportDir):
         os.makedirs(ReportDir)
     else:
-        shutil.rmtree(ReportDir)
-        os.makedirs(ReportDir)
-        
+        items = os.listdir(ReportDir)
+        for item in items:
+            fullPath = os.path.join(ReportDir, item)
+            try:
+                os.remove(fullPath)
+            except:
+                pass
+            
     saveFilePath = os.path.join(ReportDir, "%s.tfr" % guid)
-    GameWorld.DebugLog("saveFilePath=%s" % saveFilePath)
+    GameWorld.DebugLog("__saveBatBuffer=%s" % saveFilePath)
     
     try:
-        fp = open(saveFilePath, "w")
-        fp.write(turnFight.batBuffer)
+        clientPack = ChPyNetSendPack.tagSCTurnFightReport()
+        clientPack.GUID = guid
+        clientPack.Report = turnFight.batBuffer
+        clientPack.Len = len(clientPack.Report)
+        fp = open(saveFilePath, "wb")
+        fp.write(clientPack.GetBuffer())
         fp.close()
     except:
         return

--
Gitblit v1.8.0