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 卡牌服务端(后台查看玩家、物品)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_PlayerItemInfo.py |  255 ++++++++++++++++++++++----------------------------
 1 files changed, 113 insertions(+), 142 deletions(-)

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

--
Gitblit v1.8.0