From 9d3eb54f791b846ef03ff4e3a9e96dde2bb2b88f Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 10 一月 2025 19:17:14 +0800
Subject: [PATCH] 10263 【越南】【英文】后端支持NPC仿真实玩家战斗和快速战斗(修复战力不变时可能导致打包数据拉取失败bug;)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyEmblem.py | 93 ++++++++++++++++------------------------------
1 files changed, 33 insertions(+), 60 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyEmblem.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyEmblem.py
index 50df712..87b8a0a 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyEmblem.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyEmblem.py
@@ -26,8 +26,8 @@
def GetActionEmblemID(emblemActionObj): return emblemActionObj.GetValue1()
def SetActionEmblemID(emblemActionObj, emblemID): return emblemActionObj.SetValue1(emblemID)
-def GetActionEmblemExpireTimes(emblemActionObj): return emblemActionObj.GetValue2()
-def SetActionEmblemExpireTimes(emblemActionObj, endTime): return emblemActionObj.SetValue2(endTime)
+def GetActionEmblemEndTime(emblemActionObj): return emblemActionObj.GetValue2()
+def SetActionEmblemEndTime(emblemActionObj, endTime): return emblemActionObj.SetValue2(endTime)
def GetDefaultFamilyEmblemIDList():
## 获取默认的仙盟徽章ID列表,即所有解锁等级为1的徽章ID
@@ -57,8 +57,8 @@
for index in range(familyAction.Count())[::-1]: # 可能触发删除,倒序遍历
emblemActionObj = familyAction.At(index)
emblemID = GetActionEmblemID(emblemActionObj)
- isExpired, endTime = IsEmblemExpired(emblemActionObj, curTime)
- if not isExpired:
+ endTime = GetActionEmblemEndTime(emblemActionObj)
+ if not endTime or endTime > curTime:
#GameWorld.Log("检查仙盟徽章未过期! familyID=%s,emblemID=%s,endTime=%s" % (familyID, emblemID, endTime))
continue
familyAction.DelAction(index)
@@ -71,40 +71,6 @@
PlayerFamily.SetFamilyEmblemID(family, updEmblemID)
family.Broadcast_FamilyChange()
return
-
-def IsEmblemExpired(emblemActionObj, curTime):
- ## 勋章是否过期
- # @return: 是否过期, endTime
-
- endTime = -1
- if not emblemActionObj:
- return True, endTime
-
- createTime = emblemActionObj.GetTime()
- expireTimes = GetEmblemExpireTimes(emblemActionObj)
- if expireTimes == 0:
- # 永久的
- return False, 0
-
- if expireTimes > 0:
- endTime = createTime + expireTimes
- if endTime >= curTime:
- # 未过期
- return False, endTime
-
- return True, endTime
-
-def GetEmblemExpireTimes(emblemActionObj):
- ## 获取勋章有效时长,秒
- # @return: 0-永久;-1-无效;>0-有效秒数
- expireTimes = GetActionEmblemExpireTimes(emblemActionObj) # 有效时长,秒
- if not expireTimes:
- emblemID = GetActionEmblemID(emblemActionObj)
- ipyData = IpyGameDataPY.GetIpyGameData("FamilyEmblem", emblemID)
- if not ipyData:
- return -1
- expireTimes = ipyData.GetExpireMinutes() * 60
- return expireTimes
def GetFamilyEmblemActionData(familyID, emblemID):
## 获取仙盟时效徽章Action数据
@@ -130,12 +96,7 @@
if unlockFamilyLV:
GameWorld.Log("仙盟解锁的徽章不需要添加! familyID=%s,emblemID=%s" % (familyID, emblemID))
return
- if setExpireTimes >= 0:
- expireTimes = setExpireTimes
- else:
- expireTimes = ipyData.GetExpireMinutes() * 60
- GameWorld.Log("添加仙盟徽章! familyID=%s,emblemID=%s,setExpireTimes=%s,expireTimes=%s"
- % (familyID, emblemID, setExpireTimes, expireTimes))
+ ipyExpireSeconds = ipyData.GetExpireMinutes() * 60
curTime = int(time.time())
emblemActionObj = GetFamilyEmblemActionData(familyID, emblemID)
@@ -146,22 +107,31 @@
emblemActionObj.SetTime(curTime)
emblemActionObj.SetFamilyId(familyID)
emblemActionObj.SetActionType(actionType)
+
+ if not emblemActionObj:
+ return
+ endTime = GetActionEmblemEndTime(emblemActionObj)
+ updEndTime = endTime
+
+ # 指定时长的,如GM指定
+ if setExpireTimes > 0:
+ updEndTime = curTime + setExpireTimes
+
+ # 永久
+ elif ipyExpireSeconds == 0 or setExpireTimes == 0:
+ updEndTime = 0
+
else:
- isExpired, endTime = IsEmblemExpired(emblemActionObj, curTime)
- if setExpireTimes >= 0:
- emblemActionObj.SetTime(curTime)
- GameWorld.Log("直接设置勋章剩余时长,重新设置获得时间! familyID=%s,emblemID=%s" % (familyID, emblemID))
- elif isExpired:
- emblemActionObj.SetTime(curTime)
- GameWorld.Log("获得勋章时已过期,重新设置获得时间! familyID=%s,emblemID=%s,endTime=%s" % (familyID, emblemID, endTime))
+ # 未过期
+ if endTime > curTime:
+ updEndTime = endTime + ipyExpireSeconds
else:
- # 未过期,非永久的直接累加时长
- if expireTimes > 0:
- expireTimes += GetActionEmblemExpireTimes(emblemActionObj)
- GameWorld.Log("获得勋章时未过期,累加有效时长! familyID=%s,emblemID=%s,expireTimes=%s" % (familyID, emblemID, expireTimes))
-
+ updEndTime = curTime + ipyExpireSeconds
+
+ GameWorld.Log("添加仙盟徽章! familyID=%s,emblemID=%s,setExpireTimes=%s,endTime=%s,updEndTime=%s"
+ % (familyID, emblemID, setExpireTimes, endTime, updEndTime))
SetActionEmblemID(emblemActionObj, emblemID)
- SetActionEmblemExpireTimes(emblemActionObj, expireTimes)
+ SetActionEmblemEndTime(emblemActionObj, updEndTime)
# 通知
PlayerFamilyAction.SendFamilyAction(emblemActionObj)
@@ -198,9 +168,12 @@
return
else:
emblemActionObj = GetFamilyEmblemActionData(familyID, emblemID)
- isExpired, endTime = IsEmblemExpired(emblemActionObj, int(time.time()))
- if isExpired:
- GameWorld.DebugLog("该徽章不存在或已过期! emblemID=%s,endTime=%s" % (emblemID, endTime), playerID)
+ if not emblemActionObj:
+ GameWorld.DebugLog("该徽章未激活! emblemID=%s" % (emblemID), playerID)
+ return
+ endTime = GetActionEmblemEndTime(emblemActionObj)
+ if endTime and endTime <= int(time.time()):
+ GameWorld.Log("该徽章已过期! familyID=%s,emblemID=%s,endTime=%s" % (familyID, emblemID, endTime))
return
GameWorld.DebugLog("更换仙盟徽章! familyID=%s,emblemID=%s" % (familyID, emblemID), playerID)
--
Gitblit v1.8.0