From 935c7a30007928b9830c41b026788e9f698b1b66 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 27 十月 2025 11:46:20 +0800
Subject: [PATCH] 129 【战斗】战斗系统-服务端(优化战斗请求CD:主线、副本独立CD,增加全服公共CD;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py |   34 +++++++++++++++++++++++++++++-----
 1 files changed, 29 insertions(+), 5 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 cf6faf1..786b64f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -459,6 +459,7 @@
     ## 回合战斗管理器
     
     def __init__(self):
+        self.lastRequestTick = 0
         self.turnFightDict = {} # {guid:TurnFight, ...}
         return
     
@@ -864,6 +865,30 @@
         
     return
 
+def CheckFightCD(curPlayer, tick, selfKey):
+    ## 是否战斗请求CD中
+    
+    # 所有玩家公共CD,待扩展
+    tfMgr = GetTurnFightMgr()
+    pubCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 1)
+    if pubCD:
+        if tfMgr.lastRequestTick and tick - tfMgr.lastRequestTick <= pubCD:
+            GameWorld.DebugLog("回合制战斗请求服务器公共CD中!")
+            PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
+            return True
+        
+    # 个人CD
+    selfCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 2)
+    lastTick = curPlayer.GetDictByKey(selfKey)
+    if selfCD and lastTick and tick - lastTick <= selfCD:
+        GameWorld.DebugLog("回合制战斗请求CD中: %s" % selfKey)
+        PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
+        return True
+    
+    tfMgr.lastRequestTick = tick
+    curPlayer.SetDict(selfKey, tick)
+    return False
+
 #// B4 10 回合制战斗 #tagCMTurnFight
 #
 #struct    tagCMTurnFight
@@ -906,6 +931,9 @@
     # 攻防方所使用的阵容ID
     atkLineupID, defLineupID = FBLogic.GetFBPlayerLineupID(curPlayer, mapID, funcLineID)
     if atkLineupID not in ShareDefine.LineupList or defLineupID not in ShareDefine.LineupList:
+        return
+    
+    if CheckFightCD(curPlayer, tick, "TurnFightReqTick"):
         return
     
     # 玩家
@@ -1154,12 +1182,8 @@
     
     # 限制请求CD
     if tick:
-        key = "MainFightReqTick"
-        lastTick = curPlayer.GetDictByKey(key)
-        if lastTick and tick - lastTick <= 1000:
-            GameWorld.DebugLog("主线战斗请求CD中")
+        if CheckFightCD(curPlayer, tick, "MainFightReqTick"):
             return
-        curPlayer.SetDict(key, tick)
         
     mainFightMgr = GetMainFightMgr(curPlayer)
     turnFight = mainFightMgr.turnFight

--
Gitblit v1.8.0