From f05e181ee1f27a3a60c449477acfc6e83d83f5e9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 15 十二月 2025 19:27:13 +0800
Subject: [PATCH] 121 【武将】武将系统-服务端(优化广播支持按产出格子配置不同的广播;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
index 3b1065d..0178843 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
@@ -160,7 +160,6 @@
GameWorld.DebugLog("加载机器人缓存: %s" % playerID)
curCache = viewCacheMgr.AddPlayerViewCache(playerID)
curCache = UpdRobotViewCache(curCache, playerID)
- curCache.SetPlayerName("%s%s" % (GameWorld.GbkToCode("主公"), playerID))
# 假玩家,默认添加
elif ShareDefine.FackPlayerIDStart <= playerID <= ShareDefine.FackPlayerIDMax:
@@ -353,9 +352,41 @@
}
return robotDict
-def UpdRobotViewCache(curCache, robotID):
+def LoadRobot():
+ ## 加载机器人缓存,在服务器启动、重读配置时加载
+ robotFPSortList = []
+ viewCacheMgr = DBDataMgr.GetPlayerViewCacheMgr()
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for index in range(ipyDataMgr.GetRobotCount()):
+ ipyData = ipyDataMgr.GetRobotByIndex(index)
+ robotPlayerID = ipyData.GetID()
+ curCache = viewCacheMgr.GetPlayerViewCache(robotPlayerID)
+ if not curCache:
+ curCache = viewCacheMgr.AddPlayerViewCache(robotPlayerID)
+ if not curCache:
+ continue
+ UpdRobotViewCache(curCache, robotPlayerID, ipyData)
+ robotFPSortList.append([curCache.GetFightPowerTotal(), robotPlayerID])
+ robotFPSortList.sort(reverse=True) # 战力倒序排序
+ IpyGameDataPY.SetConfigEx("robotFPSortList", robotFPSortList)
+ GameWorld.Log("加载机器人战力排序: %s, %s" % (len(robotFPSortList), robotFPSortList))
+ return robotFPSortList
+
+def GetRobotFightPowerSortList():
+ ## 机器人战力倒序排序列表
+ # @return: 倒序排序列表 [[战力, 机器人ID], ...],外部使用可随机修改,不会打乱原始排序
+ sortList = []
+ robotFPSortList = IpyGameDataPY.GetConfigEx("robotFPSortList")
+ if not robotFPSortList:
+ robotFPSortList = LoadRobot()
+ if robotFPSortList:
+ sortList += robotFPSortList
+ return sortList
+
+def UpdRobotViewCache(curCache, robotID, robotIpyData=None):
## 更新机器人查看缓存
- robotIpyData = IpyGameDataPY.GetIpyGameData("Robot", robotID)
+ if not robotIpyData:
+ robotIpyData = IpyGameDataPY.GetIpyGameData("Robot", robotID)
if not robotIpyData:
return
try:
@@ -365,7 +396,7 @@
#curCache.SetAccID(dbPlayer.AccID)
- curCache.SetPlayerName(robotInfo.get("PlayerName", "p%s" % robotID))
+ curCache.SetPlayerName(GameWorld.GbkToCode(robotIpyData.GetRobotName()))
curCache.SetLV(robotInfo.get("LV", 1))
curCache.SetJob(robotInfo.get("Job", 1))
curCache.SetRealmLV(robotInfo.get("RealmLV", 0))
--
Gitblit v1.8.0