#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_PlayerItemInfo
|
#
|
# @todo:²é¿´Íæ¼ÒÎïÆ·
|
# @author hxp
|
# @date 2025-12-12
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ²é¿´Íæ¼ÒÎïÆ·
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2025-12-12 15:00"""
|
#-------------------------------------------------------------------------------
|
|
import GMCommon
|
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):
|
|
from GMToolLogicProcess import ProjSpecialProcess
|
Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False)
|
|
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)
|
|
elif Result == GMCommon.Def_Success:
|
itemList = __getPlayerItemByPlayer(curPlayer, packIndex)
|
|
else:
|
return Result
|
|
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
|
|
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:
|
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(curItemInfo)
|
|
return itemList
|