| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package GMT_PlayerItemInfo.py  | 
| # GMÃüÁî»ñµÃÍæ¼ÒÎïÆ·ÐÅÏ¢  | 
| #  | 
| # @author wdb  | 
| # @date 2012-6-14  | 
| # @version 1.4  | 
| #  | 
| # @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 *  | 
| import GMCommon  | 
| #---------------------------------------------------------------------  | 
| #È«¾Ö±äÁ¿  | 
| # ÎïÆ·userdataµÄ¶¨Òåkey  | 
| IudetEquipAddSkillList = 3  | 
| IudetEquipAddSkillCnt = 4  | 
| IudetWakeUpCnt = 12  | 
|   | 
| # ÏÔʾ˵Óб³°üÀàÐÍ  | 
| 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, ''  | 
|       | 
|     elif queryType == 'accID':  | 
|         return GMCommon.Def_DoQueryLogDB, ''  | 
|      | 
|     return GMCommon.Def_DoQueryUserDB, '%s'%GMCommon.Def_GMKey_PlayerName  | 
|           | 
|       | 
| ## ²éѯ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, ''  | 
|     else:  | 
|         # queryTypeΪaccID£¬·¢Ë͵ÄÐÅÏ¢¾ÍÊÇÍæ¼ÒµÄAccID  | 
|         playerAccID = playerFind  | 
|       | 
|     collection = userdb[UCN_DBPlayer]   | 
|     dbPlayer = DataServerPlayerData.tagDBPlayer()  | 
|     dbPlayer.IsDeleted = 0  | 
|   | 
|     loadOK = dbPlayer.adoLoadCEx(collection, {'AccID':fix_incomingText(playerAccID),  | 
|                                                   'IsDeleted':dbPlayer.IsDeleted})   | 
|     # ¼ÓÈëÈËÎïÐÅÏ¢  | 
|     resultMsg = {}  | 
|     if loadOK:  | 
|         resultMsg = {  | 
|                       'LogoffTime':dbPlayer.LogoffTime, #ÀëÏßʱ¼ä  | 
|                       'LoginTime':dbPlayer.LoginTime,  # ÉÏÏßʱ¼ä  | 
|                       'OnlineTime':dbPlayer.OnlineTime,  # ÀÛ¼ÆÉÏÏßʱ¼ä  | 
|                       'LoginIP':dbPlayer.LoginIP,  #µÇÈëIP  | 
|                     }  | 
|     else:  | 
|         return GMCommon.Def_NoTag, ''  | 
|           | 
|     # »ñµÃÍæ¼ÒÎïÆ·  | 
|     itemCollection = userdb[UCN_RoleItem]  | 
|     itemFind = itemCollection.find({'PlayerID':dbPlayer.PlayerID})  | 
|       | 
|     # ÎÞÎïÆ·  | 
|     if itemFind.count() <= 0:  | 
|         return GMCommon.Def_Success, resultMsg  | 
|       | 
|     itemList = []  | 
|     itemInfo = itemFind[0]  | 
|     packIndex = GMCommon.ToIntDef(gmCmdDict.get(GMCommon.Def_GMKey_PackIndex, ''))  | 
|       | 
|     # ±éÀúËùÓÐÎïÆ·  | 
|     for itemIndex in range(1, itemInfo['Count'] + 1):          | 
|         itemDict = itemInfo.get('%s'%itemIndex, {})  | 
|         # ÓÐÖ¸¶¨±³°üÀàÐÍ£¬Ôò¸ù¾Ý±³°üÀàÐ͹ýÂËÎïÆ·  | 
|         if packIndex != ShowAllPack and packIndex != itemDict['ItemPlaceType']:  | 
|             continue  | 
|           | 
|         itemList.append(_GetItemInfo(itemDict))  | 
|       | 
|     resultMsg['ItemList'] = itemList  | 
|       | 
|     # ²»´óÓëword  | 
|     if len(resultMsg) > pow(2, 14):  | 
|         return GMCommon.Def_MaxLimit, ''  | 
|           | 
|     # »Ø¸´²éѯÐÅÏ¢  | 
|     return GMCommon.Def_Success, resultMsg  | 
|   | 
|   | 
| ## »ñµÃÎïÆ·ÐÅÏ¢  | 
| # @param itemDict: ÎïÆ·ÐÅÏ¢×Öµä  | 
| # @return curItemInfo£ºµ±Ç°ÎïÆ·ÏÔʾÐÅÏ¢  | 
| def _GetItemInfo(itemDict):  | 
|   | 
|     stoneList = []  | 
|     hourCnt = itemDict['CanPlaceStoneCount']  | 
|     for hourIndex in range(1, hourCnt + 1):  | 
|         stoneList.append(itemDict['Stone%d'%hourIndex])  | 
|       | 
|     itemData = eval(itemDict['UserData'])  | 
|     curItemInfo = {  | 
|                 'PackType':itemDict['ItemPlaceType'],  # ±³°üÀàÐÍ  | 
|                 'ItemIndex':itemDict['ItemPlaceIndex'],   # Ë÷Òý  | 
|                 'GUID':itemDict['ItemGUID'],   # guid  | 
|                 'IsBand':itemDict['IsBind'],  # ÊÇ·ñ°ó¶¨  | 
|                 'ItemCnt':itemDict['Count'],   # ÊýÁ¿  | 
|                 'ItemID':itemDict['ItemTypeID'],   | 
|    | 
|                 'StarLV':itemDict['ItemStarLV'],  # ÐǼ¶  | 
|                 'Endure':itemDict['CurDurg'],   # µ±Ç°Ä;à  | 
|                 'MaxEndure':itemDict['MaxDurg'],  # ×î´óÄ;à  | 
|                 'IsSuite':itemDict['IsSuite'],  # ÊÇ·ñÌ××°  | 
|                 'HoleCnt':hourCnt,  # ¿×Êý   | 
|                 'StoneList':stoneList,  # ±¦Ê¯idÁÐ±í  | 
|                   | 
|                 'SkillCnt':itemData.get(IudetEquipAddSkillCnt, 0),  #ÁéÎÆÊý  | 
|                 'MaxSkillCnt':itemDict['MaxAddSkillCnt'],  # ×î´óÁéÎÆÊý  | 
|                 'SkillList':itemData.get(IudetEquipAddSkillList, []),  #¡¡¼¼ÄÜidÁÐ±í  | 
|                   | 
|                 'FitLV':itemDict['FitLV'],  # ÆõºÏµÈ¼¶  | 
|                 'Proficiency':itemDict['Proficiency'],  # ÊìÁ·¶È  | 
|                   | 
|                 'MinAtk':itemDict['EquipMinAtkValue'],  # ×îСÉ˺¦Öµ  | 
|                 'MaxAtk':itemDict['EquipMaxAtkValue'],  # ×î´óÉ˺¦Öµ  | 
|                 'Defense':itemDict['BaseMagicDef'],  # ·ÀÓùÖµ  | 
|                 'BaseHP':itemDict['BaseHP'],   # ÆøÑªÖµ  | 
|                 'MagicDef':itemDict['EquipMagicDefValue'],   # ÄÚ·ÀÖµ  | 
|                 'isWakeUp':itemData.get(IudetWakeUpCnt, 0),  # ÊÇ·ñ»½ÐÑ  | 
|                 }  | 
|     return curItemInfo  | 
|      |