From 9a635fc2a0a0dda52836b7e71f7184b3226517c7 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 18 九月 2025 16:40:52 +0800
Subject: [PATCH] 121 【武将】武将系统-服务端(武将属性计算不取整,精确3位小数;战斗时属性使用原值小数计算,仅血量、怒气取整;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py
index c2e9bc6..433c306 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py
@@ -726,9 +726,10 @@
         self._initAttrDict = initAttrDict
         self._batAttrDict = {}
         self._batAttrDict.update(initAttrDict)
+        self.__onUpdBatAttr()
         self._skillTempAttrDict = {}
-        self._xp = initXP
-        self._hp = initAttrDict.get(ChConfig.AttrID_MaxHP, 1)
+        self.SetXP(initXP, False)
+        self.SetHPFull(False)
         TurnBuff.RefreshBuffAttr(self)
         TurnPassive.RefreshPassive(self)
         return
@@ -752,6 +753,7 @@
     def ResetBattleEffect(self):
         self._batAttrDict = {}
         self._batAttrDict.update(self._initAttrDict)
+        self.__onUpdBatAttr()
         return self._batAttrDict
     
     def GetTFGUID(self): return self.tfGUID # 所属的某场战斗
@@ -856,14 +858,16 @@
     def SetDead(self):
         self._isAlive = False
         self._hp = 0
-    def GetMaxHP(self): return self._batAttrDict.get(ChConfig.AttrID_MaxHP, 0)
+    def GetMaxHP(self): return int(self._batAttrDict.get(ChConfig.AttrID_MaxHP, 0))
     def SetMaxHP(self, maxHP, isNotify=False):
+        maxHP = int(maxHP)
         self._batAttrDict[ChConfig.AttrID_MaxHP] = maxHP
         if isNotify:
             NotifyObjInfoRefresh(self, ChConfig.AttrID_MaxHP, maxHP)
         return
     def GetHP(self): return self._hp
     def SetHP(self, hp, isNotify=False):
+        hp = int(hp)
         self._hp = hp
         if isNotify:
             NotifyObjInfoRefresh(self, ChConfig.AttrID_HP, hp)
@@ -871,6 +875,7 @@
     def SetHPFull(self, isNotify=True): self.SetHP(self.GetMaxHP(), isNotify)
     def GetXP(self): return self._xp
     def SetXP(self, xp, isNotify=True):
+        xp = int(xp)
         self._xp = xp
         if isNotify:
             NotifyObjInfoRefresh(self, ChConfig.AttrID_XP, xp)
@@ -886,7 +891,14 @@
             value += self._skillTempAttrDict[attrID] # 支持正负值
             #value = max(1, value)
         return value
-    def SetBatAttrValue(self, attrID, value): self._batAttrDict[attrID] = value
+    def SetBatAttrValue(self, attrID, value):
+        self._batAttrDict[attrID] = value
+        self.__onUpdBatAttr()
+        return
+    def __onUpdBatAttr(self):
+        for attrID in [ChConfig.AttrID_MaxHP]:
+            self._batAttrDict[attrID] = int(self._batAttrDict.get(attrID, 0))
+        return
     def AddSkillTempAttr(self, attrID, value):
         ## 增加技能临时属性,支持正负值
         # @param value: 正值-加属性;负值-减属性

--
Gitblit v1.8.0