hxp
2 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
#!/usr/bin/python
# -*- coding: GBK -*-
#
#
##@package PlayerFB.py
#
# @todo:Íæ¼Ò¸±±¾
#
# @author hxp
# @date 2013-08-20
# @version 2.0
# @note:
# @change: "2014-08-01 00:30" hxp Ôö¼ÓÇå³ý¸±±¾Àäȴʱ¼äÂß¼­
# @change: "2014-12-08 17:00" hxp Ôö¼ÓÇ帱±¾CD×êʯÏû·ÑÁ÷Ïò
# @change: "2015-02-10 22:30" hxp Ôö¼Ó×êʯÏûºÄÀàÐÍʼþ»ã±¨
# @change: "2015-06-29 18:00" xdh Ôö¼ÓÍæ¼Ò¸±±¾·­ÅÆÈë¿Ú
# @change: "2016-02-30 17:00" hxp ÁìÖ÷°ÔÒµ¡¢¶ñħÊÔÁ¶
# @change: "2016-03-20 15:30" hxp ¸±±¾¶à±¶½±Àø£»¹«¹²CD¸±±¾É¨µ´
# @change: "2016-04-19 17:30" xdh ¸±±¾É¨µ´Ëã»îÔ¾¶È
# @change: "2016-04-26 15:30" hxp ¶à±¶½±Àø°Ù·Ö±È¸ÄΪ½±ÀøµÈ¼¶£» É¨µ´Ôö¼ÓÇëÇóCD
# @change: "2016-08-15 11:20" xdh ¸±±¾É¨µ´ÏûºÄµÀ¾ß
# @change: "2016-12-02 11:00" xdh ¸±±¾É¨µ´Ôö¼ÓÈËÎïµÈ¼¶ÅжÏ
#------------------------------------------------------------------------------ 
#"""Version = 2016-12-02 11:00"""
#------------------------------------------------------------------------------ 
import ReadChConfig
import IPY_GameWorld
import PlayerControl
import GameWorld
import FBCommon
import ChConfig
import FBLogic
import ChPyNetSendPack
import NetPackCommon
import PlayerSuccess
import ItemCommon
import IpyGameDataPY
import ShareDefine
import GameFuncComm
import FBHelpBattle
import SkillShell
import PyGameData
import PetControl
import NPCCommon
import GameObj
 
import time
import math
#---------------------------------------------------------------------
def OnLogin(curPlayer):
    NotifyBuyFBBuffInfo(curPlayer)
    return
 
## Íæ¼Ò¸±±¾ÐÐΪ·â°ü A5 08
#  @param playerIndex Íæ¼ÒË÷Òý  
#  @param clientData ¿Í»§¶Ë·â°ü  
#  @param tick Ê±¼ä
#  @return None
def OnDoFBAction(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    actionType = clientData.ActionType # ÐÐΪÀàÐÍ
    actionInfo = clientData.ActionInfo # ÐÐΪÐÅÏ¢
    FBLogic.DoFBAction(curPlayer, actionType, actionInfo, tick)
    return
 
## A2 10 Çå³ý¸±±¾CD#tagCMClearFBCD
#  @param playerIndex Íæ¼ÒË÷Òý  
#  @param clientData ¿Í»§¶Ë·â°ü  
#  @param tick Ê±¼ä
#  @return None
def OnClearFBCD(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    mapID = clientData.MapID # mapID
    GameWorld.DebugLog("OnClearFBCD mapID=%s" % mapID)
    if not mapID:
        return
    
    enterCDTick = FBCommon.GetFBEnterCD(curPlayer, mapID)
    if enterCDTick <= 0:
        GameWorld.DebugLog("    CDʱ¼äÒѹý£¬²»ÐèÒªÇå³ý£¬ cdTick=%s" % enterCDTick)
        return
    clearEnterCDDict = IpyGameDataPY.GetFuncEvalCfg('FBEnterCD', 2)
    if mapID not in clearEnterCDDict:
        return
    costMoney = clearEnterCDDict[mapID]
    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
    if not costMoneyList:
        return
    second = enterCDTick # ²ÎÊýÃë
    # ¿Û³ýÏûºÄ
    infoDict = {"MapID":mapID, "CDSecond":second}
    for moneyType, moneyCnt in costMoneyList:
        if not PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_ClearFBCD, infoDict):
            return
   
 
    GameWorld.DebugLog("   mapID=%s Çå³ý¸±±¾CD second=%s,costMoneyList=%s" 
                         % (mapID, second, costMoneyList), curPlayer.GetPlayerID())
    
    FBCommon.SetFBPDictValue(curPlayer, ChConfig.Def_PDict_LastEnterFBTick % mapID, 0)
    FBCommon.SyncFBEnterTick(curPlayer)
    return
 
#---·â°ü¿ªÊ¼É¨µ´-------------------------------------
 
(
PCDFB_MapIDList, # ¸±±¾µØÍ¼IDÁбí
PCDFB_NeedTime, # É¨µ´Ê±¼ä, Ãë
PCDFB_FinishTimeGold, # Á¢¼´Íê³ÉÏûºÄ×êʯ¹«Ê½
) = range(3)
 
 
## ÅжÏÊÇ·ñµ±Ç°¹«¹²CD¸±±¾É¨µ´ÖÐ
def IsCurPubCDFBSweeping(curPlayer, mapID):
    sweepCfg = GetPubCDFBSweepCfg(curPlayer, mapID)
    if not sweepCfg:
        return False
    groupNum = sweepCfg[0]
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_MapID % groupNum) == mapID
 
## »ñÈ¡¹«¹²CD¸±±¾É¨µ´ÅäÖÃÐÅÏ¢
def GetPubCDFBSweepCfg(curPlayer, mapID):
    PubCDFBSweepDict = ReadChConfig.GetEvalChConfig("PubCDFBSweep")
    for groupNum, sweepInfo in PubCDFBSweepDict.items():
        mapIDGroup = sweepInfo[0]
        if mapID not in mapIDGroup:
            continue
        
        return groupNum, sweepInfo
    
    return
 
## ¿ªÊ¼¹«¹²CD¸±±¾É¨µ´
def __DoStartPubCDFBSweep(curPlayer, mapID, lineID, cnt, isFinish, dataEx, groupNum, sweepInfo):
    curSweepMapID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_MapID % groupNum)
    if curSweepMapID > 0:
        GameWorld.DebugLog("¹«¹²CD¸±±¾É¨µ´ÖÐ, ÎÞ·¨É¨µ´!groupNum=%s,curSweepMapID=%s" 
                           % (groupNum, curSweepMapID), curPlayer.GetPlayerID())
        return
    
    if not FBLogic.OnStartPubCDFBSweep(curPlayer, mapID, lineID, cnt, dataEx):
        return
    
    curTime = int(time.time())
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_MapID % groupNum, mapID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_LineID % groupNum, lineID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_Cnt % groupNum, cnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_DataEx % groupNum, dataEx)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_Time % groupNum, curTime)
    GameWorld.DebugLog("¹«¹²CD¸±±¾¿ªÊ¼É¨µ´ mapID=%s,lineID=%s,cnt=%s,dataEx=%s,groupNum=%s,curTime=%s" 
                       % (mapID, lineID, cnt, dataEx, groupNum, curTime), curPlayer.GetPlayerID())
    
    
    Sync_PubFBSweepData(curPlayer, groupNum)
    return
 
## Íê³É¹«¹²CD¸±±¾É¨µ´
def __DoFinishPubCDFB(curPlayer, mapID, isFinish, groupNum, sweepInfo):
    playerID = curPlayer.GetPlayerID()
    curSweepMapID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_MapID % groupNum)
    if curSweepMapID <= 0 or curSweepMapID != mapID:
        GameWorld.DebugLog("δɨµ´ »ò ²»Êǵ±Ç°ÕýÔÚɨµ´µÄ¹«¹²CD¸±±¾, ÎÞ·¨Íê³É!curSweepMapID=%s,mapID=%s" 
                           % (curSweepMapID, mapID), playerID)
        return
    
    sweepTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_Time % groupNum)
    lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_LineID % groupNum)
    sweepCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_Cnt % groupNum)
    dataEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_DataEx % groupNum)
    
    sweepNeedTime = sweepInfo[PCDFB_NeedTime] # µ¥´ÎºÄʱ
    finishCostGoldFormat = sweepInfo[PCDFB_FinishTimeGold]
    needTotalTime = sweepNeedTime * sweepCnt
    
    curTime = int(time.time())
    passTime = max(0, curTime - sweepTime)
    second = max(0, needTotalTime - passTime)
    
    # Õý³£Íê³É
    if isFinish == 2 and second > 0:
        GameWorld.DebugLog("ɨµ´Ê±¼äδµ½£¬ÎÞ·¨Íê³É£¬Ê£Óà%sÃë, mapID=%s" % (second, mapID), playerID)
        return
    
    addDataDict = {"curTime":curTime, "startSweepTime":sweepTime, "sweepCnt":sweepCnt, 
                   "needTotalTime":needTotalTime, "passTime":passTime, "remainSecond":second, 
                   "costGold":0, "mapID":mapID, "lineID":lineID, "dataEx":dataEx, ChConfig.Def_Cost_Reason_SonKey:mapID}
    
    # ×êʯÁ¢¼´Íê³É
    if isFinish == 1:
        costGold = eval(finishCostGoldFormat)
        if costGold > 0:
            addDataDict["costGold"] = costGold
            if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, 
                                          ChConfig.Def_Cost_FinishFBSweep, addDataDict):
                return
    
    GameWorld.DebugLog("¹«¹²CD¸±±¾É¨µ´Íê³É: %s" % str(addDataDict), playerID)
    # ¸ø½±Àø
    FBLogic.OnGivePubCDFBSweepPrize(curPlayer, mapID, lineID, sweepCnt, dataEx)
    
    # ÖØÖÃɨµ´Êý¾Ý
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_MapID % groupNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_LineID % groupNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_Cnt % groupNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_DataEx % groupNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PubCDFBS_Time % groupNum, 0)
    Sync_PubFBSweepData(curPlayer, groupNum)
    return
 
## Í¬²½¹«¹²CD¸±±¾É¨µ´ÐÅÏ¢
def Sync_PubFBSweepData(curPlayer, groupNum=-1):
    
    PubCDFBSweepDict = ReadChConfig.GetEvalChConfig("PubCDFBSweep")
    allGroupNumList = PubCDFBSweepDict.keys()
    if groupNum == -1:
        groupNumList = allGroupNumList
    else:
        if groupNum not in allGroupNumList:
            return
        groupNumList = [groupNum]
        
    pubSweepData = ChPyNetSendPack.tagMCPubFBSweepData()
    pubSweepData.Clear()
    pubSweepData.SweepDatList = []
    
    for gNum in groupNumList:
        sweepInfo = ChPyNetSendPack.tagMCPubFBSweep()
        sweepInfo.Clear()
        sweepInfo.PubNum = gNum
        sweepInfo.FBMapID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_MapID % gNum)
        sweepInfo.LineID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_LineID % gNum)
        sweepInfo.SweepTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_Time % gNum)
        sweepInfo.SweepCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PubCDFBS_Cnt % gNum)
        pubSweepData.SweepDatList.append(sweepInfo)
        
    pubSweepData.Cnt = len(pubSweepData.SweepDatList)
    NetPackCommon.SendFakePack(curPlayer, pubSweepData)
    return
 
#//A5 05 Íæ¼Ò¿ªÊ¼¸±±¾É¨µ´ #tagCMBeginFBWipeOut
#
#struct    tagCMBeginFBWipeOut
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#    BYTE        Cnt;    // É¨µ´´ÎÊý
#    BYTE        IsFinish;    // ÊÇ·ñÁ¢¼´Íê³É; 0-·ñ£»1-»¨Ç®Á¢¼´Íê³É£»2-¿Í»§¶Ë×ÔÐе¹¼ÆÊ±¼äµ½ºó·¢ËÍ2´ú±íÁìȡɨµ´Íê³É½±Àø
#    DWORD        DataEx;    //¸½´øÐÅÏ¢
#    BYTE        IsLittleHelper;    // ÊÇ·ñСÖúÊÖɨµ´
#};
def OnPlayerFBWipeOut(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    
    #if not GameWorld.CheckPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_BeginFBWipeOut, tick):
    #    GameWorld.DebugLog("Íæ¼Ò¸±±¾É¨µ´ÇëÇóCDÖÐ...", curPlayer.GetPlayerID())
    #    return
    
    mapID = clientData.MapID
    lineID = clientData.LineID
    cnt = clientData.Cnt
    #isFinish = clientData.IsFinish
    isFinish = 1 # ÔÝʱĬÈÏ1£¬Ö®ºóÓÐÐèҪɨµ´µÈ´ýµÄÔÙ˵
    dataEx = clientData.DataEx
    isLittleHelper = clientData.IsLittleHelper
    if isLittleHelper:
        if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_LittleHelper):
            GameWorld.DebugLog("Íæ¼ÒûÓÐСÖúÊÖ¹¦ÄÜȨÏÞ£¡", curPlayer.GetPlayerID())
            return
    
    if cnt <= 0:
        return
    
    fbIpyData = FBCommon.GetFBIpyData(mapID)
    if FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID()) == FBCommon.GetRecordMapID(mapID):
        if fbIpyData and fbIpyData.GetDayTimes():#ûÓÐÏÞÖÆ½øÈë´ÎÊýµÄ²»ÏÞÖÆÔÚÄ¿±êµØÍ¼É¨µ´
            GameWorld.DebugLog("Íæ¼ÒÔÚɨµ´Ä¿±êµØÍ¼ÖУ¬ÎÞ·¨É¨µ´£¡mapID=%s" % mapID)
            return
    
    
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
    if not fbLineIpyData:
        GameWorld.DebugLog("ÕÒ²»µ½¸Ã¸±±¾Ïß·£¬ÎÞ·¨É¨µ´£¡mapID=%s, lineID=%s" % (mapID, lineID))
        return
    
    if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, cnt) != ShareDefine.EntFBAskRet_OK:
        return
    costMoneyList = []
    sweepCostindexList = []
    sweepCostCnt = 0
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    
    if fbLineIpyData:
        #ɨµ´µÈ¼¶ÅжÏ
        sweepLVLimit = fbLineIpyData.GetSweepLVLimit()
        if sweepLVLimit and curPlayer.GetLV() < sweepLVLimit:
            GameWorld.DebugLog('Íæ¼Ò¸±±¾É¨µ´,µÈ¼¶²»×㣡mapID=%s, lineID=%s, playerLV=%s, sweepLVLimit=%s' 
                               % (mapID, lineID, curPlayer.GetLV(), sweepLVLimit), curPlayer.GetPlayerID())
            return
        
        #ɨµ´µÀ¾ßÅжϣ¬Ð¡ÖúÊÖ²»ÏûºÄɨµ´µÀ¾ß
        sweepItemID = fbLineIpyData.GetSweepItemID()
        if sweepItemID and not isLittleHelper:
            sweepItemCnt = fbLineIpyData.GetSweepCostCnt()
            sweepCostCnt = sweepItemCnt * cnt
            #isEnough, sweepCostindexList = ItemCommon.GetItem_FromPack_ByID(sweepItemID, itemPack, sweepCostCnt)
            isEnough, sweepCostindexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(sweepItemID, itemPack, sweepCostCnt)
            if not isEnough:
                itemPrice = ItemCommon.GetShopItemPrice(sweepItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
                if itemPrice:
                    costMoney = itemPrice * lackCnt
                    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
                if not costMoneyList:
                    GameWorld.DebugLog("ɨµ´ÏûºÄµÀ¾ß²»×ã, mapID=%s,lineID=%s,sweepItemID=%s,sweepCostCnt=%s" 
                                   % (mapID, lineID, sweepItemID, sweepCostCnt), curPlayer.GetPlayerID())
                    return
 
            
        
    #¹«¹²CDɨµ´Ä£Ê½ÔÝÆÁ±Î£¬ÓÐÐèÒªÔÙÐÞ¸Ä
    #===============================================================================================
    # groupNum = -1
    # sweepInfo = None
    # PubCDFBSweepDict = ReadChConfig.GetEvalChConfig("PubCDFBSweep")
    # for gNum, sInfo in PubCDFBSweepDict.items():
    #    if mapID in sInfo[PCDFB_MapIDList]:
    #        groupNum = gNum
    #        sweepInfo = sInfo
    #        break
    #        
    # # ¹«¹²CD¸±±¾É¨µ´
    # if groupNum >= 0:
    #    if not isFinish:
    #        __DoStartPubCDFBSweep(curPlayer, mapID, lineID, cnt, isFinish, dataEx, groupNum, sweepInfo)
    #    else:
    #        __DoFinishPubCDFB(curPlayer, mapID, isFinish, groupNum, sweepInfo)
    #    return
    #===============================================================================================
    
    # ¸±±¾ÊÇ·ñ¿Éɨµ´, ÕâÀïÖ»Åжϸ±±¾×ÔÉíµÄÌØÊâÌõ¼þ, ¹«¹²Ìõ¼þÉÏÃæÒѾ­ÅжÏ
    if not FBLogic.OnPlayerFBSweepAsk(curPlayer, mapID, lineID, cnt, isFinish, dataEx):
        return
    
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_FBSweep, 1, [mapID])
    
    #¿Û³ýɨµ´µÀ¾ß
    if sweepCostindexList and sweepCostCnt:
        ItemCommon.ReduceItem(curPlayer, itemPack, sweepCostindexList, sweepCostCnt, False, 'FBSweepCostItem')
    if costMoneyList:
        infoDict = {"MapID":mapID, "LineID":lineID, 'SweepCount':cnt}
        for moneyType, moneyNum in costMoneyList:
            if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep, infoDict):
                return False, hasBind
    
    #ÐèÏȿ۳ýÃÅÆ±, ÔÙÔö¼Ó´ÎÊý, ·ñÔò¿ÉÄܵ¼Ö¿۳ýµÄÊýÁ¿´íÎó
    FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID, cnt)
        
    #Ôö¼Ó¸±±¾½øÈë´ÎÊý
    if fbIpyData and fbIpyData.GetDayTimes():
        FBCommon.AddEnterFBCount(curPlayer, mapID, cnt)
    
    helpIpyData = IpyGameDataPY.GetIpyGameDataNotLog("FBHelpBattle", mapID, lineID)
    if helpIpyData:
        FBHelpBattle.SendGameServer_SweepCallHelpBattlePlayer(curPlayer, mapID, lineID)
        return
    
    #ɨµ´½á¹û¸ø½±ÀøµÈ
    FBLogic.OnPlayerFBSweepResult(curPlayer, mapID, lineID, cnt, isFinish, dataEx)
    return
 
 
#// A5 1B ¹ºÂòÌôÕ½¸±±¾¾«Á¦ #tagCMBuyFBEnergy
#
#struct    tagCMBuyFBEnergy
#{
#    tagHead         Head;
#};
def OnPlayerBuyFBEnergy(playerIndex, clientData, tick):
    #curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    return
 
 
## Íæ¼Ò¸±±¾¹¦ÄÜʱ¼ä´¦Àí
def DoPlayerFBTimeProcess(curPlayer, tick):
    
    checkInterval = ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_FBTimeProcess]
    if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_FBTimeProcess) < checkInterval:
        return 
    
    curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_FBTimeProcess, tick)
    
    # ÁìÖ÷°ÔÒµÍæ¼Ò¹¦ÄÜʱ¼ä´¦Àí
    FBCommon.RegainFBCntProcess(curPlayer)
    return
 
 
#// B1 02 ÁìÈ¡¶à±¶¸±±¾½±Àø #tagCMGetMultiFBPrize
#
#struct    tagCMGetMultiFBPrize
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#    WORD        Percent;    // ¶îÍâ½±Àø°Ù·Ö±È½±ÀøµÈ¼¶
#};
def OnPlayerGetMultiFBPrize(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    mapID = clientData.MapID
    lineID = clientData.LineID
    prizeExLV = clientData.Percent
    FBLogic.OnGetMultiFBPrize(curPlayer, mapID, lineID, prizeExLV)
    return
 
 
#//A5 60 ÖØÖø±±¾ÌôÕ½´ÎÊý #tagCMResetFBJoinCnt
#
#struct tagCMResetFBJoinCnt
#{
#    tagHead        Head;
#};
def OnPlayerResetFBJoinCnt(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    return
 
 
#// B1 01 ¿Í»§¶Ë¸±±¾·¢ËͽáÊø #tagCMClientEndFB
#
#struct    tagCMClientEndFB
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#    DWORD        Data;    //¸±±¾Êý¾Ý
#};
def OnClientEndFB(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    mapID = clientData.MapID
    lineID = clientData.LineID
    data1 = clientData.Data1
    data2 = clientData.Data2
    dataList = [data1, data2]
    FBLogic.OnClientEndFB(curPlayer, mapID, lineID, dataList)
    GameWorld.DebugLog('    ¿Í»§¶Ë¸±±¾·¢ËͽáÊømapID=%s,lineID=%s,dataList=%s'%(mapID,lineID,dataList))
    return
 
 
#// B1 04 ¿Í»§¶Ë·¢ËÍ¿ªÊ¼¸±±¾ #tagCMClientStartFB
#
#struct    tagCMClientStartFB
#{
#    tagHead         Head;
#};
def OnClientStartFB(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    FBLogic.OnClientStartFB(curPlayer, tick)
    return
 
#// A2 31 Ç°¶Ë¿ªÊ¼×Ô¶¨Ò峡¾° #tagCMClientStartCustomScene
#
#struct    tagCMClientStartCustomScene
#{
#    tagHead        Head;
#    DWORD        MapID;
#    WORD        FuncLineID;
#};
def OnClientStartCustomScene(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    mapID = clientData.MapID
    funcLineID = clientData.FuncLineID
    DoEnterCustomScene(curPlayer, mapID, funcLineID, tick)
    return
 
#// A2 33 Ç°¶ËÍ˳ö×Ô¶¨Ò峡¾° #tagCMClientExitCustomScene
#
#struct    tagCMClientExitCustomScene
#{
#    tagHead        Head;
#};
def OnClientExitCustomScene(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    DoExitCustomScene(curPlayer)
    return
 
def DoEnterCustomScene(curPlayer, mapID, lineID, tick):
    ## ½øÈë×Ô¶¨Ò峡¾°×´Ì¬
    playerID = curPlayer.GetPlayerID()
    GameWorld.Log("Íæ¼ÒÇëÇó½øÈë×Ô¶¨Ò峡¾°!mapID=%s,lineID=%s" % (mapID, lineID), playerID)
    if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene):
        curMapID = PlayerControl.GetCustomMapID(curPlayer)
        curLineID = PlayerControl.GetCustomLineID(curPlayer)
        if mapID == curMapID and lineID == curLineID:
            GameWorld.Log("    Íæ¼Òµ±Ç°ÒѾ­ÔÚ×Ô¶¨Ò峡¾°ÖУ¡ÎÞÐèÖØÐÂÇëÇó£¡", playerID)
            result = 1
        else:
            GameWorld.Log("    Íæ¼Òµ±Ç°ÔÚ²»Í¬µÄ×Ô¶¨Ò峡¾°ÖУ¡²»ÔÊÐí½øÈ룡curMapID=%s,curLineID=%s" 
                          % (curMapID, curLineID), playerID)
            result = 0
        StartCustomSceneResult(curPlayer, mapID, lineID, result)
        return result
    
    #½øÈ븱±¾Í¨Óüì²é
    if mapID:
        fbIpyData = FBCommon.GetFBIpyData(mapID)
        fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
        if PlayerControl.CheckMoveToFB(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, tick) != ShareDefine.EntFBAskRet_OK:
            StartCustomSceneResult(curPlayer, mapID, lineID, 0)
            return 0
    
    PlayerControl.SetPlayerSightLevel(curPlayer, curPlayer.GetID())
        
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomScene, 1) # ÓÉÓÚǰ¶Ë²»Ò»¶¨Óз¢mapID£¬ËùÒÔÕâÀï¶îÍâ¼Ç¼Õâ¸ö״̬£¬²»ÄÜÖ±½ÓÓÃmapIDÅжÏ
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneStepTick, tick)
    PlayerControl.SetCustomMap(curPlayer, mapID, lineID)
    NPCCommon.ClearPriWoodPile(curPlayer)
    GameWorld.Log("Íæ¼Ò¿ªÊ¼×Ô¶¨Ò峡¾°!mapID=%s,lineID=%s" % (mapID, lineID), playerID)
    if mapID:
        PetControl.DoLogic_PetLoadMapOK(curPlayer)
        FBLogic.OnEnterCustomScene(curPlayer, mapID, lineID)
        
    #ĬÈÏ»ØÂúѪ
    if GameObj.GetHP(curPlayer) < GameObj.GetMaxHP(curPlayer):
        GameObj.SetHPFull(curPlayer)
        
    #֪ͨ½øÈë״̬
    StartCustomSceneResult(curPlayer, mapID, lineID, 1)
    return 1
 
def StartCustomSceneResult(curPlayer, mapID, lineID, result):
    if result != 1:
        DoExitCustomScene(curPlayer)
    resultPack = ChPyNetSendPack.tagMCStartCustomSceneResult()
    resultPack.MapID = mapID
    resultPack.FuncLineID = lineID
    resultPack.Result = result
    NetPackCommon.SendFakePack(curPlayer, resultPack)
    return
 
def DoExitCustomScene(curPlayer):
    ## Í˳ö×Ô¶¨Ò峡¾°×´Ì¬
    PlayerControl.SetPlayerSightLevel(curPlayer, 0)
    mapID = PlayerControl.GetCustomMapID(curPlayer)
    lineID = PlayerControl.GetCustomLineID(curPlayer)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomScene, 0)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneStepTick, 0)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneGrade, 0)
    PlayerControl.SetCustomMap(curPlayer, 0, 0)
    if mapID and FBCommon.GetCustomMapStep(curPlayer, mapID, lineID) != ChConfig.CustomMapStep_Over:
        FBCommon.SetCustomMapStep(curPlayer, mapID, lineID, ChConfig.CustomMapStep_Over)
    NPCCommon.ClearPriWoodPile(curPlayer)
    
    #ĬÈÏ»ØÂúѪ
    if GameObj.GetHP(curPlayer) > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie and GameObj.GetHP(curPlayer) < GameObj.GetMaxHP(curPlayer):
        GameObj.SetHPFull(curPlayer)
        
    GameWorld.Log("Íæ¼ÒÍ˳ö×Ô¶¨Ò峡¾°!", curPlayer.GetPlayerID())
    return
 
#// B1 0A ¸±±¾¹ºÂòbuff #tagCMFBBuyBuff
#struct    tagCMFBBuyBuff
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        MoneyCnt;
#};
def OnFBBuyBuff(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    mapID = clientData.MapID
    moneyCnt = clientData.MoneyCnt
    ipyData = IpyGameDataPY.GetIpyGameData('FBBuyBuff', mapID, moneyCnt)
    if not ipyData:
        return
    addBuffID = ipyData.GetBuffID()
    curSkill = GameWorld.GetGameData().GetSkillBySkillID(addBuffID)
    if not curSkill:
        return
    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
    if crossMapID and mapID !=crossMapID:
        return
    if not crossMapID and mapID != GameWorld.GetMap().GetMapID():
        return
    
    curTime = int(time.time())
    #ÅжÏCD 
    timeKey = (mapID, moneyCnt)
    lastTime = PyGameData.g_fbBuyBuffTimeDict.get(playerID, {}).get(timeKey, 0)
    if lastTime and curTime - lastTime < ipyData.GetBuffCD():
        GameWorld.DebugLog('¸±±¾¹ºÂòbuff CDδµ½ ')
        return
 
    #¿ÛÇ®
    infoDict =  {"MapID":mapID, "addBuffID":addBuffID}
    if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, moneyCnt, ChConfig.Def_Cost_FBBuyBuff, infoDict):
        return
    if playerID not in PyGameData.g_fbBuyBuffTimeDict:
        PyGameData.g_fbBuyBuffTimeDict[playerID] = {}
    PyGameData.g_fbBuyBuffTimeDict[playerID][timeKey] = curTime
    NotifyBuyFBBuffInfo(curPlayer)
    if crossMapID:
        msgDict = {"PlayerID":curPlayer.GetPlayerID(), "buffID":addBuffID}
        GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_AddBuff, msgDict)
        GameWorld.DebugLog("¿ç·þÖÐÇëÇó¸´»î, crossMapID=%s,msgDict=%s" % (crossMapID, msgDict), playerID)
        return
 
    SkillShell.__DoLogic_AddBuff(curPlayer, curPlayer, curSkill, False, tick, 0, 0)
    #SkillCommon.AddBuffBySkillType(curPlayer, addBuffID, tick)
    return
 
def NotifyBuyFBBuffInfo(curPlayer):
    playerID = curPlayer.GetPlayerID()
    buffTimeDict = PyGameData.g_fbBuyBuffTimeDict.get(playerID, {})
    if not buffTimeDict:
        return
    packData = ChPyNetSendPack.tagMCFBBuyBuffInfo()
    packData.InfoList = []
    for timeKey, buyTime in buffTimeDict.items():
        mapID, moneyCnt = timeKey
        timeInfo = ChPyNetSendPack.tagMCFBBuyBuffTime()
        timeInfo.MapID = mapID
        timeInfo.MoneyCnt = moneyCnt
        timeInfo.BuyTime = buyTime
        packData.InfoList.append(timeInfo)
    packData.Cnt = len(packData.InfoList)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return
 
#// B1 08 ¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾ #tagCMFBQuickPass
#
#struct    tagCMFBQuickPass
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#};
def OnFBQuickPass(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    mapID = clientData.MapID
    lineID = clientData.LineID
    GameWorld.DebugLog("Íæ¼ÒÇëÇó¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
    
    fbIpyData = FBCommon.GetFBIpyData(mapID)
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
    if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
        return
    
    reqRet = FBLogic.OnPlayerFBQuickPass(curPlayer, mapID, lineID)
    if not reqRet or len(reqRet) != 2:
        GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
        return
    bossID, quickCnt = reqRet
    if bossID:
        npcData = GameWorld.GetGameData().FindNPCDataByID(bossID)
        if not npcData:
            return
        npcFightPower = NPCCommon.GetSuppressFightPower(npcData)
        quickNeedRatio = IpyGameDataPY.GetFuncCfg("FBQuickPass", 1)
        quickNeedFightPower = int(npcFightPower * quickNeedRatio)
        curFightPower = PlayerControl.GetFightPower(curPlayer)
        if quickNeedFightPower and curFightPower < quickNeedFightPower:
            GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾! Õ½Á¦ÏÞÖÆ: mapID=%s,lineID=%s,bossID=%s,npcFightPower=%s,quickNeedFightPower=%s > %s" 
                               % (mapID, lineID, bossID, npcFightPower, quickNeedFightPower, curFightPower), playerID)
            PlayerControl.NotifyCode(curPlayer, 'TaskFeedback4')
            return
        
    #Ôö¼Ó¸±±¾½øÈë´ÎÊý
    if fbIpyData and fbIpyData.GetDayTimes() and quickCnt:
        # Ìø¹Ø³¬¹ý1¹ØµÄÒªÖØÐÂÑéÖ¤ÏÂ
        if quickCnt > 1 and FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, quickCnt) != ShareDefine.EntFBAskRet_OK:
            return
        FBCommon.AddEnterFBCount(curPlayer, mapID, quickCnt)
        
    #ɨµ´½á¹û¸ø½±ÀøµÈ
    FBLogic.OnPlayerFBQuickPassResult(curPlayer, mapID, lineID)
    return