From 180eab3510f793ed008e9504976c3b3063f7ca6d Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 18 十一月 2025 18:21:52 +0800
Subject: [PATCH] 110 【主界面】仙树升级-服务端(免费减时修改为充能减时;特权支持充能额外上限;广告奖励支持领取充能奖励;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py |  109 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 86 insertions(+), 23 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 1201f24..3b1065d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCache.py
@@ -37,8 +37,6 @@
     return
 
 def OnPlayerLogout(curPlayer):
-    if curPlayer.GetLV() < IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1):
-        return
     
     playerID = curPlayer.GetPlayerID()
     curCache = FindViewCache(playerID)
@@ -112,6 +110,17 @@
         
     return False
 
+def FindBattleViewCache(playerID):
+    ## 获取可战斗的玩家缓存
+    # @return: None-无;curCache-有返回该缓存对象
+    curCache = FindViewCache(playerID)
+    if not curCache:
+        return
+    plusDict = curCache.GetPlusDict()
+    if "Lineup" not in plusDict:
+        return
+    return curCache
+
 def FindViewCache(playerID):
     '''查找玩家缓存,如果不存在,则会有额外逻辑,如从redis、db直接找,
             本服玩家理论上一定有查看缓存,因为如果不存在会直接从db读,除非该玩家数据被删除
@@ -146,23 +155,35 @@
             # 逻辑待扩展
             
     # 机器人
-    elif ShareDefine.RobotIDStart <= playerID <= ShareDefine.RobotIDMax:
-        curCache = UpdRobotViewCache(playerID)
+    #elif ShareDefine.RobotIDStart <= playerID <= ShareDefine.RobotIDMax:
+    elif IpyGameDataPY.GetIpyGameDataNotLog("Robot", playerID):
+        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:
-        serverID = playerID % 100 + 1 # 1 ~ 100 服
-        accID = "fake%s@test@s%s" % (playerID, serverID)
-        fightPower = random.randint(1000000, 100000000) # 先随机,外层有需要的话再自己设置
+        GameWorld.DebugLog("加载假玩家缓存: %s" % playerID)
+        # 随机复制个机器人数据
+        ipyDataMgr = IpyGameDataPY.IPY_Data()
+        robotIpyData = ipyDataMgr.GetRobotByIndex(random.randint(0, ipyDataMgr.GetRobotCount() - 1))
         
         curCache = viewCacheMgr.AddPlayerViewCache(playerID)
-        curCache.SetPlayerName("%s%s" % (GameWorld.GbkToCode("神秘道友"), playerID))
+        curCache = UpdRobotViewCache(curCache, robotIpyData.GetID())
+        
+        # 再覆盖部分数据
+        serverID = playerID % 100 + 1 # 1 ~ 100 服
+        accID = "fake%s@test@s%s" % (playerID, serverID)
+        #fightPower = random.randint(1000000, 100000000) # 先随机,外层有需要的话再自己设置
+        
+        curCache.SetPlayerName("%s%s" % (GameWorld.GbkToCode("主公"), playerID))
         curCache.SetAccID(accID)
-        curCache.SetLV(random.randint(100, 200))
-        curCache.SetJob(random.randint(1, 2))
-        curCache.SetRealmLV(random.randint(5, 15))
-        curCache.SetFightPowerTotal(fightPower)
         curCache.SetServerID(serverID)
+        #curCache.SetLV(random.randint(100, 200))
+        #curCache.SetJob(random.randint(1, 2))
+        #curCache.SetRealmLV(random.randint(5, 15))
+        #curCache.SetFightPowerTotal(fightPower)
         curCache.SetOffTime(int(time.time()) - random.randint(1, 3600 * 24 * 10)) # 随机离线 0~10天
         
     return curCache
@@ -194,6 +215,9 @@
     if not curCache:
         return
     
+    familyID = curPlayer.GetFamilyID()
+    family = DBDataMgr.GetFamilyMgr().FindFamily(familyID) if familyID else None
+    
     tick = GameWorld.GetGameWorld().GetTick()
     curPlayer.SetDict(Key_UpdViewCacheTick, tick)
     #GameWorld.DebugLog("更新玩家查看缓存数据! isOffline=%s" % isOffline, playerID)
@@ -205,10 +229,12 @@
     curCache.SetFace(curPlayer.GetFace())
     curCache.SetFacePic(curPlayer.GetFacePic())
     curCache.SetModelMark(curPlayer.GetModelMark())
-    curCache.SetFamilyID(curPlayer.GetFamilyID())
-    curCache.SetFamilyName(curPlayer.GetFamilyName())
-    curCache.SetFamilyEmblemID(PlayerControl.GetFamilyEmblemID(curPlayer))
+    curCache.SetEquipShowSwitch(curPlayer.GetEquipShowSwitch())
     curCache.SetTitleID(PlayerControl.GetTitleID(curPlayer))
+    curCache.SetFamilyID(familyID)
+    curCache.SetFamilyName(family.GetName() if family else "")
+    curCache.SetFamilyEmblemID(family.GetEmblemID() if family else 0)
+    curCache.SetFamilyEmblemWord(family.GetEmblemWord() if family else "")
     curCache.SetFightPowerTotal(PlayerControl.GetFightPower(curPlayer))
     curCache.SetServerID(GameWorld.GetPlayerServerID(curPlayer))
     if isOffline:
@@ -236,7 +262,7 @@
     
     # 其他
     
-    plusDict= {"Equip":equipDict, "Lineup":lineupDict}
+    plusDict = {"Equip":equipDict, "Lineup":lineupDict}
     curCache.SetPlusDict(plusDict)
     
     return curCache
@@ -263,15 +289,50 @@
     curCache.SetFace(dbPlayer.Face)
     curCache.SetFacePic(dbPlayer.FacePic)
     curCache.SetModelMark(dbPlayer.ModelMark)
+    curCache.SetEquipShowSwitch(dbPlayer.EquipShowSwitch)
+    curCache.SetTitleID(dbPlayer.ExAttr3)
     curCache.SetFamilyID(familyID)
-    family = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
+    family = DBDataMgr.GetFamilyMgr().FindFamily(familyID) if familyID else None
     curCache.SetFamilyName(family.GetName() if family else "")
     curCache.SetFamilyEmblemID(family.GetEmblemID() if family else 0)
-    #curCache.SetTitleID(PlayerControl.GetTitleID(curPlayer))
+    curCache.SetFamilyEmblemWord(family.GetEmblemWord() if family else "")
     curCache.SetFightPowerTotal(dbPlayer.FightPowerEx * ChConfig.Def_PerPointValue + dbPlayer.FightPower)
     curCache.SetServerID(GameWorld.GetAccIDServerID(dbPlayer.AccID))
     curCache.SetOffTime(GameWorld.ChangeTimeStrToNum(dbPlayer.LogoffTime) if dbPlayer.LogoffTime else 0)
     return curCache
+
+def GetPlayerBaseViewInfo(playerID, curPlayer=None):
+    ## 获取玩家基础查看信息
+    baseInfo = {}
+    if not curPlayer:
+        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+    if curPlayer:
+        baseInfo = {
+                    "Name":curPlayer.GetPlayerName(),
+                    "LV":curPlayer.GetLV(),
+                    "Job":curPlayer.GetJob(),
+                    "RealmLV":curPlayer.GetOfficialRank(),
+                    "Face":curPlayer.GetFace(),
+                    "FacePic":curPlayer.GetFacePic(),
+                    "TitleID":PlayerControl.GetTitleID(curPlayer),
+                    "ServerID":GameWorld.GetPlayerServerID(curPlayer),
+                    "FightPower":PlayerControl.GetFightPower(curPlayer),
+                    }
+    else:
+        viewCache = FindViewCache(playerID)
+        if viewCache:
+            baseInfo = {
+                        "Name":viewCache.GetPlayerName(),
+                        "LV":viewCache.GetLV(),
+                        "Job":viewCache.GetJob(),
+                        "RealmLV":viewCache.GetRealmLV(),
+                        "Face":viewCache.GetFace(),
+                        "FacePic":viewCache.GetFacePic(),
+                        "TitleID":viewCache.GetTitleID(),
+                        "ServerID":viewCache.GetServerID(),
+                        "FightPower":viewCache.GetFightPowerTotal(),
+                        }
+    return baseInfo
 
 def GetRobotByViewCache(curCache):
     ## 根据缓存内容获取机器人数据
@@ -284,13 +345,15 @@
                  "RealmLV" : curCache.GetRealmLV(),
                  "Face" : curCache.GetFace(),
                  "FacePic" : curCache.GetFacePic(),
+                 "TitleID" : curCache.GetTitleID(),
                  "ModelMark" : curCache.GetModelMark(),
+                 "EquipShowSwitch" : curCache.GetEquipShowSwitch(),
                  "FightPower" : curCache.GetFightPowerTotal(),
                  "PlusData" : curCache.GetPlusDict(),
                  }
     return robotDict
 
-def UpdRobotViewCache(robotID):
+def UpdRobotViewCache(curCache, robotID):
     ## 更新机器人查看缓存
     robotIpyData = IpyGameDataPY.GetIpyGameData("Robot", robotID)
     if not robotIpyData:
@@ -300,10 +363,6 @@
     except:
         return
     
-    viewCacheMgr = DBDataMgr.GetPlayerViewCacheMgr()
-    curCache = viewCacheMgr.GetPlayerViewCache(robotID)
-    if not curCache:
-        curCache = viewCacheMgr.AddPlayerViewCache(robotID)
     #curCache.SetAccID(dbPlayer.AccID)
     
     curCache.SetPlayerName(robotInfo.get("PlayerName", "p%s" % robotID))
@@ -312,7 +371,9 @@
     curCache.SetRealmLV(robotInfo.get("RealmLV", 0))
     curCache.SetFace(robotInfo.get("Face", 0))
     curCache.SetFacePic(robotInfo.get("FacePic", 0))
+    curCache.SetTitleID(robotInfo.get("TitleID", 0))
     curCache.SetModelMark(robotInfo.get("ModelMark", 0))
+    curCache.SetEquipShowSwitch(robotInfo.get("EquipShowSwitch", 0))
     #机器人暂定没有仙盟、称号
     #curCache.SetFamilyID(familyID)
     #family = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
@@ -364,6 +425,7 @@
     clientPack.Face = curCache.GetFace()
     clientPack.FacePic = curCache.GetFacePic()
     clientPack.ModelMark = curCache.GetModelMark()
+    clientPack.EquipShowSwitch = curCache.GetEquipShowSwitch()
     clientPack.TitleID = curCache.GetTitleID()
     clientPack.ServerID = curCache.GetServerID()
     clientPack.FightPower = curCache.GetFightPower()
@@ -371,6 +433,7 @@
     clientPack.FamilyID = curCache.GetFamilyID()
     clientPack.FamilyName = curCache.GetFamilyName()
     clientPack.FamilyEmblemID = curCache.GetFamilyEmblemID()
+    clientPack.FamilyEmblemWord = curCache.GetFamilyEmblemWord()
     clientPack.PlusData = curCache.GetPlusData()
     clientPack.PlusDataSize = len(clientPack.PlusData)
     return clientPack

--
Gitblit v1.8.0