From 8a132929e7184bc274b742d3e25b93782c65e9ef Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 12 十二月 2025 14:32:56 +0800
Subject: [PATCH] 16 卡牌服务端(后台查看玩家、物品)

---
 /dev/null                                                                                                                       |  144 -------------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMToolPyInterface.py           |    9 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py  |  192 ++++++++--------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py |  255 ++++++++++------------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py          |   13 
 5 files changed, 220 insertions(+), 393 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_GetPlayerInfo.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_GetPlayerInfo.py
deleted file mode 100644
index e7be6ae..0000000
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_GetPlayerInfo.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/python
-# -*- coding: GBK -*-
-#---------------------------------------------------------------------
-#
-#---------------------------------------------------------------------
-##@package GY_Query_GetPlayerInfo
-# @todo: GM查询玩家物品 信息
-#
-# @author: wdb
-# @date 2012-06-06 12:00
-# @version 1.3
-# @note
-# @change: "2012-06-14 18:00" wdb gm工具调整,增加命令id
-# @change: "2015-01-30 02:00" hxp 增加转生次数、转生等级、绑钻信息
-# @change: "2015-05-22 14:30" hxp 增加大师等级、战斗力
-#---------------------------------------------------------------------
-"""Version = 2015-05-22 14:30"""
-#---------------------------------------------------------------------
-import GameWorld
-import IPY_GameWorld
-import PlayerControl
-import ShareDefine
-#---------------------------------------------------------------------
-
-## 请求逻辑
-#  @param query_Type 请求类型
-#  @param query_ID 请求的玩家ID
-#  @param packCMDList 发包命令 [ ]
-#  @param tick 当前时间
-#  @return resultDisc
-#  @remarks 函数详细说明.
-def DoLogic(query_Type, query_ID, packCMDList, tick):
-    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(query_ID)
-    
-    if not curPlayer or curPlayer.IsEmpty():
-        return ''
-    
-    playerInfo = {
-                  'AccID':curPlayer.GetAccID(),   # 账号
-                  'AccState':curPlayer.GetAccState(),  # 账号状态
-                  'PlayerID':curPlayer.GetPlayerID(),  
-                  'Name':curPlayer.GetPlayerName(),  # 玩家名
-                  'GMLV':curPlayer.GetGMLevel(),  #gm等级
-                  
-                  'Job':curPlayer.GetJob(),  # 职业
-                  'LV':curPlayer.GetLV(),  #玩家等级
-                  'OfficialRank':curPlayer.GetOfficialRank(),  #境界
-                  'FightPower':PlayerControl.GetFightPower(curPlayer),  #战斗力
-                  'VIPLV':curPlayer.GetVIPLv(),  # vip等级
-                  
-                  'MapID':curPlayer.GetMapID(),  #当前地图id
-                  'Gold':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money),   # 元宝
-                  'GoldPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper),   # 绑钻
-                  'Silver':PlayerControl.GetSilver(curPlayer),  # 银两
-                  'SilverPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Paper),   # 神玉
-                  
-                  'FamilyName':curPlayer.GetFamilyName(),  # 家族名称
-                  
-                  'LogoffTime':curPlayer.GetLogoffTime(), #离线时间
-                  'LoginTime':curPlayer.GetLoginTime(),  # 上线时间
-                  'LoginIP':curPlayer.GetIP(),  #登入IP
-                  'ClientVersion':curPlayer.GetAccountData().GetClientVersion(),  #客户端版本号
-                  
-                  'Online':1,
-                  }
-    
-    # 需要额外同步的自定义货币
-    CurrencyValueDict = {}
-    for moneyType in [ShareDefine.TYPE_Price_PayCoin, ShareDefine.TYPE_Price_PayCoinDay]:
-        CurrencyValueDict['PlayerCurrency_%s' % moneyType] = PlayerControl.GetMoneyReal(curPlayer, moneyType)
-    playerInfo.update(CurrencyValueDict)
-    
-    resultMsg = str([packCMDList[0], playerInfo, 'GMT_GetPlayerInfo'])
-    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GMToolResult', 
-                                                              resultMsg, len(resultMsg))
-    return ''
-    
-    
-    
-    
-    
\ No newline at end of file
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerItemInfo.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerItemInfo.py
deleted file mode 100644
index 67b57ce..0000000
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerItemInfo.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/python
-# -*- coding: GBK -*-
-#---------------------------------------------------------------------
-#
-#---------------------------------------------------------------------
-##@package GY_Query_PlayerItemInfo
-# @todo: GM查询玩家物品 信息
-#
-# @author: wdb
-# @date 2012-06-06 12:00
-# @version 1.4
-#
-# @note
-# @change: "2012-06-14 18:00" wdb gm工具调整,增加命令id
-# @change: "2012-06-28 16:30" wdb 删除错误log,增加背包类型
-# @change: "2012-06-29 21:30" wdb 返回信息是否过长
-# @change: "2015-12-29 11:00" hxp 开放其他背包查询
-#---------------------------------------------------------------------
-#"""Version = 2015-12-29 11:00"""
-#---------------------------------------------------------------------
-import IPY_GameWorld
-import GameWorld
-import ShareDefine
-import GMCommon
-#---------------------------------------------------------------------
-
-# 显示说有背包类型
-ShowAllPack = -1
-
-## 请求逻辑
-#  @param query_Type 请求类型
-#  @param query_ID 请求的玩家ID
-#  @param packCMDList 发包命令 [ ]
-#  @param tick 当前时间
-#  @return resultDisc
-#  @remarks 函数详细说明.
-def DoLogic(query_Type, query_ID, packCMDList, tick):
-    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(query_ID)
-
-    if not curPlayer or curPlayer.IsEmpty():
-        return ''
-    
-    packIndex = packCMDList[1]
-    itemList = []
-    
-    # 是否指定显示的背包类型
-    if IPY_GameWorld.rptDeleted <= packIndex <= ShareDefine.rptMax:
-        packTypes = [packIndex]
-        
-    elif packIndex == ShowAllPack:
-        return 'Not allowed to query all package items.'
-    
-    # 要查看的背包
-    for packIndex in packTypes:
-        # 遍历pack格子,获得物品信息
-        packItemList = _GetPackItem(curPlayer, packIndex)
-        itemList.extend(packItemList)
-        
-    totalItemCount = len(itemList)
-    gmResult = GMCommon.Def_Success
-    
-    resultMsg = {"PackIndex":packIndex, "TotalItemCount":totalItemCount, "ItemList":itemList}
-    retData = str([packCMDList[0], resultMsg, 'GMT_PlayerItemInfo', gmResult]).replace(" ", "")
-    if len(retData) >= 65535:
-        gmResult = GMCommon.Def_MaxLimit # 数据过大
-        resultMsg["ItemList"] = itemList[:totalItemCount / 2] # 暂只返回一半
-        retData = str([packCMDList[0], resultMsg, 'GMT_PlayerItemInfo', gmResult]).replace(" ", "")
-    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GMToolResult', retData, len(retData))
-    return ''
-    
-    
-## 获取背包字典
-#  @param curFindPlayer 当前玩家
-#  @param packIndex 背包索引
-#  @param discKey 字典key
-#  @return None
-def _GetPackItem(curFindPlayer, packIndex):
-    
-    itemPack = curFindPlayer.GetItemManager().GetPack(packIndex)
-    
-    itemList = []
-    
-    if not itemPack:
-        return itemList
-    
-    for index in range(itemPack.GetCount()):
-        curItem = itemPack.GetAt(index)
-        
-        if curItem == None:
-            continue
-        
-        if curItem.IsEmpty():
-            continue
-        
-        itemList.append(_GetItemInfo(curItem))
-        
-    return itemList
-
-def _GetItemInfo(curItem):
-#    "ItemGUID" : "096389AD-904F-4DAA-B7ED155B8663CE45",
-#    "ItemTypeID" : NumberLong(3901),
-#    "Count" : 100,
-#    "IsBind" : 0,
-#    "UserData" : "{}",
-#    "IsSuite" : 0,
-#    "RemainHour" : 0,
-#    "GearScore" : NumberLong(0),
-#    "CreateTime" : "2019-10-16 20:12:17"
-    
-#    "ItemPlaceIndex" : 1,
-#    "PlayerID" : NumberLong(268902),
-#    "ItemPlaceType" : 2,
-#    "UserDataLen" : NumberLong(2),
-#    "IsLocked" : 0,
-#    "SID" : -1135840175,
-#    "VerNO" : NumberLong(1),
-    
-    curItemInfo = {"ItemGUID":curItem.GetGUID(),
-                   "ItemTypeID":curItem.GetItemTypeID(),
-                   #"ItemName":curItem.GetName().decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding()),
-                   #"Count":curItem.GetCount(),
-                   #"UserData":curItem.GetUserData(),
-                   #"IsBind":curItem.GetIsBind(),
-                   #"IsSuite":1 if curItem.GetSuiteID() else 0,
-                   #"RemainHour":curItem.GetRemainHour(),
-                   #"GearScore":curItem.GetGearScore(),
-                   "CreateTime":curItem.GetCreateTime(),
-                   "ItemPlaceIndex":curItem.GetItemPlaceIndex()
-                   }
-    
-    if curItem.GetSuiteID():        
-        curItemInfo["IsSuite"] = 1
-    if curItem.GetCount() > 1:
-        curItemInfo["Count"] = curItem.GetCount()
-    if curItem.GetUserData() not in ["", "{}"]:
-        curItemInfo["UserData"] = curItem.GetUserData()
-    if curItem.GetIsBind():
-        curItemInfo["IsBind"] = curItem.GetIsBind()
-    if curItem.GetRemainHour():
-        curItemInfo["RemainHour"] = curItem.GetRemainHour()
-    if curItem.GetGearScore():
-        curItemInfo["GearScore"] = curItem.GetGearScore()
-    return curItemInfo
-
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py
index e8b83cf..171fab1 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py
@@ -1,109 +1,107 @@
 #!/usr/bin/python
 # -*- coding: GBK -*-
-#---------------------------------------------------------------------
+#-------------------------------------------------------------------------------
 #
-#---------------------------------------------------------------------
-##@package GMT_GetPlayerInfo.py
-# GM命令,获得玩家信息
+##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_GetPlayerInfo
 #
-# @author wdb
-# @date 2012-6-14
-# @version 1.6
+# @todo:查看玩家
+# @author hxp
+# @date 2025-12-12
+# @version 1.0
 #
-# @note
-# @change: "2012-06-21 15:30" wdb int修改到GMCommon开接口
-# @change: "2012-07-12 18:00" wdb 增加编码属性
-# @change: "2012-07-30 11:30" wdb GM回复细化,代码优化
-# @change: "2012-08-10 17:00" whx 增加仓库密码
-# @change: "2015-01-30 02:00" hxp 增加转生次数、转生等级、绑钻信息
-# @change: "2015-05-22 14:30" hxp 增加大师等级、战斗力
-#---------------------------------------------------------------------
-"""Version = 2015-05-22 14:30"""
-#---------------------------------------------------------------------
-#导入
-from Collections import DataServerPlayerData
-from MangoDBCommon import fix_incomingText
-from Collections.CollectionDefine import *
-import GMCommon
-#---------------------------------------------------------------------
-#全局变量
+# 详细描述: 查看玩家
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2025-12-12 15:00"""
+#-------------------------------------------------------------------------------
 
-#---------------------------------------------------------------------
+import GMCommon
+from Collections.CollectionDefine import (UCN_DSAccount, UCN_RoleNomalDict)
+from Collections import (DataServerPlayerData)
+import PlayerControl
+import IPY_GameWorld
+import ShareDefine
+import PyGameData
+import ChConfig
+
+CurrencyMoneyTypeList = [ShareDefine.TYPE_Price_PayCoin, ShareDefine.TYPE_Price_PayCoinDay, ShareDefine.TYPE_Price_Xiantao, ShareDefine.TYPE_Price_Lingyu]
 
 ## 收到gm命令执行
 # @param gmCmdDict:gm命令字典
 # @return None 
 def OnExec(gmCmdDict):
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
     
-    if playerFind == '':
-        return GMCommon.Def_ParamErr, ''
+    from GMToolLogicProcess import ProjSpecialProcess
+    Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False)
     
-    elif queryType == 'accID':
-        return GMCommon.Def_DoQueryLogDB, ''
-   
-    return GMCommon.Def_DoQueryUserDB, '%s'%GMCommon.Def_GMKey_PlayerName
+    if Result == GMCommon.Def_PlayerOfLine:
+        dbPlayer = curPlayer
+        playerInfo = __getPlayerInfoByDB(dbPlayer)
     
-    
-## 查询logdb返回
-# @param logdb:logdb
-# @param data:传入的信息
-# @param gmCmdDict:gm命令字典
-# @return None 
-def LogDBResponse(logdb, data, gmCmdDict):
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
-    
-    if queryType == 'accID' and GMCommon.GetPlayerOnLineByAccID(logdb, playerFind):
-        return GMCommon.Def_SendToGameServer, ''
-  
-    # 转换字符串
-    if data != '' and GMCommon.GetPlayerOnLineByAccID(logdb, data):        
-        return GMCommon.Def_SendToGameServer, ''
-        
-    return GMCommon.Def_DoQueryUserDB, ''
-
-
-## 查询userdb返回
-# @param userdb:userdb
-# @param data:传入的信息
-# @param gmCmdDict:gm命令字典
-# @return None 
-def UserDBResponse(userdb, data, gmCmdDict):
-    # 转换字符串
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
-        
-    # queryType不是accID,发送的信息是玩家的名字  
-    if queryType != 'accID':
-        playerAccID = GMCommon.GetPlayerAccID(userdb, {'PlayerName':fix_incomingText(playerFind), 'IsDeleted':0})
-        
-        if playerAccID == '':
-            return GMCommon.Def_NoTag, ''
+    elif Result == GMCommon.Def_Success:
+        playerInfo = __getPlayerInfoByPlayer(curPlayer)
         
     else:
-        # queryType为accID,发送的信息就是玩家的AccID
-        playerAccID = playerFind
+        return Result
     
-    # 返回playerid,判断是否在线
-    if data == '%s'%GMCommon.Def_GMKey_PlayerName:        
-        return GMCommon.Def_DoQueryLogDB, playerAccID
+    return GMCommon.Def_Success, playerInfo
 
+def __getPlayerInfoByPlayer(curPlayer):
+    ## 从在线取
+    if not curPlayer:
+        return {}
+    
+    playerInfo = {
+                  'AccID':curPlayer.GetAccID(),   # 账号
+                  'AccState':curPlayer.GetAccState(),  # 账号状态
+                  'PlayerID':curPlayer.GetPlayerID(),  
+                  'Name':curPlayer.GetPlayerName(),  # 玩家名
+                  'GMLV':curPlayer.GetGMLevel(),  #gm等级
+                  
+                  'Job':curPlayer.GetJob(),  # 职业
+                  'LV':curPlayer.GetLV(),  #玩家等级
+                  'OfficialRank':curPlayer.GetOfficialRank(),  #境界
+                  'FightPower':PlayerControl.GetFightPower(curPlayer),  #战斗力
+                  #'VIPLV':curPlayer.GetVIPLv(),  # vip等级
+                  
+                  'MapID':curPlayer.GetMapID(),  #当前地图id
+                  'Gold':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money),   # 元宝
+                  #'GoldPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper),   # 绑钻
+                  #'Silver':PlayerControl.GetSilver(curPlayer),  # 银两
+                  #'SilverPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Paper),   # 神玉
+                  
+                  'FamilyName':curPlayer.GetFamilyName(),  # 家族名称
+                  
+                  'LogoffTime':curPlayer.GetLogoffTime(), #离线时间
+                  'LoginTime':curPlayer.GetLoginTime(),  # 上线时间
+                  'LoginIP':curPlayer.GetIP(),  #登入IP
+                  'ClientVersion':curPlayer.GetAccountData().GetClientVersion(),  #客户端版本号
+                  
+                  'Online':1,
+                  
+                  'ExAttr1':curPlayer.GetExAttr1(), #过关进度
+                  'TreeLV':curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLV) # 祝福数等级
+                  }
+    
+    # 需要额外同步的自定义货币
+    CurrencyValueDict = {}
+    for moneyType in CurrencyMoneyTypeList:
+        CurrencyValueDict['PlayerCurrency_%s' % moneyType] = PlayerControl.GetMoneyReal(curPlayer, moneyType)
+    playerInfo.update(CurrencyValueDict)
+    
+    return playerInfo
+
+def __getPlayerInfoByDB(dbPlayer):
+    if not dbPlayer:
+        return {}
+    
+    accID = dbPlayer.AccID
+    
+    userdb = PyGameData.g_usrCtrlDB.db
+    
     accountData = DataServerPlayerData.tagDSAccount()
-    accountData.ACCID = playerAccID
+    accountData.ACCID = accID
     accountData.adoLoad(userdb[UCN_DSAccount])
-    
-    collection = userdb[UCN_DBPlayer]   
-    dbPlayer = DataServerPlayerData.tagDBPlayer()
-    dbPlayer.IsDeleted = 0
-    
-    loadOK = dbPlayer.adoLoadCEx(collection, {'AccID':fix_incomingText(playerAccID),
-                                                 'IsDeleted':dbPlayer.IsDeleted}) 
-       
-    if not loadOK:
-        # 回复gm
-        return GMCommon.Def_NoTag, ''
     
     roleDict = {}
     moneyMinusDict = {}
@@ -134,13 +132,13 @@
                   'LV':dbPlayer.LV,  #玩家等级
                   'OfficialRank':dbPlayer.OfficialRank,  #境界
                   'FightPower':dbPlayer.FightPowerEx * 100000000 + dbPlayer.FightPower,  #战斗力
-                  'VIPLV':dbPlayer.VIPLv,  # vip等级
+                  #'VIPLV':dbPlayer.VIPLv,  # vip等级
                   
                   'MapID':dbPlayer.MapID,  #当前地图id
                   'Gold':moneyMinusDict[1] if 1 in moneyMinusDict else dbPlayer.Gold,   # 元宝
-                  'GoldPaper':moneyMinusDict[2] if 2 in moneyMinusDict else dbPlayer.GoldPaper,   # 绑钻
-                  'Silver':dbPlayer.Silver,  # 银两
-                  'SilverPaper':moneyMinusDict[4] if 4 in moneyMinusDict else dbPlayer.SilverPaper,   # 神玉
+                  #'GoldPaper':moneyMinusDict[2] if 2 in moneyMinusDict else dbPlayer.GoldPaper,   # 绑钻
+                  #'Silver':dbPlayer.Silver,  # 银两
+                  #'SilverPaper':moneyMinusDict[4] if 4 in moneyMinusDict else dbPlayer.SilverPaper,   # 神玉
                   
                   'FamilyName':dbPlayer.FamilyName,  # 家族名称
                   
@@ -150,19 +148,19 @@
                   'ClientVersion':accountData.ClientVersion,  #客户端版本号
                   
                   'Online':0,
+                  
+                  'ExAttr1':dbPlayer.ExAttr1, #过关进度
+                  'TreeLV':roleDict.get(ChConfig.Def_PDict_TreeLV, 0) # 祝福数等级
                   }
     
     # 需要额外同步的自定义货币
     CurrencyValueDict = {}
-    for moneyType in [99, 98]:
-        if moneyType == 99:
+    for moneyType in CurrencyMoneyTypeList:
+        if moneyType == ShareDefine.TYPE_Price_PayCoin:
             moneyValue = dbPlayer.ExAttr11
         else:
             moneyValue = roleDict.get("PlayerCurrency_%s" % moneyType, 0)
         CurrencyValueDict['PlayerCurrency_%s' % moneyType] = moneyValue
     playerInfo.update(CurrencyValueDict)
-    return GMCommon.Def_Success, playerInfo
-
-
-
-
+    
+    return playerInfo
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py
index 5b5a96d..eb0c4a0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py
@@ -1,170 +1,141 @@
 #!/usr/bin/python
 # -*- coding: GBK -*-
-#---------------------------------------------------------------------
+#-------------------------------------------------------------------------------
 #
-#---------------------------------------------------------------------
-##@package GMT_PlayerItemInfo.py
-# GM命令获得玩家物品信息
+##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_PlayerItemInfo
 #
-# @author wdb
-# @date 2012-6-14
-# @version 1.4
+# @todo:查看玩家物品
+# @author hxp
+# @date 2025-12-12
+# @version 1.0
 #
-# @note
-# @change: "2012-06-21 15:30" wdb int修改到GMCommon开接口
-# @change: "2012-06-29 21:30" wdb 返回信息是否过长
-# @change: "2012-07-12 18:00" wdb 增加编码属性
-# @change: "2012-07-30 11:30" wdb GM回复细化,代码优化
-#---------------------------------------------------------------------
-"""Version = 2012-07-30 11:30"""
-#---------------------------------------------------------------------
-#导入
-from Collections import DataServerPlayerData
-from MangoDBCommon import fix_incomingText
-from Collections.CollectionDefine import *
+# 详细描述: 查看玩家物品
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2025-12-12 15:00"""
+#-------------------------------------------------------------------------------
+
 import GMCommon
-#---------------------------------------------------------------------
-#全局变量
-# 物品userdata的定义key
-IudetEquipAddSkillList = 3
-IudetEquipAddSkillCnt = 4
-IudetWakeUpCnt = 12
+from Collections.CollectionDefine import (UCN_RoleItem)
+#from Collections import (DataServerPlayerData)
+import IPY_GameWorld
+import ShareDefine
+import PyGameData
+import GameWorld
 
-# 显示说有背包类型
+# 所有背包
 ShowAllPack = -1
-
-#---------------------------------------------------------------------
 
 ## 收到gm命令执行
 # @param gmCmdDict:gm命令字典
 # @return None 
 def OnExec(gmCmdDict):
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
     
-    if playerFind == '':
-        return GMCommon.Def_ParamErr, ''
+    from GMToolLogicProcess import ProjSpecialProcess
+    Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False)
     
-    elif queryType == 'accID':
-        return GMCommon.Def_DoQueryLogDB, ''
-   
-    return GMCommon.Def_DoQueryUserDB, '%s'%GMCommon.Def_GMKey_PlayerName
+    packIndex = GameWorld.ToIntDef(gmCmdDict.get(GMCommon.Def_GMKey_PackIndex, ''))
+    if packIndex == ShowAllPack:
+        # 暂不提供查询所有的物品
+        return GMCommon.Def_ParamErr, "Not allowed to query all package items."
+    
+    if packIndex < IPY_GameWorld.rptDeleted or packIndex > ShareDefine.rptMax:
+        return GMCommon.Def_ParamErr, "packType error."
+    
+    if Result == GMCommon.Def_PlayerOfLine:
+        dbPlayer = curPlayer
+        itemList = __getPlayerItemByDB(dbPlayer, packIndex)
         
-    
-## 查询logdb返回
-# @param logdb:logdb
-# @param data:传入的信息
-# @param gmCmdDict:gm命令字典
-# @return None 
-def LogDBResponse(logdb, data, gmCmdDict):
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
-    
-    if queryType == 'accID' and GMCommon.GetPlayerOnLineByAccID(logdb, playerFind):
-        return GMCommon.Def_SendToGameServer, ''
-  
-    # 转换字符串
-    if data != '' and GMCommon.GetPlayerOnLineByAccID(logdb, data):        
-        return GMCommon.Def_SendToGameServer, ''
-    return GMCommon.Def_DoQueryUserDB, ''
-
-
-## 查询userdb返回
-# @param userdb:userdb
-# @param data:传入的信息
-# @param gmCmdDict:gm命令字典
-# @return None 
-def UserDBResponse(userdb, data, gmCmdDict):
-    # 转换字符串
-    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
-    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
+    elif Result == GMCommon.Def_Success:
+        itemList = __getPlayerItemByPlayer(curPlayer, packIndex)
         
-    # queryType不是accID,发送的信息是玩家的名字  
-    if queryType != 'accID':
-        playerAccID = GMCommon.GetPlayerAccID(userdb, {'PlayerName':fix_incomingText(playerFind), 'IsDeleted':0})
-        
-        if playerAccID == '':
-            return GMCommon.Def_NoTag, ''
     else:
-        # queryType为accID,发送的信息就是玩家的AccID
-        playerAccID = playerFind
+        return Result
     
-    # 返回playerid,判断是否在线
-    if data == '%s'%GMCommon.Def_GMKey_PlayerName:
-        return GMCommon.Def_DoQueryLogDB, playerAccID
-    
-    collection = userdb[UCN_DBPlayer] 
-    dbPlayer = DataServerPlayerData.tagDBPlayer()
-    dbPlayer.IsDeleted = 0
+    totalItemCount = len(itemList)
+    resultMsg = {"PackIndex":packIndex, "TotalItemCount":totalItemCount, "ItemList":itemList}
+    # 不大与word
+    #if len(str(resultMsg)) > 65000:
+    #    return GMCommon.Def_MaxLimit, ''
+    return GMCommon.Def_Success, resultMsg
 
-    loadOK = dbPlayer.adoLoadCEx(collection, {'AccID':fix_incomingText(playerAccID),
-                                                  'IsDeleted':dbPlayer.IsDeleted}) 
-    # 加入人物信息
-    if not loadOK:
-        return GMCommon.Def_NoTag, ""
+def __getPlayerItemByPlayer(curPlayer, packIndex):
+    ## 从在线取
+    if not curPlayer:
+        return []
+    
+    itemPack = curPlayer.GetItemManager().GetPack(packIndex)
+    itemList = []
+    for index in range(itemPack.GetCount()):
+        curItem = itemPack.GetAt(index)
+        if curItem == None or curItem.IsEmpty():
+            continue
+        curItemInfo = {"ItemGUID":curItem.GetGUID(),
+                       "ItemTypeID":curItem.GetItemTypeID(),
+                       "CreateTime":curItem.GetCreateTime(),
+                       "ItemPlaceIndex":curItem.GetItemPlaceIndex()
+                       }
+        if curItem.GetSuiteID():        
+            curItemInfo["IsSuite"] = 1
+        if curItem.GetCount() > 1:
+            curItemInfo["Count"] = curItem.GetCount()
+        if curItem.GetUserData() not in ["", "{}"]:
+            curItemInfo["UserData"] = curItem.GetUserData()
+        if curItem.GetIsBind():
+            curItemInfo["IsBind"] = curItem.GetIsBind()
+        if curItem.GetRemainHour():
+            curItemInfo["RemainHour"] = curItem.GetRemainHour()
+        if curItem.GetGearScore():
+            curItemInfo["GearScore"] = curItem.GetGearScore()
+        itemList.append(curItemInfo)
         
+    return itemList
+
+def __getPlayerItemByDB(dbPlayer, packIndex):
+    if not dbPlayer:
+        return []
+    
+    userdb = PyGameData.g_usrCtrlDB.db
+    
     # 获得玩家物品
     itemCollection = userdb[UCN_RoleItem]
     itemFind = itemCollection.find({'PlayerID':dbPlayer.PlayerID})
     
     itemList = []
     # 无物品
-    if itemFind.count() <= 0:
-        return GMCommon.Def_Success, itemList
-    
-    itemInfo = itemFind[0]
-    packIndex = GMCommon.ToIntDef(gmCmdDict.get(GMCommon.Def_GMKey_PackIndex, ''))
-    if packIndex == ShowAllPack:
-        # 暂不提供查询所有的物品
-        return GMCommon.Def_ParamErr, "Not allowed to query all package items."
-    # 遍历所有物品
-    for itemIndex in range(1, itemInfo['Count'] + 1):        
-        itemDict = itemInfo.get('%s'%itemIndex, {})
-        # 有指定背包类型,则根据背包类型过滤物品
-        if packIndex != ShowAllPack and packIndex != itemDict['ItemPlaceType']:
-            continue
+    if itemFind.count() > 0:
+        itemInfo = itemFind[0]
+        # 遍历所有物品
+        for itemIndex in range(1, itemInfo['Count'] + 1):        
+            itemDict = itemInfo.get('%s'%itemIndex, {})
+            # 有指定背包类型,则根据背包类型过滤物品
+            if packIndex != itemDict['ItemPlaceType']:
+                continue
+            #    "ItemGUID" : "096389AD-904F-4DAA-B7ED155B8663CE45",
+            #    "ItemTypeID" : NumberLong(3901),
+            #    "Count" : 100,
+            #    "IsBind" : 0,
+            #    "UserData" : "{}",
+            #    "IsSuite" : 0,
+            #    "RemainHour" : 0,
+            #    "GearScore" : NumberLong(0),
+            #    "CreateTime" : "2019-10-16 20:12:17"
+                
+            #    "ItemPlaceIndex" : 1,
+            #    "PlayerID" : NumberLong(268902),
+            #    "ItemPlaceType" : 2,
+            #    "UserDataLen" : NumberLong(2),
+            #    "IsLocked" : 0,
+            #    "SID" : -1135840175,
+            #    "VerNO" : NumberLong(1),
+            curItemInfo = {}
+            for k, v in itemDict.items():
+                if k in ["UserDataLen", "ItemPlaceType", "PlayerID", "IsLocked", "SID", "VerNO"]:
+                    continue
+                if not v or v == "{}":
+                    continue
+                curItemInfo[k] = v
         
-        itemList.append(_GetItemInfo(itemDict))
-        
-    totalItemCount = len(itemList)
-    resultMsg = {"PackIndex":packIndex, "TotalItemCount":totalItemCount, "ItemList":itemList}
-    # 不大与word
-    if len(str(resultMsg)) > 65000:
-        return GMCommon.Def_MaxLimit, ''
-    
-    # 回复查询信息
-    return GMCommon.Def_Success, resultMsg
-
-
-## 获得物品信息
-# @param itemDict: 物品信息字典
-# @return curItemInfo:当前物品显示信息
-def _GetItemInfo(itemDict):
-#    "ItemGUID" : "096389AD-904F-4DAA-B7ED155B8663CE45",
-#    "ItemTypeID" : NumberLong(3901),
-#    "Count" : 100,
-#    "IsBind" : 0,
-#    "UserData" : "{}",
-#    "IsSuite" : 0,
-#    "RemainHour" : 0,
-#    "GearScore" : NumberLong(0),
-#    "CreateTime" : "2019-10-16 20:12:17"
-    
-#    "ItemPlaceIndex" : 1,
-#    "PlayerID" : NumberLong(268902),
-#    "ItemPlaceType" : 2,
-#    "UserDataLen" : NumberLong(2),
-#    "IsLocked" : 0,
-#    "SID" : -1135840175,
-#    "VerNO" : NumberLong(1),
-    
-    curItemInfo = {}
-    for k, v in itemDict.items():
-        if k in ["UserDataLen", "ItemPlaceType", "PlayerID", "IsLocked", "SID", "VerNO"]:
-            continue
-        if not v or v == "{}":
-            continue
-        curItemInfo[k] = v
-        
-    return curItemInfo
-    
\ No newline at end of file
+            itemList.append(curItemInfo)
+            
+    return itemList
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMToolPyInterface.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMToolPyInterface.py
index 3b75530..01b19ca 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMToolPyInterface.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/GMToolPyInterface.py
@@ -9,6 +9,7 @@
 from DBCommon import CommonDefine
 import NetPackCommon
 from Commands import GMCommon
+DBConfig = __import__('Config.DBConfig')
 import json
 ################################################################## 
                 ####### 提供的接口 ######
@@ -16,10 +17,10 @@
     
 #回复给ServersRoute->GM工具 命令执行结果包
 def SendToGMToolCommandResult(orderID, resultMsg, UserData = ''):
-    # if isinstance(Result, unicode):
-    #     #直接从数据库未进行转化的话是unicode
-    #     Result = Result.encode('gbk')
-
+    if isinstance(resultMsg, unicode):
+        #直接从数据库未进行转化的话是unicode
+        resultMsg = resultMsg.encode(DBConfig.encoding)
+        
     recvPack = SendPackProtocol.tagGMCommandResult()
     recvPack.Type = CommonDefine.gstGMToolCommandResult 
     recvPack.OrderLen = len(orderID)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
index f915c20..ee3afd2 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/ProjSpecialProcess.py
@@ -238,7 +238,8 @@
     @param offlineSupport: 离线玩家是否支持该命令,默认支持,当玩家离线时,会在上线后执行该命令
     @return: GMCommon.Def_xxx, curPlayer
                                 非 Def_Success 的错误类型        -    代表错误,可直接返回给后台
-            Def_Success, curPlayer    -    curPlayer为空时代表玩家离线状态
+            Def_Success, curPlayer    -    curPlayer为空时代表玩家离线状态,注:离线状态且需要支持离线处理的才返回 (Def_Success, None)
+            GMCommon.Def_PlayerOfLine, dbPlayer    -    不需要支持离线处理时,返回离线跟 dbPlayer
     '''
     
     queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
@@ -249,24 +250,24 @@
     
     # 玩家姓名
     if queryType == GMCommon.Def_GMKey_PlayerName:
-        rec = PyGameData.g_usrCtrlDB.findDBPlayerByName(playerFind)
+        dbPlayer = PyGameData.g_usrCtrlDB.findDBPlayerByName(playerFind, True)
     elif queryType == GMCommon.Def_GMKey_PlayerAccID:
-        rec = PyGameData.g_usrCtrlDB.findDBPlayerByAccID(playerFind)
+        dbPlayer = PyGameData.g_usrCtrlDB.findDBPlayerByAccID(playerFind, True)
     else:
         return GMCommon.Def_ParamErr, None
     
-    if not rec:
+    if not dbPlayer:
         # db找不到就是不存在该玩家
         return GMCommon.Def_NoTag, None
     
-    playerID = rec.get(u'PlayerID', 0)
+    playerID = dbPlayer.PlayerID
     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
     if not curPlayer or curPlayer.IsEmpty():
         # 离线处理
         if offlineSupport:
             PlayerOfflineSupport.AddOfflineUnprocessed(playerID, "GMToolCMD", gmCmdDict)
             return GMCommon.Def_Success, None
-        return GMCommon.Def_PlayerOfLine, None
+        return GMCommon.Def_PlayerOfLine, dbPlayer
     
     return GMCommon.Def_Success, curPlayer
 

--
Gitblit v1.8.0