| | |
| | | #!/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, ''
|
| | | packIndex = GameWorld.ToIntDef(gmCmdDict.get(GMCommon.Def_GMKey_PackIndex, ''))
|
| | | if packIndex == ShowAllPack:
|
| | | # 暂不提供查询所有的物品
|
| | | return GMCommon.Def_ParamErr, "Not allowed to query all package items."
|
| | |
|
| | | return GMCommon.Def_DoQueryUserDB, '%s'%GMCommon.Def_GMKey_PlayerName
|
| | | 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, '')
|
| | | elif Result == GMCommon.Def_Success:
|
| | | itemList = __getPlayerItemByPlayer(curPlayer, packIndex)
|
| | |
|
| | | 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, ''
|
| | | else:
|
| | | # queryType为accID,发送的信息就是玩家的AccID
|
| | | playerAccID = playerFind
|
| | | return Result
|
| | |
|
| | | # 返回playerid,判断是否在线
|
| | | if data == '%s'%GMCommon.Def_GMKey_PlayerName:
|
| | | return GMCommon.Def_DoQueryLogDB, playerAccID
|
| | | 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
|
| | |
|
| | | collection = userdb[UCN_DBPlayer] |
| | | dbPlayer = DataServerPlayerData.tagDBPlayer()
|
| | | dbPlayer.IsDeleted = 0
|
| | | def __getPlayerItemByPlayer(curPlayer, packIndex):
|
| | | ## 从在线取
|
| | | if not curPlayer:
|
| | | return []
|
| | |
|
| | | loadOK = dbPlayer.adoLoadCEx(collection, {'AccID':fix_incomingText(playerAccID),
|
| | | 'IsDeleted':dbPlayer.IsDeleted}) |
| | | # 加入人物信息
|
| | | if not loadOK:
|
| | | return GMCommon.Def_NoTag, ""
|
| | | 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]
|
| | |
| | |
|
| | | itemList = []
|
| | | # 无物品
|
| | | if itemFind.count() <= 0:
|
| | | return GMCommon.Def_Success, itemList
|
| | | |
| | | if itemFind.count() > 0:
|
| | | 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']:
|
| | | if packIndex != itemDict['ItemPlaceType']:
|
| | | continue
|
| | | |
| | | 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,
|
| | |
| | | # "IsLocked" : 0,
|
| | | # "SID" : -1135840175,
|
| | | # "VerNO" : NumberLong(1),
|
| | | |
| | | curItemInfo = {}
|
| | | for k, v in itemDict.items():
|
| | | if k in ["UserDataLen", "ItemPlaceType", "PlayerID", "IsLocked", "SID", "VerNO"]:
|
| | |
| | | continue
|
| | | curItemInfo[k] = v
|
| | |
|
| | | return curItemInfo
|
| | | itemList.append(curItemInfo)
|
| | | |
| | | return itemList
|