From c3bbd3b0263fc6c2127cd9f072f497f46f98758b Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期六, 07 二月 2026 21:43:20 +0800
Subject: [PATCH] 389 流向记录(简化战斗流向记录,只统计出场的武将ID;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py |  208 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 144 insertions(+), 64 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 c906af0..fb0f5cf 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -29,7 +29,6 @@
 import GameWorld
 import PlayerLLMJ
 import PlayerPrestigeSys
-import CrossServerPackLogic
 import DataRecordPack
 import PlayerSuccess
 import IpyGameDataPY
@@ -45,6 +44,7 @@
 import TurnBuff
 import FBCommon
 import CommFunc
+import CrossMsg
 import FBLogic
 
 import random
@@ -79,10 +79,11 @@
         self.lineupInfo = {} # 传入初始化的阵容信息
         self.shapeType = 0 # 阵型
         self.fightPower = 0 # 阵容总战力
-        self.posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...}, 站位编号小于0为非主战单位,如主公、红颜等
-        self.heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
-        self.lingshouObjIDDict = {} # 灵兽战斗单位 {位置编号:batObjID, ...}
-        self.beautyObjIDDict = {} # 红颜战斗单位 {位置编号:batObjID, ...}
+        
+        self._posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...},如主公、命格、灵兽等
+        self._heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
+        self._batHeroObjIDList = [] # 主战武将对象ID列表
+        self._minggeObjID = 0 # 命格对象ID
         self.actionNum = ActionNumStart # 行动位置,从1开始
         self.totalHurt = 0 # 阵容总输出
         
@@ -93,9 +94,9 @@
     
     def getReqPlayerID(self): return self.turnFight.getReqPlayerID() # 发起的玩家ID
     
-    def isEmpty(self): return not self.posObjIDDict
+    def isEmpty(self): return not self._batHeroObjIDList
     
-    def setLineup(self, lineupInfo):
+    def setLineupInfo(self, lineupInfo):
         ## 设置阵容
         # @param lineupInfo: 阵容信息
         self.clearLineup()
@@ -111,26 +112,55 @@
     def clearLineup(self):
         ## 清除阵容
         batObjMgr = BattleObj.GetBatObjMgr()
-        for objID in self.posObjIDDict.values():
-            batObjMgr.delBatObj(objID)
-        for objID in self.lingshouObjIDDict.values():
-            batObjMgr.delBatObj(objID)
-        for objID in self.beautyObjIDDict.values():
+        for objID in self._posObjIDDict.values():
             batObjMgr.delBatObj(objID)
         self.lineupInfo = {}
-        self.posObjIDDict = {}
-        self.heroObjIDDict = {}
-        self.lingshouObjIDDict = {}
-        self.beautyObjIDDict = {}
+        self._posObjIDDict = {}
+        self._heroObjIDDict = {}
+        self._batHeroObjIDList = []
+        self._minggeObjID = 0
         self.fightPower = 0
         self.totalHurt = 0
         return
+    
+    def addObj(self, batObj):
+        objID = batObj.GetID()
+        posNum = batObj.GetPosNum()
+        heroID = batObj.GetHeroID()
+        batObjType = batObj.GetBatObjType()
+        self._posObjIDDict[posNum] = objID
+        if heroID:
+            self._heroObjIDDict[heroID] = objID
+            
+        if batObjType == ChConfig.BatObjType_BatHero:
+            if objID not in self._batHeroObjIDList:
+                self._batHeroObjIDList.append(objID)
+        elif batObjType == ChConfig.BatObjType_Mingge:
+            self._minggeObjID = objID
+        elif batObjType == ChConfig.BatObjType_Lingshou:
+            pass
+        return
+    
+    def getPosObjIDDict(self): return self._posObjIDDict
+    def getAllPosObjIDList(self): return self._posObjIDDict.values()
+    
+    def getBatHeroObjIDList(self): return self._batHeroObjIDList ## 获取主战武将对象ID列表
+    
+    def getHeroObj(self, heroID):
+        if heroID not in self._heroObjIDDict:
+            return
+        return BattleObj.GetBatObjMgr().getBatObj(self._heroObjIDDict[heroID])
+    
+    def getMinggeObj(self):
+        if not self._minggeObjID:
+            return
+        return BattleObj.GetBatObjMgr().getBatObj(self._minggeObjID)        
     
     def getDeadObjCnt(self):
         ## 获取本阵容目前死亡队员数
         deadCnt = 0
         batObjMgr = BattleObj.GetBatObjMgr()
-        for objID in self.posObjIDDict.values():
+        for objID in self._batHeroObjIDList:
             batObj = batObjMgr.getBatObj(objID)
             if not batObj:
                 continue
@@ -138,11 +168,6 @@
                 continue
             deadCnt += 1
         return deadCnt
-    
-    def getHeroObj(self, heroID):
-        if heroID not in self.heroObjIDDict:
-            return
-        return BattleObj.GetBatObjMgr().getBatObj(self.heroObjIDDict[heroID])
     
 class BatFaction():
     ## 战斗阵营
@@ -291,24 +316,32 @@
             if not lineupInfo:
                 continue
             batLineup = batFaction.getBatlineup(num)
-            batLineup.setLineup(lineupInfo)
+            batLineup.setLineupInfo(lineupInfo)
         return
     
     def sortActionQueue(self):
         ## 刷新出手顺序队列
+        batObjMgr = BattleObj.GetBatObjMgr()
         sortList = []
         for batFaction in self.factionDict.values():
             faction = batFaction.faction
             for num, batLineup in batFaction.lineupDict.items():
                 isPlayer = 1 if batLineup.ownerID else 0 # 玩家阵容优先攻击
+                atkSpeed = 0
+                for objID in batLineup.getBatHeroObjIDList():
+                    batObj = batObjMgr.getBatObj(objID)
+                    if not batObj:
+                        continue
+                    atkSpeed += batObj.GetBatAttrValue(ChConfig.AttrID_AtkSpeed)
                 fightPower = batLineup.fightPower
                 sortValue = -(faction * 10 + num)
-                sortList.append([isPlayer, fightPower, sortValue, faction, num])
+                sortList.append([isPlayer, atkSpeed, fightPower, sortValue, faction, num])
         sortList.sort(reverse=True) # 战力高的先手
         
         self.actionIndex = 0
         self.actionSortList = []
-        for _, _, _, faction, num in sortList:
+        for sortInfo in sortList:
+            faction, num = sortInfo[-2:]
             self.actionSortList.append([faction, num])
             
         GameWorld.DebugLogEx("阵容战力排序[isPlayer, fp, sortV, f, n]: %s", sortList)
@@ -338,10 +371,7 @@
             for batLineup in batFaction.lineupDict.values():
                 if not allKilled:
                     break
-                for posNum, objID in batLineup.posObjIDDict.items():
-                    if posNum <= 0:
-                        # 非主战位置不判断
-                        continue
+                for objID in batLineup.getBatHeroObjIDList():
                     batObj = batObjMgr.getBatObj(objID)
                     if not batObj:
                         continue
@@ -402,10 +432,12 @@
                 tfLineup.OwnerID = batLineup.ownerID
                 tfLineup.ShapeType = batLineup.shapeType
                 tfLineup.ObjList = []
-                for posNum, objID in batLineup.posObjIDDict.items():
+                for posNum, objID in batLineup.getPosObjIDDict().items():
                     batObj = batObjMgr.getBatObj(objID)
                     if not batObj:
                         continue
+                    #if posNum == ChConfig.TFPosNum_Mingge: # 理论上要都同步,但是前端需要同步修改,等前端要改时再同步
+                    #    continue
                     tfObj = ChPyNetSendPack.tagSCTurnFightObj()
                     tfObj.ObjID = batObj.GetID()
                     tfObj.NPCID = batObj.GetNPCID()
@@ -617,6 +649,7 @@
     lineup = GetPlayerLineupByID(curPlayer, batPresetID, exclusiveMapID)
     if lineup.IsEmpty():
         return {}
+    batPresetID = lineup.batPresetID
     
     heroDict = {}
     curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptHero)
@@ -654,8 +687,18 @@
     if not heroDict:
         return {}
     
+    mgPresetID = PlayerPreset.GetFuncPresetID(curPlayer, batPresetID, ShareDefine.FuncPreset_Mingge)
+    olPlayer = PlayerOnline.GetOnlineMgr().GetOnlinePlayer(curPlayer)
+    mgSkillLVDict = olPlayer.GetCalcSpecInfo(ChConfig.Def_CalcAttr_Mingge, mgPresetID)
+    mgSkillIDList = []
+    for skillTypeID, skillLV in mgSkillLVDict.items():
+        skillID = SkillCommon.GetSkillIDBySkillTypeID(skillTypeID, skillLV)
+        if skillID not in mgSkillIDList:
+            mgSkillIDList.append(skillID)
     #shapeType = 0
     lineupInfo = {"PlayerID":playerID, "FightPower":lineup.fightPower, "BatPresetID":batPresetID, "Hero":heroDict}
+    if mgSkillIDList:
+        lineupInfo["MGSkillIDList"] = mgSkillIDList
     return lineupInfo
 
 def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0, isLog=True, viewNPCID=0):
@@ -812,7 +855,16 @@
     reModelID = lineupIpyData.GetReModelID()
     lvReIpyData = None
     heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
-    npcStronger = IpyGameDataPY.GetIpyGameDataNotLog("NPCStronger", npcID)
+    npcStronger = None
+    npcStrongerList = IpyGameDataPY.GetIpyGameDataListNotLog("NPCStronger", npcID)
+    if npcStrongerList and strongerLV:
+        for strongerData in npcStrongerList:
+            if not strongerData.GetNPCLV() or strongerLV <= strongerData.GetNPCLV():
+                npcStronger = strongerData
+                break
+        if not npcStronger:
+            npcStronger = npcStrongerList[-1] # 找不到时取最后一条
+            
     if npcStronger and strongerLV:
         lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, strongerLV)
         if lvReIpyData:
@@ -940,12 +992,33 @@
     lineupPlayerID = lineupInfo.get("PlayerID", 0) # 阵容所属玩家ID
     npcLineupID = lineupInfo.get("NPCLineupID", 0)
     GameWorld.DebugLogEx("SummonLineupObjs faction:%s,num:%s,npcLineupID=%s,lineupPlayerID=%s", faction, num, npcLineupID, lineupPlayerID)
+    mgSkillIDList = lineupInfo.get("MGSkillIDList", [])
     
     turnFight = batLineup.turnFight
     tfGUID = turnFight.guid
     heroDict = lineupInfo.get("Hero", {})
     
     batObjMgr = BattleObj.GetBatObjMgr()
+    
+    # 命格
+    #mgSkillIDList = [9000014] # 测试用
+    if mgSkillIDList:
+        minggeObj = batObjMgr.addBatObj()
+        if minggeObj:
+            minggeObj.SetOwnerID(lineupPlayerID)
+            minggeObj.SetTFGUID(tfGUID)
+            minggeObj.SetFaction(faction)
+            minggeObj.SetLineupPos(ChConfig.TFPosNum_Mingge, num)
+            skillManager = minggeObj.GetSkillManager()
+            skillManager.SkillReset()
+            for skillID in mgSkillIDList:
+                skillManager.LearnSkillByID(skillID)
+            batLineup.addObj(minggeObj)
+            GameWorld.DebugLogEx("AddBatObj 命格: faction:%s,num:%s,objID=%s,skillIDList=%s", faction, num, minggeObj.GetID(), skillManager.GetSkillIDList())
+            ResetObjSkill(minggeObj)
+            minggeObj.InitBatAttr({ChConfig.AttrID_MaxHP:1})
+            
+    # 武将
     initXP = IpyGameDataPY.GetFuncCfg("AngerXP", 1)
     for posNumKey, heroInfo in heroDict.items():
         posNum = int(posNumKey)
@@ -985,7 +1058,7 @@
         batObj = batObjMgr.addBatObj()
         if not batObj:
             break
-        objID = batObj.GetID()
+        #objID = batObj.GetID()
         if npcID:
             batObj.SetNPCID(npcID)
         elif lineupPlayerID:
@@ -1009,8 +1082,7 @@
         for skillID in skillIDList:
             skillManager.LearnSkillByID(skillID)
             
-        batLineup.posObjIDDict[posNum] = objID
-        batLineup.heroObjIDDict[heroID] = objID
+        batLineup.addObj(batObj)
         GameWorld.DebugLogEx("AddBatObj %s,lv=%s,star=%s,skill=%s", GetObjName(batObj), lv, star, skillManager.GetSkillIDList())
         ResetObjSkill(batObj)
         
@@ -1034,7 +1106,7 @@
     GameWorld.DebugLogEx("切换小队重置玩家阵容武将...")
     batLineup = batFaction.getBatlineup(1) # 只处理玩家阵容
     batObjMgr = BattleObj.GetBatObjMgr()
-    for objID in batLineup.posObjIDDict.values():
+    for objID in batLineup.getAllPosObjIDList():
         batObj = batObjMgr.getBatObj(objID)
         if not batObj:
             continue
@@ -1216,17 +1288,17 @@
             isMultiMap = True
             
     if isMultiMap:
-        CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
+        CrossMsg.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
     else:
-        SSMsg_BattleRequest(reqInfo, fromServerID)
+        S2B_BattleRequest(reqInfo, fromServerID)
     return
 
-def SSMsg_BattleRequest(reqInfo, fromServerID, msgType=""):
+def S2B_BattleRequest(reqInfo, fromServerID, msgType=""):
     ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
     guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
-    if msgType:
-        GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" 
-                      % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
+    #if msgType:
+    #    GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" 
+    #                  % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
         
     if npcLineupIDList:
         turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
@@ -1245,20 +1317,20 @@
     
     # 本地图自己处理的
     if fromServerID == GameWorld.GetGameWorld().GetServerID():
-        SSMsg_BattleResult(retInfo, fromServerID)
+        B2S_BattleResult(retInfo, fromServerID)
         
     # 其他服务器地图请求的,发送战斗结果回去
     else:
-        CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
+        CrossMsg.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
     return
 
-def SSMsg_BattleResult(retInfo, fromServerID, msgType=""):
+def B2S_BattleResult(retInfo, fromServerID, msgType=""):
     ## 收到战斗结果信息
     
     guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
-    if msgType:
-        GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" 
-                      % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
+    #if msgType:
+    #    GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" 
+    #                  % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
         
     curPlayer = None
     if reqPlayerID:
@@ -1574,7 +1646,6 @@
                 turnFight.syncState(FightState_Fighting)
             TurnFightPerTurnBigStart(turnFight, turnNum)
             
-        # 红颜
         # 灵兽
         
         if turnFight.winFaction:
@@ -1588,14 +1659,15 @@
             faction, num = turnFight.actionSortList[turnFight.actionIndex]
             batFaction = turnFight.getBatFaction(faction)
             batLineup = batFaction.getBatlineup(num)
+            posObjIDDict = batLineup.getPosObjIDDict()
             for posNum in range(batLineup.actionNum, PosNumMax + 1):
                 #GameWorld.DebugLogEx("武将位置: faction=%s,posNum=%s", faction, posNum)
-                if posNum not in batLineup.posObjIDDict:
+                if posNum not in posObjIDDict:
                     batLineup.actionNum = posNum + 1
                     #GameWorld.DebugLogEx("没有武将: faction=%s,posNum=%s", faction, posNum)
                     continue
                 
-                objID = batLineup.posObjIDDict[posNum]
+                objID = posObjIDDict[posNum]
                 batObj = batObjMgr.getBatObj(objID)
                 
                 # 玩家自己阵营,预判可否行动
@@ -1662,11 +1734,12 @@
             faction, num = turnFight.actionSortList[turnFight.actionIndex]
             batFaction = turnFight.getBatFaction(faction)
             batLineup = batFaction.getBatlineup(num)
+            posObjIDDict = batLineup.getPosObjIDDict()
             for posNum in range(batLineup.actionNum, PosNumMax + 1):
                 batLineup.actionNum = posNum + 1
-                if posNum not in batLineup.posObjIDDict:
+                if posNum not in posObjIDDict:
                     continue
-                objID = batLineup.posObjIDDict[posNum]
+                objID = posObjIDDict[posNum]
                 batObj = batObjMgr.getBatObj(objID)
                 TurnFightHeroTurnStart(turnFight, batObj, turnNum)
                 isAction = OnObjAction(turnFight, batObj)
@@ -1714,7 +1787,7 @@
         batFaction = turnFight.getBatFaction(faction)
         batLineup = batFaction.getBatlineup(num)
         batLineup.actionNum = ActionNumStart
-        for objID in batLineup.posObjIDDict.values():
+        for objID in batLineup.getAllPosObjIDList():
             batObj = batObjMgr.getBatObj(objID)
             turnFight.ResetOneActionUseSkillCnt()
             TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_FightStart)
@@ -1732,7 +1805,7 @@
         batFaction = turnFight.getBatFaction(faction)
         batLineup = batFaction.getBatlineup(num)
         batLineup.actionNum = 1
-        for objID in batLineup.posObjIDDict.values():
+        for objID in batLineup.getAllPosObjIDList():
             batObj = batObjMgr.getBatObj(objID)
             if not batObj:
                 continue
@@ -1759,7 +1832,7 @@
         GameWorld.DebugLogEx("回合结束逻辑: turnNum=%s,faction=%s, num=%s", turnNum, faction, num)
         batFaction = turnFight.getBatFaction(faction)
         batLineup = batFaction.getBatlineup(num)
-        for objID in batLineup.posObjIDDict.values():
+        for objID in batLineup.getAllPosObjIDList():
             batObj = batObjMgr.getBatObj(objID)
             if not batObj:
                 continue
@@ -2052,7 +2125,7 @@
         batFaction = turnFight.getBatFaction(faction)
         for lineupNum in batFaction.lineupDict.keys():
             batLineup = batFaction.getBatlineup(lineupNum)
-            for lineupObjID in batLineup.posObjIDDict.values():
+            for lineupObjID in batLineup.getBatHeroObjIDList():
                 lineupObj = batObjMgr.getBatObj(lineupObjID)
                 if not lineupObj.IsAlive():
                     continue
@@ -2133,29 +2206,33 @@
     heroCount = 0
     batObjMgr = BattleObj.GetBatObjMgr()
     statInfo = {}
-    drLineupInfo = {}
+    drHeroIDDict = {}
     for faction in turnFight.factionDict.keys():
         if str(faction) not in statInfo:
             statInfo[str(faction)] = {}
         facStatInfo = statInfo[str(faction)]
-        if str(faction) not in drLineupInfo:
-            drLineupInfo[str(faction)] = {}
-        facDRLineupInfo = drLineupInfo[str(faction)]
+        if str(faction) not in drHeroIDDict:
+            drHeroIDDict[str(faction)] = {}
+        facDRHeroIDDict = drHeroIDDict[str(faction)]
         batFaction = turnFight.getBatFaction(faction)
         batFaction.totalHurt = 0
         for num in batFaction.lineupDict.keys():
             if str(num) not in facStatInfo:
                 facStatInfo[str(num)] = {}
             lineupStatInfo = facStatInfo[str(num)]
+            if str(num) not in facDRHeroIDDict:
+                facDRHeroIDDict[str(num)] = {}
+            posHeroIDDict = facDRHeroIDDict[str(num)]
             batLineup = batFaction.getBatlineup(num)
             batLineup.totalHurt = 0
-            facDRLineupInfo[str(num)] = batLineup.lineupInfo
             GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
-            for posNum, objID in batLineup.posObjIDDict.items():
+            for posNum, objID in batLineup.getPosObjIDDict().items():
+                if posNum == ChConfig.TFPosNum_Mingge:
+                    #命格不统计
+                    continue
                 batObj = batObjMgr.getBatObj(objID)
                 if not batObj:
                     continue
-                heroCount += 1
                 objID = batObj.GetID()
                 npcID = batObj.GetNPCID()
                 heroID = batObj.GetHeroID()
@@ -2165,6 +2242,9 @@
                 batLineup.totalHurt += atkHurt
                 batFaction.totalHurt += atkHurt
                 dead = 0 if batObj.IsAlive() else 1
+                if heroID:
+                    heroCount += 1
+                    posHeroIDDict[str(posNum)] = heroID
                 GameWorld.DebugLogEx("    Pos:%s ID=%s,npcID=%s,heroID=%s,HP=%s/%s, 输出=%s,承伤=%s,治疗=%s", 
                                      posNum, objID, npcID, heroID, batObj.GetHP(), batObj.GetMaxHP(), atkHurt, defHurt, cureHP)
                 lineupStatInfo[str(posNum)] = {"ObjID":objID, "HeroID":heroID, "NPCID":npcID, "AtkHurt":atkHurt, "DefHurt":defHurt, "CureHP":cureHP, 
@@ -2179,7 +2259,7 @@
     # 流向记录
     if mapID != ChConfig.Def_FBMapID_Main and reqPlayerID:
         DataRecordPack.DR_FightStat(reqPlayerID, mapID, funcLineID, turnFight.isWin, turnFight.turnNum, turnFight.turnMax, 
-                                    heroCount, turnFight.costTime, statInfo, drLineupInfo, guid)
+                                    heroCount, turnFight.costTime, drHeroIDDict, guid)
     return
 
 #// B4 14 查看战报 #tagCSTurnFightReportView

--
Gitblit v1.8.0