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
167
168
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package GMT_GetPlayerInfo.py
# GMÃüÁ»ñµÃÍæ¼ÒÐÅÏ¢
#
# @author wdb
# @date 2012-6-14
# @version 1.6
#
# @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
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
 
#---------------------------------------------------------------------
 
## ÊÕµ½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
    
    # ·µ»Øplayerid£¬ÅжÏÊÇ·ñÔÚÏß
    if data == '%s'%GMCommon.Def_GMKey_PlayerName:        
        return GMCommon.Def_DoQueryLogDB, playerAccID
 
    accountData = DataServerPlayerData.tagDSAccount()
    accountData.ACCID = playerAccID
    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 = {}
    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,
                  }
    
    # ÐèÒª¶îÍâͬ²½µÄ×Ô¶¨Òå»õ±Ò
    CurrencyValueDict = {}
    for moneyType in [99, 98]:
        if moneyType == 99:
            moneyValue = dbPlayer.ExAttr11
        else:
            moneyValue = roleDict.get("PlayerCurrency_%s" % moneyType, 0)
        CurrencyValueDict['PlayerCurrency_%s' % moneyType] = moneyValue
    playerInfo.update(CurrencyValueDict)
    return GMCommon.Def_Success, playerInfo