hxp
2023-09-29 2a659639d74889599ed54458863a2f7b31ff4eff
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package PlayerFamilyBoss
#
# @todo:¼Ò×åboss¸±±¾
# @author hxp
# @date 2014-04-16
# @version 1.0
#
# ÏêϸÃèÊö: ¼Ò×åboss¸±±¾
#
#---------------------------------------------------------------------
#"""Version = 2014-04-16 18:00"""
#---------------------------------------------------------------------
 
import PlayerFamilyAction
import GameWorld
import PlayerCompensation
import ChPyNetSendPack
import NetPackCommon
import ShareDefine
import IpyGameDataPY
import PlayerDBGSEvent
import PlayerControl
import ChConfig
import time
 
def FamilyBossFBOnWeek(curFamily):
    return
 
def FamilyBossFBOnDay(curFamily):
    __FamilyBossFBHurtOnDay(curFamily)
    return
 
def OnLogin(curPlayer):
    SyncFamilyBosFBInfo(curPlayer.GetFamilyID(), None, curPlayer)
    NotifyAllFamilyBossState(curPlayer)
    return
 
def OnPlayerJionFamily(curFamily, curPlayer):
    SyncFamilyBosFBInfo(curPlayer.GetFamilyID(), None, curPlayer)
    return
 
def __FamilyBossFBHurtOnDay(curFamily):
    familyID = curFamily.GetID()
    
    #²¹·¢ÏÉÃËÉËѪ½±Àø
    hurtValueTotal = 0
    memberHurtAwardStateDict = {}
    fActionType = ShareDefine.Def_ActionType_FamilyBossFB
    familyBossFBAction = GameWorld.GetFamilyActionManager().GetFamilyAction(familyID, fActionType)
    for index in range(familyBossFBAction.Count()):
        actionData = familyBossFBAction.At(index)
        playerID = actionData.GetValue1()
        
        if playerID == 1:
            hurtValueTotal = GetFamilyBossPlayerHurtValue(actionData)
        else:
            hurtAwardStateFamily = actionData.GetValue2()
            memberHurtAwardStateDict[playerID] = hurtAwardStateFamily
            
    #GameWorld.DebugLog("__FamilyBossFBHurtOnDay hurtValueTotal=%s,memberHurtAwardStateDict=%s" % (hurtValueTotal, memberHurtAwardStateDict), familyID)
    awardIpyDataList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for ipyIndex in range(ipyDataMgr.GetFamilyBossHurtAwardCount()):
        ipyData = ipyDataMgr.GetFamilyBossHurtAwardByIndex(ipyIndex)
        if ipyData.GetAwardType() != 2:
            continue
        needHurtTotal = ipyData.GetNeedHurtTotal()
        if hurtValueTotal < needHurtTotal:
            #GameWorld.DebugLog("    ÏÉÃËÉËѪ²»×㣬²»²¹·¢¸Ã½±Àø! needHurtTotal=%s" % needHurtTotal, familyID)
            continue
        awardIpyDataList.append(ipyData)
        
    offLineHourMax = 48
    for index in xrange(curFamily.GetCount()):
        member = curFamily.GetAt(index)
        playerID = member.GetPlayerID()
        offLineHour = GameWorld.GetPastHour(GameWorld.ChangeTimeNumToStr(member.GetExattr2())) if member.GetExattr2() > 1 else 0
        if offLineHour >= offLineHourMax:
            #GameWorld.DebugLog("    ÀëÏß¹ý¾Ã£¬²»²¹·¢. playerID=%s,offLineHour=%s" % (playerID, offLineHour), familyID)
            continue
        
        hurtAwardStateFamily = memberHurtAwardStateDict.get(playerID, 0)
        for ipyData in awardIpyDataList:
            recordIndex = ipyData.GetRecordIndex()
            if hurtAwardStateFamily & pow(2, recordIndex):
                #GameWorld.DebugLog("    ÒѾ­ÁìÈ¡¹ý£¬²»²¹·¢. playerID=%s,recordIndex=%s,%s" % (playerID, recordIndex, hurtAwardStateFamily), familyID)
                continue
            needHurtTotal = ipyData.GetNeedHurtTotal()
            paramList = [needHurtTotal]
            awardItemList = ipyData.GetAwardItemList()
            PlayerCompensation.SendMailByKey("FamilyBossHurtAwardFamily", [playerID], awardItemList, paramList)
            #GameWorld.DebugLog("    Óʼþ²¹·¢ÉËѪ½±Àø. playerID=%s,recordIndex=%s" % (playerID, recordIndex), familyID)
            
    # ×îºóÇå³ýaction
    PlayerFamilyAction.ClearFamilyAction(familyID, fActionType)
    SyncFamilyBosFBInfo(familyID, curFamily)
    return
 
def GetFamilyBossFBActionData(familyID, playerID=1):
    ## »ñÈ¡ÏÉÃËbossÉËѪaction
    # playerID  1-ÌØÊâÀàÐÍ£¬¼Ç¼ÏÉÃË×ÜÉ˺¦ÐÅÏ¢£»>1-Íæ¼ÒÏÉÃËÉËѪ½±ÀøÁì½±¼Ç¼
    
    findActionData = None
    fActionType = ShareDefine.Def_ActionType_FamilyBossFB
    familyBossFBAction = GameWorld.GetFamilyActionManager().GetFamilyAction(familyID, fActionType)
    for index in range(familyBossFBAction.Count()):
        actionData = familyBossFBAction.At(index)
        if playerID == actionData.GetValue1():
            findActionData = actionData
            break
            
    if not findActionData:
        findActionData = familyBossFBAction.AddAction()
        findActionData.SetFamilyId(familyID)
        findActionData.SetActionType(fActionType)
        findActionData.SetValue1(playerID)
        
    return findActionData
 
def GetFamilyBossPlayerHurtValue(actionData):
    return actionData.GetValue3() * ChConfig.Def_PerPointValue + actionData.GetValue2()
def SetFamilyBossPlayerHurtValue(actionData, hurtValue):
    actionData.SetValue2(hurtValue % ChConfig.Def_PerPointValue)
    actionData.SetValue3(hurtValue / ChConfig.Def_PerPointValue)
    return
 
def MapServer_FamilyBoss(msgList, tick):
    msgType, msgData = msgList
    
    # Í¬²½ÉËѪ
    if msgType == "FBMemberHurt":
        __addFBMemberHurtInfo(msgData)
        return
    
    # ÏÉÃËÉËѪÁì½±  - ÇëÇó
    if msgType == "FamilyHurtAwardReq":
        familyID = msgData[0]
        actionData = GetFamilyBossFBActionData(familyID)
        hurtValueTotal = GetFamilyBossPlayerHurtValue(actionData) if actionData else 0
        return msgList + [hurtValueTotal]
    
    # ÏÉÃËÉËѪÁì½±¼Ç¼ͬ²½ - ÓÃÓÚ¼ÓÈëÏÉÃËʱ£¬Í¬²½µ½GameServer£¬·½±ãͳһ´¦Àí²¹·¢½±Àø
    if msgType == "FamilyHurtAwardStateFamily":
        familyID, playerID, hurtAwardStateFamily = msgData
        actionData = GetFamilyBossFBActionData(familyID, playerID)
        actionData.SetValue2(hurtAwardStateFamily)
        return
    
    return
 
def __addFBMemberHurtInfo(msgData):
    ## Ôö¼ÓÏÉÃËbossÏÉÃË×ÜÉËѪ
    statsType, familyID, fightMemCount, addFamilyHurt = msgData
    curFamily = GameWorld.GetFamilyManager().FindFamily(familyID)
    if not curFamily:
        return
    
    actionData = GetFamilyBossFBActionData(familyID)
    if not actionData:
        return
    actionData.SetValue4(fightMemCount)
    
    hurtValueTotal = GetFamilyBossPlayerHurtValue(actionData) + addFamilyHurt
    SetFamilyBossPlayerHurtValue(actionData, hurtValueTotal)
    
    #GameWorld.DebugLog("FamilyBossFBMemberHurt statsType=%s,familyID=%s,fightMemCount=%s,addFamilyHurt=%s,hurtValueTotal=%s" 
    #                   % (statsType, familyID, fightMemCount, addFamilyHurt, hurtValueTotal))
    
    if statsType:
        SyncFamilyBosFBInfo(familyID, curFamily)
    return
 
def SyncFamilyBosFBInfo(familyID, curFamily=None, curPlayer=None):
    if not familyID:
        return
    if not curFamily and not curPlayer:
        return
    actionData = GetFamilyBossFBActionData(familyID)
    if not actionData:
        return
    
    clientPack = ChPyNetSendPack.tagGCFamilyBosFBInfo()
    clientPack.Clear()
    clientPack.HurtTotal = actionData.GetValue2()
    clientPack.HurtTotalPoint = actionData.GetValue3()
    clientPack.FightMemCount = actionData.GetValue4()
    
    if curFamily:
        for i in range(0, curFamily.GetCount()):
            notifyMember = curFamily.GetAt(i)
            curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(notifyMember.GetPlayerID())        
            if curPlayer == None:
                continue
            NetPackCommon.SendFakePack(curPlayer, clientPack)
        return
    
    if curPlayer:
        NetPackCommon.SendFakePack(curPlayer, clientPack)
        
    return
 
#############################¶àÏÉÃËBOSS#############################
 
def OnAllFamilyBossStateChange(isOpen):
    if isOpen:
        #±¾´Î¿ªÆôʱ¼ä¾àÀëÉϴλ÷ɱʱ¼ä³¬¹ý1СʱÔòÖØÖÃ
        lastKillTime = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_AllFamilyBossTime)
        curTime = int(time.time())
        if abs(curTime-lastKillTime)> 3600:
            PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_AllFamilyBossTime, 0)
            #֪ͨ
            NotifyAllFamilyBossState()
    return
 
def AllFamilyBossKilled():
    if PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_AllFamilyBossTime):
        GameWorld.Log('¶àÏÉÃËBossÒѱ»»÷ɱ£¬²»¿ÉÖØ¸´£¡£¡')
        return
    curTime = int(time.time())
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_AllFamilyBossTime, curTime)
    GameWorld.Log('¶àÏÉÃËBoss±»»÷ɱ!!')
    NotifyAllFamilyBossState()
    return
 
def NotifyAllFamilyBossState(curPlayer=None):
    lastKillTime = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_AllFamilyBossTime)
    bossInfo = ChPyNetSendPack.tagGCAllFamilyBossInfo()
    bossInfo.IsEnd = 1 if lastKillTime else 0
    
    if curPlayer == None:
        playerManager = GameWorld.GetPlayerManager()
        for i in xrange(playerManager.GetActivePlayerCount()):
            curPlayer = playerManager.GetActivePlayerAt(i)
            if curPlayer == None or not curPlayer.GetInitOK():
                continue
            if PlayerControl.GetIsTJG(curPlayer):
                continue
            NetPackCommon.SendFakePack(curPlayer, bossInfo)
    else:
        if PlayerControl.GetIsTJG(curPlayer):
            return
        NetPackCommon.SendFakePack(curPlayer, bossInfo)
    return
 
#ÊÇ·ñÔÚÏÉÃËBOSS»î¶¯ÖÐ
def IsInAllFamilyBoss(lineID=-1):
    state1 = GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyBoss1)
    return state1