hxp
2025-06-03 4cdd576855c6e22d986ece4b18f7c80d82cefe38
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.PlayerBossReborn
#
# @todo:BOSS¸´»î
# @author xdh
# @date 2018-07-12 16:50
# @version 1.0
#
#
# ÏêϸÃèÊö: BOSS¸´»î
#
#---------------------------------------------------------------------
"""Version = 2018-07-12 16:50"""
#---------------------------------------------------------------------
 
import IPY_GameWorld
import GameWorld
import ChConfig
import IpyGameDataPY
import PlayerControl
import ItemControler
import ChPyNetSendPack
import NetPackCommon
import ShareDefine
import PyGameData
import ItemCommon
 
 
def OnLogin(curPlayer):
    isReset = __CheckPlayerBossRebornAction(curPlayer)
    if not isReset:
        actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {})
        # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢
        if actCostRebateInfo.get(ShareDefine.ActKey_State):
            SyncBossRebornInfo(curPlayer)
            SyncBossRebornPlayerInfo(curPlayer)
    return
 
 
def RefreshOperationAction_BossReborn():
    playerManager = GameWorld.GetPlayerManager()
    for i in xrange(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(i)
        if not GameWorld.IsNormalPlayer(curPlayer):
            continue
        __CheckPlayerBossRebornAction(curPlayer)
    return
 
 
def __CheckPlayerBossRebornAction(curPlayer):
    ## ¼ì²éÍæ¼ÒBOSS¸´»î»î¶¯Êý¾ÝÐÅÏ¢
    playerID = curPlayer.GetPlayerID()
    
    actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {})
    bossRebornID = actBossRebornInfo.get(ShareDefine.ActKey_ID, 0)
    state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0)
    cfgID = actBossRebornInfo.get(ShareDefine.ActKey_CfgID, 0)
    
    playerBossRebornID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornID)  # Íæ¼ÒÉíÉϵĻID
    
    # »î¶¯ID ÏàͬµÄ»°²»´¦Àí
    if bossRebornID == playerBossRebornID:
        #GameWorld.DebugLog("BOSS¸´»î»î¶¯ID²»±ä£¬²»´¦Àí£¡", curPlayer.GetPlayerID())
        return
    actWorldLV = actBossRebornInfo.get(ShareDefine.ActKey_WorldLV, 0)
    playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
    
    templateID = 0
    if cfgID:
        actBossIpyData = IpyGameDataPY.GetIpyGameData("ActBossReborn", cfgID)
        templateID = 0 if not actBossIpyData else actBossIpyData.GetTemplateID()
    playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
    
    GameWorld.DebugLog("BOSS¸´»îÖØÖÃ! costRebateID=%s,playerCostRebateID=%s,state=%s,templateID=%s,playerTemplateID=%s" 
                       % (bossRebornID, playerBossRebornID, state, templateID, playerTemplateID), playerID)
    
    # Î´ÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
    __SendBossRebornMail(curPlayer, playerTemplateID, playerWorldLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionWorldLV, actWorldLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BossRebornID, bossRebornID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BossRebornTemplateID, templateID)
    for brid in ChConfig.BossRebornActIDList:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionCurTimes % brid, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionGotTimes % brid, 0)
        
    SyncBossRebornInfo(curPlayer)
    SyncBossRebornPlayerInfo(curPlayer)
    return True
 
 
def __SendBossRebornMail(curPlayer, playerTemplateID, playerWorldLV):
    # Î´ÁìÈ¡µÄ½±ÀøÓʼþ·¢·Å
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("BossReborn", {'TemplateID':playerTemplateID}, True)
    if not ipyDataList:
        return
    
    totalItemDict = {}
    for ipyData in ipyDataList:
        brid = ipyData.GetID()
        singleTimes = ipyData.GetSingleTimes()
        curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % brid)
        gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % brid)
        canGotCnt = (curTimes - gotTimes) / singleTimes
        if not canGotCnt:
            continue
        itemDict = __GetAwardItem(curPlayer, ipyData, playerWorldLV, canGotCnt)
        GameWorld.AddDictValue(totalItemDict, itemDict)
    
    #È¥µô¸´»îµãµÀ¾ß
    totalItemDict.pop(ChConfig.Def_ItemID_BossReborn, 0)
    if not totalItemDict:
        return
    totalItemList = [[itemID, itemCnt, 1] for itemID, itemCnt in totalItemDict.items()]
    PlayerControl.SendMailByKey('BossFHUnGetMail', [curPlayer.GetID()], totalItemList)
    return
 
 
def AddBossRebornActionCnt(curPlayer, actionID, addCnt=1):
    '''Ôö¼Óboss¸´»îÏà¹Ø»î¶¯Íê³É´ÎÊý'''
    #ÅжϻÊÇ·ñ¿ªÆô
    actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {})
    state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0)
    if not state:
        return
    playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
    ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', playerTemplateID, actionID)
    if not ipyData:
        return
    totalTimes = ipyData.GetTotalTimes()
    curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actionID)
    addCnt = addCnt if totalTimes == 0 else min(totalTimes - curTimes, addCnt)
    if addCnt <= 0:
        return
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionCurTimes % actionID, curTimes + addCnt)
    
    SyncBossRebornPlayerInfo(curPlayer, actionID)
    return
 
 
def GetBossRebornActionAward(curPlayer, actionID):
    '''ÁìÈ¡boss¸´»î»î¶¯½±Àø'''
    playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BossRebornTemplateID)
    ipyData = IpyGameDataPY.GetIpyGameData('BossReborn', playerTemplateID, actionID)
    if not ipyData:
        return
    singleTimes = ipyData.GetSingleTimes()
    curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actionID)
    gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % actionID)
    if curTimes - gotTimes < singleTimes:
        return
    playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
    #¸ø½±Àø
    awardDict = __GetAwardItem(curPlayer, ipyData, playerWorldLV)
    # ¼ì²é±³°ü
    needSpace = len(awardDict)
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    if needSpace > packSpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
        return
    #¸üдÎÊý Ã¿´ÎÁì½±Ö»ÁìÒ»´Î
    newGotTimes = gotTimes + singleTimes
    
    #GameWorld.Log('  actionID=%s,curTimes=%s,gotTimes=%s,singleTimes=%s,newGotTimes=%s'%(actionID, curTimes, gotTimes,singleTimes, newGotTimes))
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BRActionGotTimes % actionID, newGotTimes)
    for itemID, itemCnt in awardDict.items():
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
    SyncBossRebornPlayerInfo(curPlayer, actionID)
    return
 
 
def __GetAwardItem(curPlayer, ipyData, worldLV, times=1):
    awardDict = {}
 
    awardList = GameWorld.GetDictValueByRangeKey(ipyData.GetReward(), worldLV, [])
    for itemID, itemCnt, isbind in awardList:
        if not itemID or not itemCnt:
            continue
        awardDict[itemID] = awardDict.get(itemID, 0) + itemCnt * times
        
    return awardDict
 
 
def SyncBossRebornPlayerInfo(curPlayer, actID=-1):
    #֪ͨµ±Ç°´ÎÊý¡¢ÒÑÁì´ÎÊý 
    packData = ChPyNetSendPack.tagMCBossRebornPlayerInfo()
    packData.DataList = []
    if actID != -1:
        syneActIDList = [actID]
    else:
        syneActIDList = []
        ipyMgr = IpyGameDataPY.IPY_Data()
        for i in xrange(ipyMgr.GetBossRebornCount()):
            ipyData = ipyMgr.GetBossRebornByIndex(i)
            syneActIDList.append(ipyData.GetID())
     
    for actid in syneActIDList:
        curTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionCurTimes % actid)
        gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionGotTimes % actid)
        tiemInfo = ChPyNetSendPack.tagMCBossRebornData()
        tiemInfo.ActID = actid
        tiemInfo.CurTimes = curTimes
        tiemInfo.GotTimes = gotTimes
        packData.DataList.append(tiemInfo)
    
    packData.Count = len(packData.DataList)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return
 
 
def SyncBossRebornInfo(curPlayer):
    actBossRebornInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_BossReborn, {})
    state = actBossRebornInfo.get(ShareDefine.ActKey_State, 0)
    cfgID = actBossRebornInfo.get(ShareDefine.ActKey_CfgID, 0)
    if not state or not cfgID:
        return
    actBossIpyData = IpyGameDataPY.GetIpyGameData("ActBossReborn", cfgID)
    if not actBossIpyData:
        return
    templateID = actBossIpyData.GetTemplateID()
    if not templateID:
        return
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("BossReborn", {'TemplateID':templateID}, True)
    if not ipyDataList:
        return
    worldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BRActionWorldLV)
    startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(actBossIpyData)
    actInfo = ChPyNetSendPack.tagMCBossRebornInfo()
    actInfo.Clear()
    actInfo.StartDate = startDateStr
    actInfo.EndtDate = endDateStr
    actInfo.ResetType = actBossIpyData.GetResetType()
    actInfo.LimitLV = actBossIpyData.GetLVLimit()
    actInfo.TaskInfo = []
    for ipyData in ipyDataList:
        taskInfo = ChPyNetSendPack.tagMCBossRebornTaskInfo()
        taskInfo.TaskID = ipyData.GetID()
        taskInfo.TotalTimes = ipyData.GetTotalTimes()
        taskInfo.SingleTimes = ipyData.GetSingleTimes()
        taskInfo.AwardItem = []
        awardList = GameWorld.GetDictValueByRangeKey(ipyData.GetReward(), worldLV, [])
        for itemID, itemCnt, isBind in awardList:
            awardItem = ChPyNetSendPack.tagMCBossRebornAwardItem()
            awardItem.ItemID = itemID
            awardItem.ItemCount = itemCnt
            awardItem.IsBind = isBind
            taskInfo.AwardItem.append(awardItem)
        taskInfo.AwardItemCount = len(taskInfo.AwardItem)
        actInfo.TaskInfo.append(taskInfo)
    actInfo.TaskCnt = len(actInfo.TaskInfo)
    NetPackCommon.SendFakePack(curPlayer, actInfo)
    return
 
def DoBossRebornActionBossOnKilledLogic(npcRankHurtMgr):
    ## boss¸´»î»î¶¯boss±»»÷ɱ
    #  @param rankHurtList: NPCHurtMgr.PlayerRankHurtList
    
    npcID = npcRankHurtMgr.npcID
    
    GameWorld.Log("Boss¸´»î»î¶¯boss±»»÷ɱ: npcID=%s" % (npcID))
    rankItemDict = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 2) # {Ãû´Î:[[ÎïÆ·ID,¸öÊý,ÊÇ·ñÅÄÆ·], ...], ...}
    
    for index in xrange(npcRankHurtMgr.GetHurtCount()):
        rank = index + 1
        hurtObj = npcRankHurtMgr.GetHurtAt(index)
        if hurtObj.GetValueType() != ChConfig.Def_NPCHurtTypePlayer:
            continue
        playerID = hurtObj.GetValueID()
        rankItemList = GameWorld.GetOrderValueByDict(rankItemDict, rank)
        GameWorld.Log("    ÅÅÐÐÍæ¼Ò½±Àø: rank=%s,rankItemList=%s" % (rank, rankItemList), playerID)
        if not rankItemList:
            continue
        paramList = [npcID, rank]
        PlayerControl.SendMailByKey("BossRebornActionBossRank", [playerID], rankItemList, paramList)
        
    entireMailItemList = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 1) # [[ÎïÆ·ID,¸öÊý,ÊÇ·ñÅÄÆ·], ...]
    if entireMailItemList:
        getDays, limitLV, limitLVType = IpyGameDataPY.GetFuncEvalCfg("BossRebornServerBoss", 4)
        paramList = [npcID]
        #ɾ³ý¾É°æ·¢ËÍÓʼþ£¬Èç¹û¹¦ÄÜ»¹ÓÐÐèÒª£¬¿ÉʹÓÃа汾·¢ËÍÓʼþ PlayerMail
        
    return