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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_ChaosDemon
#
# @todo:»ìÂÒÑýÓò
# @author xdh
# @date 2016-06-04 16:00
# @version 1.0
#
#
# ÏêϸÃèÊö: »ìÂÒÑýÓò
#
#---------------------------------------------------------------------
#"""Version = 2017-06-23 16:30"""
#---------------------------------------------------------------------
 
import FBCommon
import IPY_GameWorld
import GameWorldProcess
import GameWorld
import PlayerControl
import NPCCustomRefresh
import ItemControler
import IpyGameDataPY
import ChConfig
import ShareDefine
import ItemCommon
import PlayerSuccess
import FBHelpBattle
import EventReport
import PlayerWeekParty
 
import math
 
 
(
Def_PrepareTime, # ×¼±¸Ê±¼ä, Ãë
Def_FightTime, # ¸±±¾Ê±¼ä, Ãë
Def_ExitTime, # Í˳öʱ¼ä, Ãë
Def_StarTime, # ÐǼ¶¶ÔÓ¦ºÄʱÅäÖÃ, Ãë
) = range(4)
 
 
 
 
# ¸±±¾×´Ì¬
(
FB_Step_Open, #¿ªÆô
FB_Step_Prepare, #×¼±¸ÖÐ
FB_Step_Fight, # Õ½¶·ÖÐ
FB_Step_Over, # ½áÊøµÈ´ý
FB_Step_Close, # ¹Ø±ÕÖÐ
) = range(5)
 
 
ChaosDemon_FBNextRefreshStep = 'ChaosDemon_FBNextRefreshStep'   # Ë¢¹Ö½×¶ÎÊý
ChaosDemon_FBNPCCnt = 'ChaosDemon_FBNPCCnt'   # ¸±±¾Ê£Óà¹ÖÎïÊý
ChaosDemon_FBNPCNeedRefreshCnt = 'ChaosDemon_FBNPCNeedRefreshCnt'   # »¹ÐèˢеĹÖÎïÊý
ChaosDemon_FBNPCRefreshCnt = 'ChaosDemon_FBNPCRefreshCnt'   # µ±ÂÖˢеĹÖÎïÊý
 
ChaosDemon_FBStar = 'ChaosDemon_FBStar'   # µ±Ç°¸±±¾ÐǼ¶
 
 
 
 
 
## OnDay´¦Àí
#  @param curPlayer
#  @return None
def ChaosDemonOnDay(curPlayer):
    
    return
 
##---»ñµÃ¸±±¾Ë¢¹ÖÅäÖÃ---
#  @param None
#  @return ÅäÖÃÐÅÏ¢
def __GetChaosDemonnpcCfg():
    return IpyGameDataPY.GetFuncEvalCfg('ChaosDemonCfg')
 
 
 
##¿ªÆô¸±±¾
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks ¿ªÆô¸±±¾
def OnOpenFB(tick):
    
    return
 
 
##¹Ø±Õ¸±±¾
# @param tick Ê±¼ä´Á
# @return ÎÞÒâÒå
# @remarks 
def OnCloseFB(tick):
    return
 
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
#  @param curPlayer Íæ¼ÒʵÀý
#  @param mapID µØÍ¼ID
#  @param lineID Ïß·id
#  @param tick Ê±¼ä´Á
#  @return ²¼¶ûÖµ
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
    return True
 
 
 
##¸±±¾Íæ¼Ò½øÈëµã
# @param curPlayer Íæ¼ÒʵÀý
# @param mapID µØÍ¼ID
# @param lineId ·ÖÏßID
# @param tick Ê±¼ä´Á
# @return ×ø±êÁбí(X,Y)
# @remarks ¸±±¾Íæ¼Ò½øÈëµã
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
    return ipyEnterPosInfo
 
 
##ÊÇ·ñ¿ÉÒÔ½øÈë
# @param ask ÇëÇó½á¹¹Ìå
# @param tick Ê±¼ä´Á
# @return TChangeMapError
# @remarks ÑéÖ¤¼Ò×åÊÇ·ñÔÚ½ñÌìµÄ¼Ò×åÕ½±í
def OnChangeMapAsk(ask, tick):
    return IPY_GameWorld.cmeAccept
 
 
##Íæ¼Ò½øÈ븱±¾
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ÎÞÒâÒå
# @remarks Íæ¼Ò½øÈ븱±¾
def DoEnterFB(curPlayer, tick):
    mapID = GameWorld.GetGameWorld().GetMapID()
    mapID = FBCommon.GetRecordMapID(mapID)
    gameFB = GameWorld.GetGameFB()
    
    ChaosDemonCfg = FBCommon.GetFBLineStepTime(mapID)
    # ÉèÖø±±¾¹«¹²ÊôÐԵĵ¥¶À´¦Àí£¬·ÀÖ¹¶ÓÔ±½øÈëºó±»ÐÞ¸Ä
    if not FBCommon.GetHadSetFBPropertyMark():
        lineID = 0
        FBCommon.SetFBPropertyMark(lineID)
        if gameFB.GetFBStep() == FB_Step_Open:
            FBCommon.SetFBStep(FB_Step_Prepare, tick)
            gameFB.SetGameFBDict(ChaosDemon_FBNextRefreshStep, 0)
            gameFB.SetGameFBDict(ChaosDemon_FBNPCCnt, 0)
            gameFB.SetGameFBDict(ChaosDemon_FBNPCRefreshCnt, 0)
            
    GameWorld.DebugLog("ChaosDemon DoEnterFB lineID=%s£¡" % FBCommon.GetFBPropertyMark(), curPlayer.GetID())
    # ½øÈëÏûºÄ´¦Àí
    if not FBCommon.GetHadDelTicket(curPlayer):
        FBCommon.SetHadDelTicket(curPlayer)
        isHelpFight = False
        if FBCommon.SetIsHelpFight(curPlayer):
            isHelpFight = True
            GameWorld.DebugLog("ChaosDemon ÖúÕ½½øÈ븱±¾£¡", curPlayer.GetID())
        # Ôö¼ÓÍæ¼Ò½øÈ븱±¾´ÎÊý
        FBCommon.AddEnterFBCount(curPlayer, mapID, 1)
        joinType = FBCommon.GetFBJoinType(curPlayer, isHelpFight)
        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_ChaosDemon, 0, ChConfig.CME_Log_Start, joinType)
        PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_ChaosDemon, 1)
    
    fbStep = gameFB.GetFBStep()
    if fbStep <= FB_Step_Prepare:
        notify_tick = ChaosDemonCfg[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 = ChaosDemonCfg[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)
        __UpdChaosDemonFBStar(tick, True, curPlayer)
        
    FBHelpBattle.RefershTeamFBMemRelation(tick)
    #DoFBHelp(curPlayer, tick)
    return
 
## ×çÖä³Ç±¤Ë¢¹Ö
# @return: True-ÒÑͨ¹Ø
def __RefreshChaosDemonNextNPC():
    gameFB = GameWorld.GetGameFB()
    
    npcCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCCnt)
    needRefreshCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCNeedRefreshCnt)
    # »¹Óй֠or »¹Ã»Ë¢Í꣬²»Ö´ÐÐÏÂÒ»²¨Ë¢ÐÂ
    if npcCnt > 0 or needRefreshCnt > 0:
        return
    
    refreshStep = gameFB.GetGameFBDictByKey(ChaosDemon_FBNextRefreshStep)
   
    refreshNPCList = __GetChaosDemonnpcCfg()
    rMarkList = IpyGameDataPY.GetFuncEvalCfg('ChaosDemonCfg', 2)
    
    if refreshStep >= len(refreshNPCList) or refreshStep >= len(rMarkList):
        # ÒÑÊÇ×îºóÒ»²¨, Í¨¹Ø
        GameWorld.DebugLog("ÒÑÊÇ×îºóÒ»²¨, Í¨¹Ø")
        return True
    rMark = rMarkList[refreshStep]
    rNPCList = refreshNPCList[refreshStep]
    needRefreshCnt = 0
    for rNPCInfo in rNPCList:
        needRefreshCnt += rNPCInfo[1]
        
    gameFB.SetGameFBDict(ChaosDemon_FBNPCRefreshCnt, needRefreshCnt)
    gameFB.SetGameFBDict(ChaosDemon_FBNPCNeedRefreshCnt, needRefreshCnt)
    NPCCustomRefresh.SetNPCRefresh(rMark, rNPCList, needRefreshCnt, needRefreshCnt)
    
    # ¸üÐÂÏÂÒ»²¨½×¶ÎÖµ
    gameFB.SetGameFBDict(ChaosDemon_FBNextRefreshStep, refreshStep + 1)
    #gameFB.SetGameFBDict(ChaosDemon_GameStep, refreshStep + 1)
    return
 
 
##Íæ¼ÒÍ˳ö¸±±¾.
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
def DoExitFB(curPlayer, tick):
    GameWorld.DebugLog("ChaosDemon DoExitFB...", curPlayer.GetPlayerID())
    fbStep = GameWorld.GetGameFB().GetFBStep()
    if fbStep <= FB_Step_Fight:
        FBHelpBattle.RefershTeamFBMemRelation(tick, curPlayer.GetPlayerID())
    return
 
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
def DoPlayerLeaveFB(curPlayer, tick):
    GameWorld.DebugLog("ChaosDemon DoPlayerLeaveFB...", curPlayer.GetPlayerID())
    
    return
 
##Íæ¼Ò¸±±¾¸´»î
# @param curPlayer Íæ¼ÒʵÀý
# @param rebornType
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
def DoFBOnReborn(curPlayer, rebornType, tick):
    GameWorld.DebugLog("ChaosDemon DoFBOnReborn...rebornType=%s" % rebornType)
    #»Ø³Ç¸´»îÖØÖÃ
    
    return
 
## »ñÈ¡È볡Я´øÐÅÏ¢
#  @param curPlayer
#  @param lineId ·ÖÏß
#  @return ×Ö·ûÐÍ ½øÈëÐéÄâ·ÖÏßID
def GetPlayerResetWorldPosFBMsg(curPlayer, lineId):
    
    return ""
 
##¸±±¾¶¨Ê±Æ÷
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks ¸±±¾¶¨Ê±Æ÷
def OnProcess(tick):
    fbStep = GameWorld.GetGameFB().GetFBStep()
 
    # ¸±±¾×¼±¸
    if fbStep == FB_Step_Prepare:
        __DoLogic_FB_Prepare(tick)
    elif fbStep == FB_Step_Fight:
        __ProcessOverFight(tick)
        __UpdChaosDemonFBStar(tick)
    elif fbStep == FB_Step_Over:
        __ProcessCloseFB(tick)
        
    return
 
 
## ¸±±¾×¼±¸Âß¼­
#  @param 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
    FBHelpBattle.RefershTeamFBMemRelation(tick)
    __RefreshChaosDemonNextNPC()
    playerManager = GameWorld.GetMapCopyPlayerManager()
    for i in range(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(i)
        if not curPlayer:
            continue
        DoFBHelp(curPlayer, tick)
    
    FBCommon.SetFBStep(FB_Step_Fight, tick)
    FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, fbCfg[Def_FightTime] * 1000)
    return
 
## É±¹Ö½áÊø
#  @param tick
#  @return None
def __ProcessOverFight(tick):
    mapID = GameWorld.GetMap().GetMapID()
    FightTime = FBCommon.GetFBLineStepTime(mapID)[Def_FightTime]
    openTick = GameWorld.GetGameWorld().GetOpenFBTick()
    if max(0, FightTime * 1000 - (tick - openTick)) > 0:
        return
 
    __DoChaosDemonOver(False, tick)        
    return
    
## ¸±±¾¹Ø±Õ
#  @param tick
#  @return None
def __ProcessCloseFB(tick):
    gameFB = GameWorld.GetGameFB()
    mapID = GameWorld.GetMap().GetMapID()
    if tick - gameFB.GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000:
        return
    
    FBCommon.DoLogic_FBKickAllPlayer()
    GameWorldProcess.CloseFB(tick)
    FBCommon.SetFBStep(FB_Step_Close, tick)
    return
 
def __DoChaosDemonOver(isPass, tick):
    # Õ½¶·³¬Ê±
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetFBStep() == FB_Step_Over:
        return
    costTime = tick - GameWorld.GetGameFB().GetFBStepTick()
    FBCommon.SetFBStep(FB_Step_Over, tick)
    mapID = GameWorld.GetMap().GetMapID()
    mapID = FBCommon.GetRecordMapID(mapID)
    star = GameWorld.GetGameFB().GetGameFBDictByKey(ChaosDemon_FBStar)
    itemDict = IpyGameDataPY.GetFuncEvalCfg('ChaosDemonReward')
    rateDict = IpyGameDataPY.GetFuncEvalCfg('ChaosDemonReward', 2, {})
    giveExp = IpyGameDataPY.GetFuncCfg('ChaosDemonReward', 3)
    rate = rateDict.get(star, 0)
    prizeItemList = []
    for itemID, itemCnt in itemDict.items():
#        cnt = int(itemCnt*rate/100)
#        if cnt:
        prizeItemList.append([itemID, itemCnt, 1])
    prizeItemList += IpyGameDataPY.GetFuncEvalCfg('ChaosDemonReward', 4, {}).get(star, [])
    exitTime = FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000
    playerManager = GameWorld.GetMapCopyPlayerManager()
    playerCount = playerManager.GetPlayerCount()
    for index in xrange(playerCount):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not curPlayer:
            continue
        
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, exitTime, True)
        if not isPass:
            FBCommon.Notify_FB_Over(curPlayer, {FBCommon.Over_isPass: 0})
            continue
        overDict = {FBCommon.Over_grade:star,FBCommon.Over_dataMapID:mapID,FBCommon.Over_isPass:int(isPass), FBCommon.Over_costTime:costTime}
        isHelp = False
        if FBCommon.GetIsHelpFight(curPlayer):
            isHelp = True
        else:
            #¸ø½±Àø
            needSpace = len(prizeItemList)
            emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
            isSendMail = int(needSpace > emptySpace) # ÊÇ·ñ·¢ËÍÓʼþ
            if isSendMail:
                PlayerControl.SendMailByKey("ChaosDemonMail", [curPlayer.GetPlayerID()], prizeItemList)
                GameWorld.DebugLog("±³°ü¿Õ¼ä²»¹»£¬·¢ËÍÓʼþ: mailItemList=%s" % str(prizeItemList), curPlayer.GetPlayerID())
            else:
                for itemID, itemCnt, isBind in prizeItemList:
                    ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem], event=["ChaosDemon", False, {}])
            
            reExp = PlayerControl.GetPlayerReExp(curPlayer)
            addExp = int(eval(giveExp) * rate/100)
            PlayerControl.PlayerControl(curPlayer).AddExp(addExp)
            # Í¨Öª½á¹û
            overDict[FBCommon.Over_itemInfo] = FBCommon.GetJsonItemList(prizeItemList)
            exp = addExp % ChConfig.Def_PerPointValue
            expPoint = addExp / ChConfig.Def_PerPointValue
            overDict[FBCommon.Over_exp] = exp
            overDict[FBCommon.Over_expPoint] = expPoint
        
        FBCommon.Notify_FB_Over(curPlayer, overDict)
        #³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ChaosDemon, 1, [playerCount, star])
        GameWorld.DebugLog("__SendChaosDemonOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID())
    return      
 
 
    
##¸±±¾ÓÐNPCÕÙ³ö
# @param curNPC:
# @param tick:tick
# @return None
def DoFBRebornNPC(curNPC, tick):
    if curNPC.GetNPCID() not in __GetAllNPCIDList():
        return
    gameFB = GameWorld.GetGameFB()
    npcCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCCnt)
    needRefreshCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCNeedRefreshCnt)
    
    npcCnt += 1
    needRefreshCnt -= 1
    gameFB.SetGameFBDict(ChaosDemon_FBNPCCnt, npcCnt)
    gameFB.SetGameFBDict(ChaosDemon_FBNPCNeedRefreshCnt, needRefreshCnt)
    GameWorld.DebugLog("DoFBRebornNPC, npcID=%s,ChaosDemon_FBNPCCnt=%s,needRefreshCnt=%s" % (curNPC.GetNPCID(), npcCnt, needRefreshCnt))
    if needRefreshCnt <= 0:
        GameWorld.DebugLog("±¾²¨¹ÖÎïË¢ÐÂÍê±Ï£¡npcCnt=%s" % npcCnt)
    return
 
def __GetAllNPCIDList():
    refreshNPCList = __GetChaosDemonnpcCfg()
    npcIDList = []
    for rList in refreshNPCList:
        for npcid, npccnt in rList:
            npcIDList.append(npcid)
    return npcIDList
 
##Íæ¼ÒɱËÀNPC
# @param curPlayer:Íæ¼ÒʵÀý
# @param curNPC:µ±Ç°±»É±ËÀµÄNPC
# @param tick:ʱ¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
    if curNPC.GetNPCID() not in __GetAllNPCIDList():
        return
    gameFB = GameWorld.GetGameFB()
    npcCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCCnt)
    needRefreshCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCNeedRefreshCnt)
    
    npcCnt -= 1
    gameFB.SetGameFBDict(ChaosDemon_FBNPCCnt, npcCnt)
    
    GameWorld.DebugLog("DoFB_Player_KillNPC, npcID=%s,ChaosDemon_FBNPCCnt=%s,needRefreshCnt=%s" 
                       % (curNPC.GetNPCID(), npcCnt, needRefreshCnt))
    
    
    if npcCnt <= 0 and needRefreshCnt <= 0:
        GameWorld.DebugLog("±¾²¨ËùÓйÖÎïÒѱ»»÷ɱ£¡")
        isAllKilled = __RefreshChaosDemonNextNPC()
        if isAllKilled:
            __DoChaosDemonOver(True, tick)
    
 
    FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
    return
 
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼­ÓÉÍâ²ã¾ö¶¨
#  @param attacker ¹¥»÷·½
#  @param defender ·ÀÊØ·½
#  @return bool
def CheckCanAttackTagObjInFB(attacker, defender):
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetFBStep() != FB_Step_Fight:
        return False
    return True
    
## Íæ¼Ò¹¥»÷Íæ¼ÒÊÇ·ñÓгͷ£
#  @param atkPlayer: ¹¥»÷·½
#  @param defPlayer: ·ÀÊØ·½
#  @return Íæ¼Ò¹¥»÷Íæ¼ÒÊÇ·ñÓгͷ£
def DoFBAttackHasPunish(atkPlayer, defPlayer):
    return True
 
## ¸üе±Ç°¸±±¾ÐǼ¶
def __UpdChaosDemonFBStar(tick, isEnter=False, curPlayer=None):
    gameFB = GameWorld.GetGameFB()
    curStar = gameFB.GetGameFBDictByKey(ChaosDemon_FBStar)
    if curStar == 1:
        return curStar
    
    mapID = GameWorld.GetMap().GetMapID()
    useSecond = int(math.ceil((tick - gameFB.GetFBStepTick()) / 1000.0))
    chaosDemonCfg = FBCommon.GetFBLineStepTime(mapID)
    starTimeList = chaosDemonCfg[Def_StarTime]
    diffSecond = 0
    updStar = 1 # Ä¬ÈÏÖÁÉÙ1ÐÇ
    for star, starTime in enumerate(starTimeList, 2):
        if useSecond <= starTime:
            updStar = star
            diffSecond = starTime-useSecond
            
    if curStar == updStar and not isEnter:
        return curStar
        
    gameFB.SetGameFBDict(ChaosDemon_FBStar, updStar)
    
    GameWorld.DebugLog("__UpdFBStar useSecond=%s,curStar=%s,updStar=%s, diffSecond=%s" 
                       % (useSecond, curStar, updStar, diffSecond))
    
    if curPlayer:
        DoFBHelp(curPlayer, tick)
        if updStar != 1:
            curPlayer.Sync_TimeTick(IPY_GameWorld.tttFlagTake, 0, diffSecond * 1000, True)
    else:
        playerManager = GameWorld.GetMapCopyPlayerManager()
        for index in xrange(playerManager.GetPlayerCount()):
            curPlayer = playerManager.GetPlayerByIndex(index)
            if not curPlayer:
                continue
            DoFBHelp(curPlayer, tick)
            if updStar != 1:
                curPlayer.Sync_TimeTick(IPY_GameWorld.tttFlagTake, 0, diffSecond * 1000, True)
            
            
    return updStar
 
##¸±±¾°ïÖúÐÅÏ¢
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ÎÞÒâÒå
# @remarks ÓÃÓÚ֪ͨÕóÓª±È·ÖÌõ
def DoFBHelp(curPlayer, tick):
    playerID = curPlayer.GetPlayerID()
    gameFB = GameWorld.GetGameFB()
    star = gameFB.GetGameFBDictByKey(ChaosDemon_FBStar)
    wheelNum = gameFB.GetGameFBDictByKey(ChaosDemon_FBNextRefreshStep)
    needKillCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCRefreshCnt)
    remainNPCCnt = gameFB.GetGameFBDictByKey(ChaosDemon_FBNPCCnt)
    KillNPCCnt = max(0, needKillCnt - remainNPCCnt)
    data = [KillNPCCnt, needKillCnt]
    lineID = FBCommon.GetFBPropertyMark()
    isHelp = FBCommon.GetIsHelpFight(curPlayer)
    helpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FBRealHelpCount % ChConfig.Def_FBMapID_ChaosDemon)
    fbHelpDict = {FBCommon.Help_step:wheelNum, FBCommon.Help_grade:star, FBCommon.Help_npcTotal:KillNPCCnt, FBCommon.Help_lineID:lineID, 
                  FBCommon.Help_isHelp:isHelp, FBCommon.Help_helpCount:helpCount, FBCommon.Help_relation:FBHelpBattle.GetTeamFBMemRelationInfo(playerID)}
    FBCommon.Notify_FBHelp(curPlayer, fbHelpDict)
    GameWorld.DebugLog("DoFBHelp %s" % str(fbHelpDict), playerID)
    return
 
 
 
## ¸±±¾ÐÐΪ
#  @param curPlayer Íæ¼Ò
#  @param actionType ÐÐΪÀàÐÍ
#  @param actionInfo ÐÐΪÐÅÏ¢
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def DoFBAction(curPlayer, actionType, actionInfo, tick):
  
    return