hxp
2024-11-15 789490b7d362160f7fca4580df6176498e1eb271
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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_IceLode
#
# @todo:±ù¾§¿óÂö
# @author xdh
# @date 2017-9-14
# @version 1.0
#
# ÏêϸÃèÊö: ±ù¾§¿óÂö
#
#-------------------------------------------------------------------------------
#"""Version = 2017-09-14 15:30"""
#-------------------------------------------------------------------------------
 
import FBCommon
import GameWorld
import IPY_GameWorld
import NPCCustomRefresh
import GameWorldProcess
import PlayerControl
import ShareDefine
import IpyGameDataPY
import PyGameData
import ChConfig
import PlayerActivity
import ItemCommon
import ItemControler
import EventReport
import EventShell
import ChPyNetSendPack
import NetPackCommon
import PlayerSuccess
import PlayerWeekParty
import PlayerActLogin
import BuffSkill
 
import random
import datetime
import time
import math
 
#---¸±±¾ÅäÖöÔÓ¦keyÖµ---
(
Def_PrepareTime, # ¸±±¾×¼±¸Ê±¼ä(Ãë)
Def_FightTime, # ½øÐÐʱ¼ä(Ãë)
Def_PickTime, # Ê°È¡Ê±¼ä(Ãë)£¨°üº¬Í˳öʱ¼ä£©
Def_LeaveTime, # Í˳öʱ¼ä(Ãë)
Def_StarTime, #ÐǼ¶Ê±¼ä
) = range(5)
 
 
#---¸±±¾·ÖÏßÅäÖÃË÷ÒýÐÅÏ¢---
(
Def_RefreshMark, # Ë¢¹Ö±êʶµã
DL_NPCID, # NPCID
DL_TotalNPCCnt, # ÀÛ¼ÆË¢NPC×ܸöÊý
DL_ScreenMaxNPC, # Í¬Ê±´æÔÚNPCÊý
) = range(4)
 
 
#µ±Ç°¸±±¾µØÍ¼µÄ״̬
(
FB_Step_Open, # ¸±±¾¿ªÆô
FB_Step_Prepare, # ¸±±¾µÈ´ý
FB_Step_Fighting, # ¸±±¾½øÐÐÖÐ
FB_Step_PickItem, # Ê°È¡ÎïÆ·ÖÐ
FB_Step_Over, # ¸±±¾½áÊø
FB_Step_Close, # ¸±±¾¹Ø±Õ
) = range(6)
 
 
FBPlayerDict_RemainNPCCnt = 'FBPlayerDict_RemainNPCCnt'   # Ê£Óà¹ÖÊýÁ¿
FBPlayerDict_TotalPoint = 'FBPlayerDict_TotalPoint'   # »ñµÃµÄ×ÜÅ­ÆøÖµ
FBPlayerDict_CostTime = 'FBPlayerDict_CostTime' #ͨ¹ØÊ±¼ä
FBPlayerDict_TotalExp = 'FBPlayerDict_TotalExp'   # »ñµÃµÄ×ܾ­Ñé
FBPlayerDict_TotalExpPoint = 'FBPlayerDict_TotalExpPoint'   # »ñµÃµÄ×ܾ­Ñéµã
FBPlayerDict_FBStar = 'FBPlayerDict_FBStar'   # µ±Ç°ÐǼ¶
 
 
 
##---»ñµÃ¸±±¾·ÖÏßÅäÖÃ---
#  @param None
#  @return ÅäÖÃÐÅÏ¢
def GetIceLodeNPCCfg():
    lineID = FBCommon.GetFBPropertyMark()
    return FBCommon.GetFBLineRefreshNPC(GameWorld.GetMap().GetMapID(), lineID)
 
def GetPointByNPCID(npcid):
    '''ͨ¹ýNPCID»ñÈ¡¶ÔÓ¦µÄ»ý·Ö'''
    npcPointDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeNeedPoint', 2, {})
    
    return npcPointDict.get(npcid, 0)
 
 
## OnDay´¦Àí
#  @param curPlayer
#  @return None
def OnFBPlayerOnDay(curPlayer):
    if curPlayer.GetMapID() == ChConfig.Def_FBMapID_IceLode:
        #Íæ¼Ò»¹ÔÚ¸±±¾ÖУ¬µÈÕâ´Î¸±±¾½áÊø£¬ÒÔ×îеÄ×ÜÐǼ¶¸ø·¢½±Àø 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeIsInFBOnDay, 1)
        return
    
    #²¹·¢½±Àø
    CheckIceLodeStarAwardMail(curPlayer)
    return
 
def OnFBPlayerOnLogin(curPlayer):
    isInFBOnDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeIsInFBOnDay)
    if isInFBOnDay and curPlayer.GetMapID() != ChConfig.Def_FBMapID_IceLode: #ÔÚ¸±±¾Àï¹ýÌ죬¸±±¾½áÊøºóÔÙ²¹·¢½±Àø
        if CheckIceLodeStarAwardMail(curPlayer):
            return
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    if not lineList:
        __RandomLine(curPlayer, lineList)
    SyncIceLoddInfo(curPlayer)
    return
 
def __RandomLine(curPlayer, oldlineList):
    # Ëæ»ú½ñÈÕÍæ·¨
    maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
    lineList = range(maxCnt)
    newlineList = list(set(lineList) - set(oldlineList))
    if len(newlineList) < randomCnt:
        random.shuffle(oldlineList)
        newlineList += oldlineList[:randomCnt-len(newlineList)]
    else:
        random.shuffle(newlineList)
        newlineList = newlineList[:randomCnt]
    #random.shuffle(lineList)
    for lineID in lineList:
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IceLoadLineID, lineID, 1 if lineID in newlineList else 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeDayLV, curPlayer.GetLV())
    GameWorld.DebugLog('    Ëæ»ú±ù¾§¿óÂö½ñÈÕÍæ·¨ oldlineList=%s, newlineList =%s'%(oldlineList, newlineList), curPlayer.GetID())
    return
 
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
#  @param curPlayer Íæ¼ÒʵÀý
#  @param mapID µØÍ¼ID
#  @param lineID Ïß·id
#  @param tick Ê±¼ä´Á
#  @return ²¼¶ûÖµ
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    if lineID not in lineList:
        GameWorld.DebugLog('±ù¾§¿óÂö½ñÈÕûÓиÃÏß· lineID=%s,lineList=%s'%(lineID, lineList))
        return False
    return True
 
 
 
##¸±±¾Íæ¼Ò½øÈëµã
# @param curPlayer Íæ¼ÒʵÀý
# @param mapID µØÍ¼ID
# @param lineId ·ÖÏßID
# @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢
# @param tick Ê±¼ä´Á
# @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡)
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
    return ipyEnterPosInfo
 
 
##²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼
# @param ask:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk)
# @param tick:ʱ¼ä´Á
# @return IPY_GameWorld.cme Ã¶¾Ù
def OnChangeMapAsk(ask, tick):
    return IPY_GameWorld.cmeAccept
 
 
## ½ø¸±±¾
#  @param curPlayer
#  @param tick
#  @return None
def DoEnterFB(curPlayer, tick):
    PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 2)
    playerID = curPlayer.GetPlayerID()
    mapID = GameWorld.GetGameWorld().GetMapID()
    gameFB = GameWorld.GetGameFB()
    lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqFBFuncLine)
    GameWorld.DebugLog("DoEnterFB...lineID=%s"%lineID, playerID)
    hadDelTicket = FBCommon.GetHadDelTicket(curPlayer)
    if not hadDelTicket:
        PyGameData.g_fbPickUpItemDict.pop(playerID, 0)
        GameWorld.DebugLog("DoEnterFB ¿Û³ýÈ볡ȯ£¬ÖØÖÃÐÅÏ¢£¡")
        delResult = FBCommon.DelFBEnterTicket(curPlayer, mapID)
        isOK = delResult[0]
        #hasBind = delResult[1]
        if not isOK:
            PlayerControl.PlayerLeaveFB(curPlayer)
            return
        #ÐǼ¶Îª0ÔòÃâ·Ñ,·ñÔòÊÕÇ®
        curStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [mapID])
        if curStar:
            costGold = IpyGameDataPY.GetFuncCfg('IceLodeCfg')
            if costGold:
                costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costGold)
                if not costMoneyList:
                    GameWorld.Log('Ç®²»¹» lineID=%s,costGold=%s'%(lineID, costGold))
                    PlayerControl.PlayerLeaveFB(curPlayer)
                    return
                for moneyType, moneyNum in costMoneyList:
                    PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_BuyFBCnt, {"MapID":mapID, 'lineID':lineID})
        
        FBCommon.SetFBPropertyMark(lineID)
        FBCommon.SetHadDelTicket(curPlayer)
        FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_IceLode)
        FBCommon.SetFBStep(FB_Step_Prepare, tick)
        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start)
 
    fbStep = gameFB.GetFBStep()
    if fbStep <= FB_Step_Prepare:
        mapID = GameWorld.GetMap().GetMapID()
        notify_tick = FBCommon.GetFBLineStepTime(mapID)[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_Fighting:
        mapID = GameWorld.GetMap().GetMapID()
        notify_tick = FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)
        __UpdIceLoadFBStar(tick, True, curPlayer)
    DoFBHelp(curPlayer, tick)
    return
 
##Íæ¼ÒÍ˳ö¸±±¾
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ÎÞÒâÒå
def DoExitFB(curPlayer, tick):
    PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default)
    return
 
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
def DoPlayerLeaveFB(curPlayer, tick):
    PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default)
    return
 
##Íæ¼ÒÇл»µØÍ¼
def DoPlayerChangeMapLogic(curPlayer):
    tick = GameWorld.GetGameWorld().GetTick()
    for buffID in IpyGameDataPY.GetFuncEvalCfg('IceLodeSpecial', 2):
        BuffSkill.DelBuffBySkillID(curPlayer, buffID, tick)
    return
 
def OnPickUpItem(curPlayer, curItem, tick):
    return
    mapItemType = curItem.GetType()
    if mapItemType == ChConfig.Def_ItemType_Money:
        return
    playerID = curPlayer.GetID()
    isEquip = ItemCommon.CheckItemIsEquip(curItem)
    jsonItem = ItemCommon.GetJsonItem(curItem)
    if playerID in PyGameData.g_fbPickUpItemDict:
        if isEquip:
            PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
        else:
            for itemInfo in PyGameData.g_fbPickUpItemDict[playerID]:
                if itemInfo["ItemID"] == jsonItem["ItemID"] and itemInfo.get("IsBind") == jsonItem.get("IsBind"):
                    itemInfo["Count"] = itemInfo.get("Count", 1)+ jsonItem.get("Count", 1)
    else:
        PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem]
    
    isItemAllPickUp = (GameWorld.GetMapItemManager().GetMapItemCount() <= 1)
    if isItemAllPickUp and GameWorld.GetGameFB().GetFBStep() == FB_Step_PickItem:
        __DoIceLodeOver(True)
        
    
    #GameWorld.Log('PyGameData.g_fbPickUpItemDict=%s'%PyGameData.g_fbPickUpItemDict)
    return
 
 
## »ñµÃ¸±±¾°ïÖúÐÅÏ¢
#  @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£©
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def DoFBHelp(curPlayer, tick):
    gameFB = GameWorld.GetGameFB()
    
    # »ñµÃ¸±±¾ÐÅÏ¢
    star = gameFB.GetGameFBDictByKey(FBPlayerDict_FBStar)
    lineID = FBCommon.GetFBPropertyMark()
    #¸±±¾°ïÖú
    helpDict = {FBCommon.Help_grade:star, FBCommon.Help_lineID:lineID}
    GameWorld.DebugLog("DoFBHelp %s" % str(helpDict))
    FBCommon.Notify_FBHelp(curPlayer, helpDict)
    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_Fighting:
        __DoLogic_FB_Fighting(tick)
        __UpdIceLoadFBStar(tick)
    # ¸±±¾Ê°È¡ÖÐ
    elif fbStep == FB_Step_PickItem:
        __DoLogic_FB_PickItem(tick)
    # ¸±±¾½áÊø
    elif fbStep == FB_Step_Over:
        __DoLogic_FB_Over(tick)
    
    return
 
 
## ¸üе±Ç°¸±±¾ÐǼ¶
def __UpdIceLoadFBStar(tick, isEnter=False, curPlayer=None):
    gameFB = GameWorld.GetGameFB()
    curStar = gameFB.GetGameFBDictByKey(FBPlayerDict_FBStar)
    if curStar == 1:
        return curStar
    
    mapID = GameWorld.GetMap().GetMapID()
    useSecond = int(math.ceil((tick - gameFB.GetFBStepTick()) / 1000.0))
    icelodeTimeCfg = FBCommon.GetFBLineStepTime(mapID)
    starTimeList = icelodeTimeCfg[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(FBPlayerDict_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 tick:ʱ¼ä´Á
#  @return ÎÞÒâÒå
def __DoLogic_FB_Prepare(tick):
    gameFB = GameWorld.GetGameFB()
    mapID = GameWorld.GetMap().GetMapID()
    stepTimeCfg = FBCommon.GetFBLineStepTime(mapID)
    # ¼ä¸ôδµ½
    if tick - gameFB.GetFBStepTick() < stepTimeCfg[Def_PrepareTime] * 1000:
        return
    
    # ÉèÖÿªÊ¼Ë¢¹Ö
    npcCnt = 0
    npcCfg = GetIceLodeNPCCfg()
    for npcInfo in npcCfg:
        npcid = npcInfo[DL_NPCID]
        maxCnt = npcInfo[DL_ScreenMaxNPC]
        totalMaxCnt = npcInfo[DL_TotalNPCCnt]
        NPCCustomRefresh.SetNPCRefresh(npcInfo[Def_RefreshMark], [npcid], maxCnt, totalMaxCnt)
        npcCnt += totalMaxCnt
    NPCCustomRefresh.ProcessAllNPCRefresh(tick) # Á¢¼´³ö·¢Ò»´Î±êʶµãË¢ÐÂ
    gameFB.SetGameFBDict(FBPlayerDict_RemainNPCCnt, npcCnt)
    GameWorld.DebugLog('ÉèÖÿªÊ¼Ë¢¹Ö remainNPCCnt=%s'%npcCnt)
    # ¸±±¾¿ªÊ¼
    FBCommon.SetFBStep(FB_Step_Fighting, tick)
    FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, stepTimeCfg[Def_FightTime] * 1000)
    return
 
 
## ¸±±¾½øÐÐÖÐ
#  @param tick:ʱ¼ä´Á
#  @return ÎÞÒâÒå
def __DoLogic_FB_Fighting(tick):
    # ¼ä¸ôδµ½
    mapID = GameWorld.GetMap().GetMapID()
    if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000:
        return
    
    __DoIceLodeOver(False)
    return
 
## ¸±±¾Ê°È¡
#  @param tick:ʱ¼ä´Á
#  @return ÎÞÒâÒå
def __DoLogic_FB_PickItem(tick):
    # ¼ä¸ôδµ½
    mapID = GameWorld.GetMap().GetMapID()
    if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000:
        return
    
    #¸±±¾¹Ø±Õ
    GameWorldProcess.CloseFB(tick)
    FBCommon.SetFBStep(FB_Step_Close, tick)
    return
 
        
##¸±±¾¹Ø±ÕÖÐ
# @param tick:ʱ¼ä´Á
# @return ÎÞÒâÒå
# @remarks ¸±±¾¹Ø±ÕÖÐ
def __DoLogic_FB_Over(tick):
 
    # ¼ä¸ôδµ½
    mapID = GameWorld.GetMap().GetMapID()
    if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000:
        return
    
    #¸±±¾¹Ø±Õ
    GameWorldProcess.CloseFB(tick)
    FBCommon.SetFBStep(FB_Step_Close, tick)
    return
 
## »ñµÃ¾­Ñé
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param addExp »ñµÃµÄ¾­Ñé
#  @param expViewType ¾­ÑéÀàÐÍ
#  @return True or False
def OnGetExp(curPlayer, addExp, expViewType):
    
    if expViewType != ShareDefine.Def_ViewExpType_KillNPC:
        return
    
    playerID = curPlayer.GetID() 
    gameFB = GameWorld.GetGameFB()
    exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp)
    expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint)
    totalExp = expPoint * ChConfig.Def_PerPointValue + exp
    updTotalExp = totalExp + addExp
    updExp = updTotalExp % ChConfig.Def_PerPointValue
    updExpPoint = updTotalExp / ChConfig.Def_PerPointValue
    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExp, updExp)
    gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExpPoint, updExpPoint)
    
    
    GameWorld.DebugLog("OnGetExp() totalExp=%s,addExp=%s,updTotalExp=%s" 
                       % (totalExp, addExp, updTotalExp), playerID)
    
    return
 
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼­ÓÉÍâ²ã¾ö¶¨
#  @param attacker ¹¥»÷·½
#  @param defender ·ÀÊØ·½
#  @return bool
def CheckCanAttackTagObjInFB(attacker, defender):
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetFBStep() != FB_Step_Fighting:
        return False
    return True
 
def __OnKillNPC(curNPC, tick):
    gameFB = GameWorld.GetGameFB()
    npcid = curNPC.GetNPCID()
    npcCfg = GetIceLodeNPCCfg()
    isfbnpc = False
    for npcInfo in npcCfg:
        if npcid == npcInfo[DL_NPCID]:
            isfbnpc = True
            break
    if not isfbnpc:
        return
    
    remainNPCCnt = max(0, gameFB.GetGameFBDictByKey(FBPlayerDict_RemainNPCCnt) - 1)
    gameFB.SetGameFBDict(FBPlayerDict_RemainNPCCnt, remainNPCCnt)
    GameWorld.DebugLog('__OnKillNPC remainNPCCnt=%s'%remainNPCCnt)
    if remainNPCCnt <=0 or npcid in IpyGameDataPY.GetFuncEvalCfg('IceLodeSpecial'):
        __DoIceLodeOver(True)
    return
 
def DoFB_NPCDead(curNPC):
    __OnKillNPC(curNPC, GameWorld.GetGameWorld().GetTick())
    return
 
#def DoFB_Npc_KillNPC(attacker, curNPC, tick):
#    GameWorld.Log('__OnKillNPC 1111111111')
#    __OnKillNPC(attacker, curNPC, tick)
#    return
 
## Ö´Ðи±±¾É±¹ÖÂß¼­
#  @param curPlayer É±¹ÖµÄÈË
#  @param curNPC ±»É±µÄ¹Ö
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
#    GameWorld.Log('__OnKillNPC 2222222222')
#    __OnKillNPC(curPlayer, curNPC, tick)
#    
    
#    addPoint = GetPointByNPCID(npcid)
#    if not addPoint:
#        return
#    totalPoint = gameFB.GetGameFBDictByKey(FBPlayerDict_TotalPoint)
#    maxPoint = IpyGameDataPY.GetFuncCfg('IceLodeNeedPoint')
#    updPoint = min(totalPoint + addPoint, maxPoint)
#    gameFB.SetGameFBDict(FBPlayerDict_TotalPoint, updPoint)
#    
#    if updPoint >= maxPoint:
#        costTime = tick - GameWorld.GetGameFB().GetFBStepTick()
#        gameFB.SetGameFBDict(FBPlayerDict_CostTime, costTime)
#        FBCommon.SetFBStep(FB_Step_PickItem, tick)
#        mapID = GameWorld.GetMap().GetMapID()
#        curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000, True)
#        
#        FBCommon.ClearFBNPC()
#        npcCfg = GetIceLodeNPCCfg()
#        for npcInfo in npcCfg:
#            NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick)
#        
#        #__DoIceLodeOver(True)
    
    #DoFBHelp(curPlayer, tick)
    return
 
## ÊÇ·ñ¸±±¾¸´»î
#  @param None
#  @return ÊÇ·ñ¸±±¾¸´»î
def OnPlayerReborn():
    return True
 
## ¸±±¾½áÊø´¦Àí
def __DoIceLodeOver(isPass):
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetFBStep() == FB_Step_Over:
        return
    tick = GameWorld.GetGameWorld().GetTick()
    curPlayer = None
    playerManager = GameWorld.GetMapCopyPlayerManager()
    if playerManager.GetPlayerCount() > 0:
        curPlayer = playerManager.GetPlayerByIndex(0)
        
    if not curPlayer:
        GameWorldProcess.CloseFB(tick)
        return
    
    __UpdIceLoadFBStar(tick) # ½áËãǰ¸üÐÂÒ»´ÎÐǼ¶
    playerID = curPlayer.GetPlayerID()
    lineID = FBCommon.GetFBPropertyMark()
    star = GameWorld.GetGameFB().GetGameFBDictByKey(FBPlayerDict_FBStar)
    mapID = ChConfig.Def_FBMapID_IceLode
    isInFBOnDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeIsInFBOnDay)
    #¸üÐÂÐǼ¶
    lastStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [mapID])
    if isPass and star > lastStar:
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, star, False, [mapID])
        FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapID) # Í¬²½ÐÅÏ¢
        if not lastStar and not isInFBOnDay: #ÿÈջ
            PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_IceLode)
            PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_IceLode, 1)
            PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_IceLode, 1)
    
    if isInFBOnDay: #ÔÚ¸±±¾Àï¹ýÌ죬¸±±¾½áÊøºóÔÙ²¹·¢ÐǼ¶½±Àø
        CheckIceLodeStarAwardMail(curPlayer)
#    exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp)
#    expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint)
#    totalExp = expPoint * ChConfig.Def_PerPointValue + exp
    
    costTime = gameFB.GetGameFBDictByKey(FBPlayerDict_CostTime)
    if not costTime:
        costTime = tick - GameWorld.GetGameFB().GetFBStepTick()
    #jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, [])
    overDict = {FBCommon.Over_isPass:int(isPass), FBCommon.Over_costTime:costTime}
    if isPass:
        itemList = FBCommon.GetFBLineReward(mapID, lineID)
        # ¸øÎïÆ·
        needSpace = len(itemList)
        packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
        if needSpace > packSpace:
            PlayerControl.SendMailByKey('', [curPlayer.GetID()], itemList)
        else:
            for itemID, itemCount, isBind in itemList:
                ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
        
        jsonItemList = FBCommon.GetJsonItemList(itemList)
        overDict[FBCommon.Over_itemInfo] = jsonItemList
        EventShell.EventRespons_FBEvent(curPlayer, 'icelode')
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_IceLode, 1)
        
    # Í¨Öª½á¹û
    __SendIceLodeOverInfo(curPlayer, overDict)
    
    # ½øÈëÀ뿪½×¶Î
    FBCommon.SetFBStep(FB_Step_Over, tick)
    FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttLeaveMap, FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000)
    
    # Çå¹Ö£¬¹Ø±ÕË¢¹Ö
#    FBCommon.ClearFBNPC()
#    npcCfg = GetIceLodeNPCCfg()
#    for npcInfo in npcCfg:
#        NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick)
    
    return
 
## ·¢ËÍÌôÕ½½á¹ûÐÅÏ¢£¬É¨µ´½á¹ûͨÓÃ
def __SendIceLodeOverInfo(curPlayer, overDict):
    overDict[FBCommon.Over_dataMapID] = ChConfig.Def_FBMapID_IceLode
    GameWorld.DebugLog("__SendIceLodeOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID())
    
    FBCommon.Notify_FB_Over(curPlayer, overDict)
    return
 
 
## ¸±±¾ÐÐΪ
#  @param curPlayer Íæ¼Ò
#  @param actionType ÐÐΪÀàÐÍ
#  @param actionInfo ÐÐΪÐÅÏ¢
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def DoFBAction(curPlayer, actionType, actionInfo, tick):
    
    return
 
## ¿É·ñɨµ´
def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
    if curPlayer.GetMapID() == ChConfig.Def_FBMapID_IceLode:
        GameWorld.DebugLog('±ù¾§¿óÂöɨµ´  ¸±±¾Àï²»ÄÜɨµ´ ')
        return
    #Õ½Á¦ÅжÏ
    LVIpyData = PlayerControl.GetPlayerLVIpyData(curPlayer.GetLV())
    reFightPower = 0 if not LVIpyData else LVIpyData.GetIceLodeFightPower() # µ±Ç°µÈ¼¶²Î¿¼Õ½Á¦
    if PlayerControl.GetFightPower(curPlayer) < reFightPower:
        GameWorld.DebugLog('±ù¾§¿óÂöɨµ´ Õ½Á¦²»×ã %s'%(reFightPower))
        return
    #vipÅжÏ
    if curPlayer.GetVIPLv() < IpyGameDataPY.GetFuncCfg('IceLodeCfg', 5):
        GameWorld.DebugLog('±ù¾§¿óÂöɨµ´ vip²»×ã ')
        return
    
    #Ç®
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeHasSweep):
        costMoney = IpyGameDataPY.GetFuncCfg('IceLodeCfg', 3)
    else:
        costMoney = 0
    if costMoney:
        costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
        if not costMoneyList:
            return
        for moneyType, moneyNum in costMoneyList:
            if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep):
                GameWorld.DebugLog("±ù¾§¿óÂöɨµ´ÏÉÓñ²»×ã!costGold=%s" % (costMoney))
                return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeHasSweep, 1)
    
    SyncIceLoddInfo(curPlayer)
    return True
 
## É¨µ´½á¹û
def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
    itemList = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 4)
    jsonItemList = FBCommon.GetJsonItemList(itemList)
    needSpace = len(itemList)
    if needSpace > ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace):
        PlayerControl.SendMailByKey(0, [curPlayer.GetID()], itemList)
    else:
        for itemID, itemCnt, isBind in itemList:
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
    #Ö±½Ó½«5ÌõÏßÐǼ¶¸ÄΪ3ÐÇ
    addCnt = 0
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    for lineid in lineList:
        curStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineid, False, [mapID])
        if curStar == 0:
            addCnt += 1
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineid, 3, False, [mapID])
    PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_IceLode, addCnt)
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_IceLode, addCnt)
    PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_IceLode, addCnt)
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_IceLode, len(lineList))
    FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapID) # Í¬²½ÐÅÏ¢
#    npcCountDict = {}
#    iceLodeSweepDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeSweep')
#    for npcID, count in iceLodeSweepDict.items():
#        npcCountDict[npcID] = count * sweepCnt
#        
#    exp_rate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Sweep)
#    jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, mapID, npcCountDict, exp_rate)
    GameWorld.DebugLog("ɨµ´½±Àø: ´ÎÊý=%s,jsonItemList=%s" % (sweepCnt, jsonItemList))
    overDict = {FBCommon.Over_isPass:1, FBCommon.Over_isSweep:1, FBCommon.Over_itemInfo:jsonItemList}
    __SendIceLodeOverInfo(curPlayer, overDict)
    for _ in xrange(sweepCnt):
        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start)
    return True
 
 
def GetIceLodeStarAward(curPlayer, starIndex):
    ## ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('IceLodeStarAward', {'Index':starIndex}, True)
    if not ipyDataList:
        return
    playerLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
    #playerLV = curPlayer.GetLV()
    awardList = []
    needStar = 0
    for ipyData in ipyDataList:
        lvLimit = ipyData.GetLVLimit()
        if lvLimit[0]<=playerLV <=lvLimit[1]:
            awardList = ipyData.GetItemList()
            needStar = ipyData.GetStar()
            break
    if not awardList:
        GameWorld.Log('    ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬Ã»ÕÒµ½½±Àø starIndex=%s,playerLV=%s'%(starIndex,playerLV), curPlayer.GetID())
        return
    awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
    if awardRecord & pow(2, starIndex):
        GameWorld.DebugLog('ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬ ½±ÀøÒÑÁìÈ¡ starIndex=%s'%starIndex)
        return
    
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    if starCnt < needStar:
        GameWorld.DebugLog('ÁìÈ¡±ù¾§¿óÂöÐǼ¶½±Àø£¬ ×ÜÐÇÊý²»×ãstarIndex=%s  starCnt=%s£¬needStar=%s'%(starIndex,starCnt,needStar))
        return
            
    # ¼ì²é±³°ü
    needSpace = len(awardList)
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    if needSpace > packSpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
        return
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeStarAwardRecord, awardRecord|pow(2, starIndex))
    
    for itemID, itemCount, isBind in awardList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
    #֪ͨ
    SyncIceLoddInfo(curPlayer)
    return
 
def GetIceLodeAllStarCnt(curPlayer):
    ##»ñÈ¡µ±Ç°×ÜÐÇÊý
    maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
    starCnt = 0
    lineList = []
    for i in xrange(maxCnt):
        if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_IceLoadLineID, i):
            starCnt += GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, i, False, [ChConfig.Def_FBMapID_IceLode])
            lineList.append(i)
    if lineList and len(lineList) != randomCnt:
        GameWorld.ErrLog('    ±ù¾§¿óÂö»ñÈ¡µ±Ç°×ÜÐÇÊý£¬µ±Ç°Ïß·ÊýÁ¿Òì³££¡lineList=%s'%lineList)
    return starCnt, lineList[:randomCnt]
 
def CheckIceLodeStarAwardMail(curPlayer):
    #Óʼþ²¹·¢Î´ÁìÈ¡ÐǼ¶½±Àø
    serverTime = GameWorld.GetCurrentTime()
    curDateTimeStr = "%d-%d-%d 00:00:00" % (serverTime.year, serverTime.month, serverTime.day)
    curDateTime = datetime.datetime.strptime(curDateTimeStr, ChConfig.TYPE_Time_Format)
    curDateTime = int(time.mktime(curDateTime.timetuple()))
    lastCheckTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeLastCheckTime)
    if lastCheckTime and lastCheckTime == curDateTime:
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeLastCheckTime, curDateTime)
    
    itemList = []
    mailStarList = []
    awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
    playerLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    ipyMgr = IpyGameDataPY.IPY_Data()
    newRecord = awardRecord
    for i in xrange(ipyMgr.GetIceLodeStarAwardCount()):
        ipyData = ipyMgr.GetIceLodeStarAwardByIndex(i)
        starIndex = ipyData.GetIndex()
        lvLimit = ipyData.GetLVLimit()
        if lvLimit[0]<=playerLV <=lvLimit[1]:
            if starCnt >= ipyData.GetStar() and not awardRecord & pow(2, starIndex):
                itemList += ipyData.GetItemList()
                newRecord |= pow(2, starIndex)
                mailStarList.append(starIndex)
    if itemList:
        PlayerControl.SendMailByKey('IceLodeStarReward', [curPlayer.GetID()], itemList, detail=mailStarList)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeIsInFBOnDay, 0)
    maxCnt, randomCnt = IpyGameDataPY.GetFuncEvalCfg('IceLodeCfg', 2)
    for i in xrange(maxCnt):
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, i, 0, False, [ChConfig.Def_FBMapID_IceLode])
    FBCommon.Sync_FBPlayerFBInfoData(curPlayer, ChConfig.Def_FBMapID_IceLode) # Í¬²½ÐÅÏ¢
    #ÖØÖÃÁì½±¼Ç¼
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeStarAwardRecord, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IceLodeHasSweep, 0)
    #Ëæ»ú½ñÈÕÍæ·¨
    __RandomLine(curPlayer, lineList)
    #֪ͨ
    SyncIceLoddInfo(curPlayer)
    return True
 
def SyncIceLoddInfo(curPlayer):
    starCnt, lineList = GetIceLodeAllStarCnt(curPlayer)
    packdata = ChPyNetSendPack.tagMCIceLodeInfo()
    packdata.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeStarAwardRecord)
    packdata.DayLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeDayLV)
    packdata.HasSweep = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IceLodeHasSweep)
    packdata.LineList = lineList
    packdata.Cnt = len(packdata.LineList)
    NetPackCommon.SendFakePack(curPlayer, packdata)
    return