hxp
6 天以前 acebf38b40565a700efeecddb2e3f6e2b2e183a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/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