#!/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  
 | 
  
 |