#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_GetPlayerInfo # # @todo:²é¿´Íæ¼Ò # @author hxp # @date 2025-12-12 # @version 1.0 # # ÏêϸÃèÊö: ²é¿´Íæ¼Ò # #------------------------------------------------------------------------------- #"""Version = 2025-12-12 15:00""" #------------------------------------------------------------------------------- import GMCommon from Collections.CollectionDefine import (UCN_DSAccount, UCN_RoleNomalDict) from Collections import (DataServerPlayerData) import PlayerControl import IPY_GameWorld import ShareDefine import PyGameData import ChConfig CurrencyMoneyTypeList = [ShareDefine.TYPE_Price_PayCoin, ShareDefine.TYPE_Price_PayCoinDay, ShareDefine.TYPE_Price_Xiantao, ShareDefine.TYPE_Price_Lingyu] ## ÊÕµ½gmÃüÁîÖ´ÐÐ # @param gmCmdDict:gmÃüÁî×Öµä # @return None def OnExec(gmCmdDict): from GMToolLogicProcess import ProjSpecialProcess Result, curPlayer = ProjSpecialProcess.GMCmdPlayerValidation(gmCmdDict, False) if Result == GMCommon.Def_PlayerOfLine: dbPlayer = curPlayer playerInfo = __getPlayerInfoByDB(dbPlayer) elif Result == GMCommon.Def_Success: playerInfo = __getPlayerInfoByPlayer(curPlayer) else: return Result return GMCommon.Def_Success, playerInfo def __getPlayerInfoByPlayer(curPlayer): ## ´ÓÔÚÏßÈ¡ if not curPlayer: return {} playerInfo = { 'AccID':curPlayer.GetAccID(), # Õ˺Š'AccState':curPlayer.GetAccState(), # Õ˺Å״̬ 'PlayerID':curPlayer.GetPlayerID(), 'Name':curPlayer.GetPlayerName(), # Íæ¼ÒÃû 'GMLV':curPlayer.GetGMLevel(), #gmµÈ¼¶ 'Job':curPlayer.GetJob(), # Ö°Òµ 'LV':curPlayer.GetLV(), #Íæ¼ÒµÈ¼¶ 'OfficialRank':curPlayer.GetOfficialRank(), #¾³½ç 'FightPower':PlayerControl.GetFightPower(curPlayer), #Õ½¶·Á¦ #'VIPLV':curPlayer.GetVIPLv(), # vipµÈ¼¶ 'MapID':curPlayer.GetMapID(), #µ±Ç°µØÍ¼id 'Gold':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money), # Ôª±¦ #'GoldPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper), # °ó×ê #'Silver':PlayerControl.GetSilver(curPlayer), # ÒøÁ½ #'SilverPaper':PlayerControl.GetMoneyReal(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Paper), # ÉñÓñ 'FamilyName':curPlayer.GetFamilyName(), # ¼Ò×åÃû³Æ 'LogoffTime':curPlayer.GetLogoffTime(), #ÀëÏßʱ¼ä 'LoginTime':curPlayer.GetLoginTime(), # ÉÏÏßʱ¼ä 'LoginIP':curPlayer.GetIP(), #µÇÈëIP 'ClientVersion':curPlayer.GetAccountData().GetClientVersion(), #¿Í»§¶Ë°æ±¾ºÅ 'Online':1, 'ExAttr1':curPlayer.GetExAttr1(), #¹ý¹Ø½ø¶È 'TreeLV':curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLV) # ×£¸£ÊýµÈ¼¶ } # ÐèÒª¶îÍâͬ²½µÄ×Ô¶¨Òå»õ±Ò CurrencyValueDict = {} for moneyType in CurrencyMoneyTypeList: CurrencyValueDict['PlayerCurrency_%s' % moneyType] = PlayerControl.GetMoneyReal(curPlayer, moneyType) playerInfo.update(CurrencyValueDict) return playerInfo def __getPlayerInfoByDB(dbPlayer): if not dbPlayer: return {} accID = dbPlayer.AccID userdb = PyGameData.g_usrCtrlDB.db accountData = DataServerPlayerData.tagDSAccount() accountData.ACCID = accID accountData.adoLoad(userdb[UCN_DSAccount]) roleDict = {} moneyMinusDict = {} collection = userdb[UCN_RoleNomalDict] docs = collection.find({'PlayerID':dbPlayer.PlayerID}) if docs.count(): obj = DataServerPlayerData.tagRoleNomalDict() doc = list(docs)[0] #ÓÐÊý¾Ý if doc.has_key('__PackSave'): for i in xrange(doc['Count']): obj.readRecord(doc['%s'%(i+1)]) if obj.DictName.startswith("MoneyMinus_") and obj.DictValue > 0: moneyMinusDict[int(obj.DictName[len("MoneyMinus_"):])] = -obj.DictValue # »õ±Ò¸ºÖµ if 1 in moneyMinusDict and 2 in moneyMinusDict and 4 in moneyMinusDict: break if obj.DictValue > 0: roleDict[obj.DictName] = obj.DictValue playerInfo = { 'AccID':dbPlayer.AccID, # Õ˺Š'AccState':dbPlayer.AccState, # Õ˺Å״̬ 'PlayerID':dbPlayer.PlayerID, 'Name':dbPlayer.PlayerName, # Íæ¼ÒÃû 'GMLV':dbPlayer.GMLevel, #gmµÈ¼¶ 'Job':dbPlayer.Job, # Ö°Òµ 'LV':dbPlayer.LV, #Íæ¼ÒµÈ¼¶ 'OfficialRank':dbPlayer.OfficialRank, #¾³½ç 'FightPower':dbPlayer.FightPowerEx * 100000000 + dbPlayer.FightPower, #Õ½¶·Á¦ #'VIPLV':dbPlayer.VIPLv, # vipµÈ¼¶ 'MapID':dbPlayer.MapID, #µ±Ç°µØÍ¼id 'Gold':moneyMinusDict[1] if 1 in moneyMinusDict else dbPlayer.Gold, # Ôª±¦ #'GoldPaper':moneyMinusDict[2] if 2 in moneyMinusDict else dbPlayer.GoldPaper, # °ó×ê #'Silver':dbPlayer.Silver, # ÒøÁ½ #'SilverPaper':moneyMinusDict[4] if 4 in moneyMinusDict else dbPlayer.SilverPaper, # ÉñÓñ 'FamilyName':dbPlayer.FamilyName, # ¼Ò×åÃû³Æ 'LogoffTime':dbPlayer.LogoffTime, #ÀëÏßʱ¼ä 'LoginTime':dbPlayer.LoginTime, # ÉÏÏßʱ¼ä 'LoginIP':dbPlayer.LoginIP, #µÇÈëIP 'ClientVersion':accountData.ClientVersion, #¿Í»§¶Ë°æ±¾ºÅ 'Online':0, 'ExAttr1':dbPlayer.ExAttr1, #¹ý¹Ø½ø¶È 'TreeLV':roleDict.get(ChConfig.Def_PDict_TreeLV, 0) # ×£¸£ÊýµÈ¼¶ } # ÐèÒª¶îÍâͬ²½µÄ×Ô¶¨Òå»õ±Ò CurrencyValueDict = {} for moneyType in CurrencyMoneyTypeList: if moneyType == ShareDefine.TYPE_Price_PayCoin: moneyValue = dbPlayer.ExAttr11 else: moneyValue = roleDict.get("PlayerCurrency_%s" % moneyType, 0) CurrencyValueDict['PlayerCurrency_%s' % moneyType] = moneyValue playerInfo.update(CurrencyValueDict) return playerInfo