hxp
2020-01-07 e37c0b9f504429962a92755c7a79926f092ed9af
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_KillDevil
#
# @todo:ÌÖ·¥Ñýħ
# @author hxp
# @date 2020-01-07
# @version 1.0
#
# ÏêϸÃèÊö: ÌÖ·¥Ñýħ£¬×é¶Ó/µ¥ÈË
#
#-------------------------------------------------------------------------------
#"""Version = 2020-01-07 19:00"""
#-------------------------------------------------------------------------------
 
import FBCommon
import EventShell
import PlayerAssist
import GameWorldProcess
import NPCCustomRefresh
import ItemControler
import IPY_GameWorld
import GameWorld
import ChConfig
 
(
Def_PrepareTime, # ×¼±¸Ê±¼ä, Ãë
Def_FightTime, # ¸±±¾Ê±¼ä, Ãë
Def_ExitTime, # Í˳öʱ¼ä, Ãë
) = range(3)
 
# ¸±±¾×´Ì¬
(
FB_Step_Open, #¿ªÆô
FB_Step_Prepare, #×¼±¸ÖÐ
FB_Step_Fight, # Õ½¶·ÖÐ
FB_Step_Over, # ½áÊøµÈ´ý
FB_Step_Close, # ¹Ø±ÕÖÐ
) = range(5)
 
FBDict_FBBossID = "FBBossID" # ¸±±¾bossID
FBDict_KillNPCCount = "KillNPCCount_%s" # ÒÑ»÷ɱNPCÊý£¬²ÎÊýnpcID
 
## ¿ªÆô¸±±¾
def OnOpenFB(tick):
    return
 
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
    teamID = curPlayer.GetTeamID()
    if teamID:
        if curPlayer.GetTeamLV() != IPY_GameWorld.tmlLeader:
            return True
        
    taskID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PiaomiaoMaxGradeTaskID)
    curMission = curPlayer.FindMission(taskID)
    if curMission == None:
        GameWorld.DebugLog("ûÓиø±±¾ÈÎÎñ£¬ÎÞ·¨½øÈë!taskID=%s" % taskID)
        return False
    missionState = curMission.GetMissionState()
    if missionState != IPY_GameWorld.msProcessing:
        GameWorld.DebugLog("¸Ã¸±±¾ÈÎÎñ·Ç½øÐÐÖУ¬ÎÞ·¨½øÈë!taskID=%s,missionState=%s" % (taskID, missionState))
        return False
    
    return True
 
## ¸±±¾Íæ¼Ò½øÈëµã
def OnGetFBEnterPos(curPlayer, mapID, lineID, ipyEnterPosInfo, tick):
    return ipyEnterPosInfo
 
## ÊÇ·ñ¿ÉÒÔ½øÈë
def OnChangeMapAsk(ask, tick):
    return IPY_GameWorld.cmeAccept
 
## Íæ¼Ò½øÈ븱±¾
def DoEnterFB(curPlayer, tick):
    mapID = GameWorld.GetGameWorld().GetMapID()
    mapID = FBCommon.GetRecordMapID(mapID)
    gameFB = GameWorld.GetGameFB()
    
    lineTimeCfg = FBCommon.GetFBLineStepTime(mapID)
    
    # ½øÈëÏûºÄ´¦Àí
    if not FBCommon.GetHadDelTicket(curPlayer):
        FBCommon.SetHadDelTicket(curPlayer)
        PlayerAssist.SetFBNoAssistPlayerID(curPlayer)
        
    fbStep = gameFB.GetFBStep()
    if fbStep == FB_Step_Open:
        FBCommon.SetFBStep(FB_Step_Prepare, tick)
        bossID = FBCommon.GetFBLineRefreshNPC(mapID)[1]
        gameFB.SetGameFBDict(FBDict_FBBossID, bossID)
        
    if fbStep <= FB_Step_Prepare:
        notify_tick = lineTimeCfg[Def_PrepareTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttAddUpTime, 0, max(notify_tick, 0), True)
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True)
        
    elif fbStep == FB_Step_Fight:
        notify_tick = lineTimeCfg[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)
        
    DoFBHelp(curPlayer, tick)
    return
 
## ¸±±¾°ïÖúÐÅÏ¢
def DoFBHelp(curPlayer, tick):
    playerID = curPlayer.GetPlayerID()
    gameFB = GameWorld.GetGameFB()
    npcID = gameFB.GetGameFBDictByKey(FBDict_FBBossID)
    killCount = gameFB.GetGameFBDictByKey(FBDict_KillNPCCount % npcID)
    #fbHelpDict = {FBCommon.Help_npcTotal:killCount}
    fbHelpDict = {FBCommon.Help_npc:FBCommon.GetJsonNPCKillList({npcID:killCount})}
    FBCommon.Notify_FBHelp(curPlayer, fbHelpDict)
    GameWorld.DebugLog("DoFBHelp %s" % str(fbHelpDict), playerID)
    return
 
## Íæ¼ÒÍ˳ö¸±±¾.
def DoExitFB(curPlayer, tick):
    return
 
## Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
def DoPlayerLeaveFB(curPlayer, tick):
    return
 
## ¹Ø±Õ¸±±¾
def OnCloseFB(tick):
    return
 
## Íæ¼Ò¸±±¾¸´»î
def DoFBOnReborn(curPlayer, rebornType, tick):
    return
 
## ¸±±¾¶¨Ê±Æ÷
def OnProcess(tick):
    fbStep = GameWorld.GetGameFB().GetFBStep()
 
    # ¸±±¾×¼±¸
    if fbStep == FB_Step_Prepare:
        __DoLogic_FB_Prepare(tick)
    elif fbStep == FB_Step_Fight:
        __ProcessFight(tick)
    elif fbStep == FB_Step_Over:
        __ProcessCloseFB(tick)
        
    return
 
## ¸±±¾×¼±¸
def __DoLogic_FB_Prepare(tick):
    #gameFB = GameWorld.GetGameFB()
    mapID = GameWorld.GetMap().GetMapID()
    fbCfg = FBCommon.GetFBLineStepTime(mapID)
    # ¼ä¸ôδµ½
    if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_PrepareTime] * 1000:
        return
    
    gameFB = GameWorld.GetGameFB()
    mapID = GameWorld.GetMap().GetMapID()
    refreshMark, bossID = FBCommon.GetFBLineRefreshNPC(mapID)
    gameFB.SetGameFBDict(FBDict_FBBossID, bossID)
    
    NPCCustomRefresh.SetNPCRefresh(refreshMark, [bossID])
    NPCCustomRefresh.ProcessAllNPCRefresh(tick) # Á¢¼´³ö·¢Ò»´Î±êʶµãË¢ÐÂ
    
    FBCommon.SetFBStep(FB_Step_Fight, tick)
    FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, fbCfg[Def_FightTime] * 1000)
    return
 
## ¸±±¾Õ½¶·
def __ProcessFight(tick):
    mapID = GameWorld.GetMap().GetMapID()
    fbCfg = FBCommon.GetFBLineStepTime(mapID)
    # ¼ä¸ôδµ½
    if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_FightTime] * 1000:
        return
    
    __DoKillDevilOver(False, tick)        
    return
    
## ¸±±¾¹Ø±Õ
def __ProcessCloseFB(tick):
    mapID = GameWorld.GetMap().GetMapID()
    fbCfg = FBCommon.GetFBLineStepTime(mapID)
    # ¼ä¸ôδµ½
    if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_ExitTime] * 1000:
        return
    
    GameWorldProcess.CloseFB(tick)
    FBCommon.SetFBStep(FB_Step_Close, tick)
    return
 
## Íæ¼ÒɱËÀNPC
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
    npcID = curNPC.GetNPCID()
    gameFB = GameWorld.GetGameFB()
    fbBossID = gameFB.GetGameFBDictByKey(FBDict_FBBossID)
    if npcID != fbBossID:
        return
    gameFB.SetGameFBDict(FBDict_KillNPCCount % npcID, gameFB.GetGameFBDictByKey(FBDict_KillNPCCount % npcID) + 1)
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    
    __DoKillDevilOver(True, tick)
    return
 
def __DoKillDevilOver(isPass, tick):
    # Õ½¶·³¬Ê±
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetFBStep() == FB_Step_Over:
        return
    FBCommon.SetFBStep(FB_Step_Over, tick)
    
    mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
    noAssistPlayerID, assistMoneyType, assistPlayerMoneyDict = PlayerAssist.OnFBAssistOver(mapID)
    exitTime = FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000
    rewardInfo = FBCommon.GetFBLineReward(mapID, 0)
    noAssistItemList, assistItemList = ([], []) if not rewardInfo else rewardInfo
    
    playerManager = GameWorld.GetMapCopyPlayerManager()
    playerCount = playerManager.GetPlayerCount()
    for index in xrange(playerCount):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not curPlayer:
            continue
        
        playerID = curPlayer.GetPlayerID()
        overDict = {FBCommon.Over_dataMapID:mapID, FBCommon.Over_isPass: int(isPass)}
        if isPass:
            itemList = []
            if playerID == noAssistPlayerID:
                itemList = noAssistItemList
                EventShell.EventRespons_FBEvent(curPlayer, "fb_pass_%s" % mapID)
                
            elif playerID in assistPlayerMoneyDict:
                addAssistMoney = assistPlayerMoneyDict[playerID]
                itemList = assistItemList
                overDict.update({FBCommon.Over_isAssist:1, FBCommon.Over_money:FBCommon.GetJsonMoneyList({assistMoneyType:addAssistMoney})})
            overDict[FBCommon.Over_itemInfo] = FBCommon.GetJsonItemList(itemList)
            
            if itemList:
                ItemControler.GivePlayerItemOrMail(curPlayer, itemList)
                
        GameWorld.DebugLog("overDict=%s" % overDict, playerID)
        FBCommon.Notify_FB_Over(curPlayer, overDict)
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, exitTime, True)
        
    return
 
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼­ÓÉÍâ²ã¾ö¶¨
def CheckCanAttackTagObjInFB(attacker, defender):
    return GameWorld.GetGameFB().GetFBStep() == FB_Step_Fight