hxp
6 天以前 acebf38b40565a700efeecddb2e3f6e2b2e183a6
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/GMToolLogicProcess/Commands/GMT_GetPlayerInfo.py
@@ -1,109 +1,107 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_GetPlayerInfo.py
# GM命令,获得玩家信息
##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_GetPlayerInfo
#
# @author wdb
# @date 2012-6-14
# @version 1.6
# @todo:查看玩家
# @author hxp
# @date 2025-12-12
# @version 1.0
#
# @note
# @change: "2012-06-21 15:30" wdb int修改到GMCommon开接口
# @change: "2012-07-12 18:00" wdb 增加编码属性
# @change: "2012-07-30 11:30" wdb GM回复细化,代码优化
# @change: "2012-08-10 17:00" whx 增加仓库密码
# @change: "2015-01-30 02:00" hxp 增加转生次数、转生等级、绑钻信息
# @change: "2015-05-22 14:30" hxp 增加大师等级、战斗力
#---------------------------------------------------------------------
"""Version = 2015-05-22 14:30"""
#---------------------------------------------------------------------
#导入
from Collections import DataServerPlayerData
from MangoDBCommon import fix_incomingText
from Collections.CollectionDefine import *
import GMCommon
#---------------------------------------------------------------------
#全局变量
# 详细描述: 查看玩家
#
#-------------------------------------------------------------------------------
#"""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):
    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, ''
    return GMCommon.Def_DoQueryUserDB, '%s'%GMCommon.Def_GMKey_PlayerName
    if Result == GMCommon.Def_PlayerOfLine:
        dbPlayer = curPlayer
        playerInfo = __getPlayerInfoByDB(dbPlayer)
    
## 查询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, ''
    elif Result == GMCommon.Def_Success:
        playerInfo = __getPlayerInfoByPlayer(curPlayer)
        
    else:
        # queryType为accID,发送的信息就是玩家的AccID
        playerAccID = playerFind
        return Result
    
    # 返回playerid,判断是否在线
    if data == '%s'%GMCommon.Def_GMKey_PlayerName:
        return GMCommon.Def_DoQueryLogDB, playerAccID
    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 = playerAccID
    accountData.ACCID = accID
    accountData.adoLoad(userdb[UCN_DSAccount])
    collection = userdb[UCN_DBPlayer]
    dbPlayer = DataServerPlayerData.tagDBPlayer()
    dbPlayer.IsDeleted = 0
    loadOK = dbPlayer.adoLoadCEx(collection, {'AccID':fix_incomingText(playerAccID),
                                                 'IsDeleted':dbPlayer.IsDeleted})
    if not loadOK:
        # 回复gm
        return GMCommon.Def_NoTag, ''
    
    roleDict = {}
    moneyMinusDict = {}
@@ -134,13 +132,13 @@
                  'LV':dbPlayer.LV,  #玩家等级
                  'OfficialRank':dbPlayer.OfficialRank,  #境界
                  'FightPower':dbPlayer.FightPowerEx * 100000000 + dbPlayer.FightPower,  #战斗力
                  'VIPLV':dbPlayer.VIPLv,  # vip等级
                  #'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,   # 神玉
                  #'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,  # 家族名称
                  
@@ -150,19 +148,19 @@
                  'ClientVersion':accountData.ClientVersion,  #客户端版本号
                  
                  'Online':0,
                  'ExAttr1':dbPlayer.ExAttr1, #过关进度
                  'TreeLV':roleDict.get(ChConfig.Def_PDict_TreeLV, 0) # 祝福数等级
                  }
    
    # 需要额外同步的自定义货币
    CurrencyValueDict = {}
    for moneyType in [99, 98]:
        if moneyType == 99:
    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 GMCommon.Def_Success, playerInfo
    return playerInfo