hxp
2025-02-06 a90833bf05d8f4a338b0224a956a3794c106bb48
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
#!/usr/bin/python
# -*- coding: GBK -*-
 
##@package GMT_GetFamilyInfo
# GMÃüÁîÖ´ÐÐ->¼Ò×åÐÅÏ¢
#
# @author wdb
# @date 2012-06-14
# @version 1.3
#
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
# @note
# Ä£¿éÏêϸ˵
# @change: "2012-06-29 21:30" wdb ·µ»ØÐÅÏ¢ÊÇ·ñ¹ý³¤
# @change: "2012-07-12 18:00" wdb ×Ö·ûת»»ÔÚÈë¿Ú´¦Àí
# @change: "2016-09-07 03:00" hxp Ôö¼Ó²éѯȫ²¿Õ½ÃË£»Õ½Ã˲éѯ·µ»ØÐÅϢͳһ£»¾«È·²éѯ·µ»Ø³ÉÔ±ÏêÇé
#---------------------------------------------------------------------
#µ¼Èë
import GMCommon
import GameWorld
import PlayerFamily
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
#---------------------------------------------------------------------
VER = "2016-09-07 03:00" 
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ(ÕâÀïcurPlayer = None)
## Ö´ÐÐÂß¼­
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param gmList [cmdIndex gmAccID forbidAcc]
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnExec(orderId, gmCmdDict):
    
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')      
    familyName = gmCmdDict.get(GMCommon.Def_GMKey_FamilyName, '')
    
    familyInfo = []
    if queryType != 'all' and familyName == '':
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)
        return
    
    # È«Ãû²éѯ
    if queryType == 'normal':
        curFamily = GameWorld.GetFamilyManager().FindFamilyByName(familyName)
        familyInfo.append(GetQueryFamilyInfo(curFamily, True))
        
    # Ä£ºý²éѯ
    elif queryType == 'faintness':
        familyMgr = GameWorld.GetFamilyManager()
        sortFamilyIDList = PlayerFamily.GetSortFamilyIDList()
        for familyID in sortFamilyIDList:
            curFamily = familyMgr.FindFamily(familyID)
            if not curFamily:
                continue
            if familyName not in curFamily.GetName():
                continue
            familyInfo.append(GetQueryFamilyInfo(curFamily, False))
            
    # È«²¿
    elif queryType == 'all':
        familyMgr = GameWorld.GetFamilyManager()
        sortFamilyIDList = PlayerFamily.GetSortFamilyIDList()
        for familyID in sortFamilyIDList:
            curFamily = familyMgr.FindFamily(familyID)
            if not curFamily:
                continue
            familyInfo.append(GetQueryFamilyInfo(curFamily, False))
            
    if len(familyInfo) > pow(2, 14):
        #Êý¾Ý¹ý´ó
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_MaxLimit)   
        return
    
    #Ö´Ðгɹ¦
    GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success, familyInfo)        
    return
 
 
## »ñµÃÐèÒªµÄÐÅÏ¢
#  @param gmList 
#  @return None
def GetQueryFamilyInfo(curFamily, memberDetail):
    if curFamily == None:
        return {} 
    
    memberCnt = curFamily.GetCount()
    memberInfo = []
    onlineCnt = 0
    
    # ±éÀú˵ÓгÉÔ±
    for index in range(memberCnt):
        
        curMember = curFamily.GetAt(index)
        player = GameWorld.GetPlayerManager().FindPlayerByID(curMember.GetPlayerID())
        
        #¡¡ÊÇ·ñÔÚÏß
        if player != None:
            onlineCnt += 1
            
        if not memberDetail:
            continue
        
        offLineTime = curMember.GetExattr2()
        offLineSeconds = GameWorld.GetPastSeconds(GameWorld.ChangeTimeNumToStr(offLineTime)) if offLineTime > 1 else offLineTime
        
        # ³ÉÔ±ÐÅÏ¢
        member = {
                  'Name':curMember.GetName(),
                  'LV':curMember.GetLV(),
                  'FamilyLV':curMember.GetFamilyLV(),
                  'ActiveValue':curMember.GetFamilyActiveValue(),
                  'OffLineSeconds':offLineSeconds, 
                  }
        memberInfo.append(member)
        
    familyInfo = {
                  'Rank':PlayerFamily.GetFamilyIDRank(curFamily.GetID()), # ÅÅÃû
                  'WarRank':PlayerFamily.GetFamilyWarRank(curFamily), # ÁªÈüÅÅÃû
                  'FightPower':PlayerFamily.GetFamilyTotalFightPower(curFamily), # ×ÜÕ½Á¦
                  'FamilyName':curFamily.GetName(),
                  'LeaderName':curFamily.GetLeaderName(),
                  'LV':curFamily.GetLV(),
                  'Broadcast':curFamily.GetBroadcast(),
                  'MemberCnt':memberCnt,
                  'OnLineCnt':onlineCnt,
                  'ServerID':curFamily.GetServerID(),
                  }
    if memberInfo:
        familyInfo['MemberInfo'] = memberInfo
        
    return familyInfo