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
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerActXianXiaMJ
#
# @todo:ÏÉÏ»Ãؾ³
# @author hxp
# @date 2021-05-26
# @version 1.0
#
# ÏêϸÃèÊö: ÏÉÏ»Ãؾ³
#
#-------------------------------------------------------------------------------
#"""Version = 2021-05-26 11:30"""
#-------------------------------------------------------------------------------
 
import PyGameData
import ShareDefine
import PlayerControl
import IpyGameDataPY
import ItemControler
import CrossRealmPlayer
import PlayerBillboard
import ChPyNetSendPack
import NetPackCommon
import PlayerActTask
import ItemCommon
import GameWorld
import ChConfig
 
Def_SuperLibType = 9 # ´ó½±¿âÀàÐ͹̶¨Îª9
 
def OnMixFirstLogin(curPlayer):
    
    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_XianXiaMJ, {}).values():
        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
        if not actInfo.get(ShareDefine.ActKey_State):
            continue
        score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)
        if not score:
            continue
        GameWorld.Log("ÏÉÏ»Ãؾ³ºÏ·þÊ×µÇͬ²½»ý·Ö°ñµ¥: actNum=%s,score=%s" % (actNum, score), curPlayer.GetPlayerID())
        PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_XianXiaMJScore, score, autoSort=True)
        break
    
    return
 
def OnPlayerLogin(curPlayer):
    
    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_XianXiaMJ, {}).values():
        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
        isReset = __CheckPlayerXianXiaMJAction(curPlayer, actNum)
        if not isReset:
            # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢
            if actInfo.get(ShareDefine.ActKey_State):
                Sync_XianXiaMJActionInfo(curPlayer, actNum)
                Sync_XianXiaMJLayerInfo(curPlayer, actNum)
                
    if not __CheckPlayerCrossActXianXiaMJ(curPlayer):
        Sync_CrossActXianXiaMJActionInfo(curPlayer)
        
    return
 
def RefreshXianXiaMJActionInfo(actNum):
    ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢
    playerManager = GameWorld.GetPlayerManager()
    for index in xrange(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not GameWorld.IsNormalPlayer(curPlayer):
            continue
        __CheckPlayerXianXiaMJAction(curPlayer, actNum)
    return
 
def __CheckPlayerXianXiaMJAction(curPlayer, actNum):
    ## ¼ì²éÍæ¼Ò»î¶¯Êý¾ÝÐÅÏ¢
    
    playerID = curPlayer.GetPlayerID()
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    actID = actInfo.get(ShareDefine.ActKey_ID, 0)
    state = actInfo.get(ShareDefine.ActKey_State, 0)
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
    
    playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJID % actNum) # Íæ¼ÒÉíÉϵĻID
    
    # »î¶¯ID ÏàͬµÄ»°²»´¦Àí
    if actID == playerActID:
        GameWorld.DebugLog("ÏÉÏ»Ãؾ³»î¶¯ID²»±ä£¬²»´¦Àí£¡actNum=%s,actID=%s" % (actNum, actID), playerID)
        
        layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)
        if state and layerNum <= 0:
            GameWorld.Log("ÏÉÏ»Ãؾ³»î¶¯Öе«Êײ㽱³Øδˢгõʼ»¯£¬³¢ÊÔˢУ¡actNum=%s,actID=%s" % (actNum, actID), playerID)
            __InitFirstLayerData(curPlayer, actNum, actInfo)
            
        return
    
    actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
    
    GameWorld.DebugLog("ÏÉÏ»Ãؾ³ÖØÖÃ! actNum=%s,actID=%s,playerActID=%s,state=%s,cfgID=%s" 
                       % (actNum, actID, playerActID, state, cfgID), playerID)
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJID % actNum, actID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJWorldLV % actNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJLayerNum % actNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJScore % actNum, 0)
    
    if state:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJWorldLV % actNum, actWorldLV)
        Sync_XianXiaMJActionInfo(curPlayer, actNum)
        __InitFirstLayerData(curPlayer, actNum, actInfo)
    return True
 
def __InitFirstLayerData(curPlayer, actNum, actInfo):
    ## ³õʼ»¯ÊײãÊý¾Ý
    
    state = actInfo.get(ShareDefine.ActKey_State, 0)
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
    
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID) if cfgID else None
    templateID = ipyData.GetTemplateID() if ipyData else 0
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID) if templateID else []
    if awardIpyDataList:
        for awardIpyData in awardIpyDataList:
            libType = awardIpyData.GetAwardLibType()
            libItemCount = max(awardIpyData.GetAwardItemCountList())
            for num in xrange(libItemCount):
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), 0)
                
            itemAwardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()
            for itemID in itemAwardTimesTotalInfo.keys():
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID), 0)
                
        # »î¶¯ÖУ¬Éú³Éн±³Ø    
        if state:
            __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList)
            
    Sync_XianXiaMJLayerInfo(curPlayer, actNum)
    return True
 
def RefreshCrossActXianXiaMJInfo():
    ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢
    playerManager = GameWorld.GetPlayerManager()
    for index in xrange(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not GameWorld.IsNormalPlayer(curPlayer):
            continue
        __CheckPlayerCrossActXianXiaMJ(curPlayer)
        
    return
 
def __CheckPlayerCrossActXianXiaMJ(curPlayer):
    
    playerID = curPlayer.GetPlayerID()
    
    actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
    actID = actInfo.get(ShareDefine.ActKey_ID, 0)
    state = actInfo.get(ShareDefine.ActKey_State, 0)
    dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)
    
    playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_XianXiaMJID) # Íæ¼ÒÉíÉϵĻID
    
    # »î¶¯ID ÏàͬµÄ»°²»´¦Àí
    if actID == playerActID:
        GameWorld.DebugLog("¿ç·þÏÉÏ»Ãؾ³»î¶¯ID²»±ä£¬²»´¦Àí£¡cfgID=%s,dayIndex=%s,actID=%s" % (cfgID, dayIndex, actID), playerID)   
        return
    GameWorld.DebugLog("¿ç·þÏÉÏ»Ãؾ³»î¶¯ÖØÖÃ! cfgID=%s,actID=%s,playerActID=%s,state=%s" % (cfgID, actID, playerActID, state), playerID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_XianXiaMJID, actID)
    
    if not state:
        CrossRealmPlayer.NotifyCrossActEnd(curPlayer, ShareDefine.CrossActName_XianXiaMJ)
        
    Sync_CrossActXianXiaMJActionInfo(curPlayer)
    return True
 
def SendToGameServer_XianXiaMJ(curPlayer, msgType, dataMsg=""):
    playerID = curPlayer.GetPlayerID()
    msgList = str([msgType, dataMsg])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "XianXiaMJ", msgList, len(msgList))
    GameWorld.Log("ÏÉÏ»Ãؾ³·¢ËÍGameServer: %s, %s" % (msgType, dataMsg), playerID)
    return
 
def AddPlayerLotteryScore(curPlayer, actNum, addScore, isRelationCrossAct):
    if addScore <= 0:
        return 0
    lotteryScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)
    updLotteryScore = lotteryScore + addScore
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJScore % actNum, updLotteryScore)
    PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_XianXiaMJScore, updLotteryScore, autoSort=True)
    SendToGameServer_XianXiaMJ(curPlayer, "AddLotteryScore", [addScore, updLotteryScore, isRelationCrossAct])
    return updLotteryScore
 
def GetLayerSetByList(layerNum, setList):
    if not setList:
        return 0
    return setList[layerNum - 1] if len(setList) >= layerNum else setList[-1]
 
#// AA 16 ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½± #tagCMActXianXiaMJSuperItem
#
#struct    tagCMActXianXiaMJSuperItem
#{
#    tagHead        Head;
#    BYTE        ActNum;        //»î¶¯±àºÅ
#    BYTE        SuperItemCount;    //Ñ¡ÔñÎïÆ·ÊýÁ¿
#    DWORD        SuperItemIDList[SuperItemCount];    //Ñ¡ÔñµÄ´ó½±¿âÎïÆ·IDÁÐ±í£¬Ã¿´ÎÖØÐÂÑ¡ÔñÐèÒª·¢ËÍÈ«²¿ÒÑÑ¡ÔñµÄ´ó½±ÎïÆ·ID£¬²»ÄÜÖ»·¢µ¥¸öÎïÆ·ID;
#};
def OnActXianXiaMJSuperItem(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    actNum = clientData.ActNum
    superItemIDList = clientData.SuperItemIDList
    
    GameWorld.DebugLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±: actNum=%s,superItemIDList=%s" % (actNum, superItemIDList))
    
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    if not actInfo.get(ShareDefine.ActKey_State):
        GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")
        return
    
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)
    if not ipyData:
        return
    
    templateID = ipyData.GetTemplateID()
    if not templateID:
        return
        
    layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)
    actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)
    if not awardIpyDataList:
        return
    
    superAwardIpyData = None
    for awardIpyData in awardIpyDataList:
        libType = awardIpyData.GetAwardLibType()
        if libType == Def_SuperLibType:
            superAwardIpyData = awardIpyData
            break
    
    if not superAwardIpyData:
        GameWorld.ErrLog("ûÓÐÅäÖÃÏÉÏ»Ãؾ³»î¶¯´ó½±¿â! cfgID=%s,actNum=%s,templateID=%s" % (cfgID, actNum, templateID))
        return
    
    superLibItemCount = GetLayerSetByList(layerNum, superAwardIpyData.GetAwardItemCountList())
    if len(superItemIDList) != superLibItemCount:
        GameWorld.ErrLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±¸öÊý´íÎó! cfgID=%s,actNum=%s,templateID=%s,layerNum=%s,superLibItemCount=%s,reqSuperItemIDList=%s" 
                         % (cfgID, actNum, templateID, layerNum, superLibItemCount, superItemIDList))        
        return
    
    posNumItemIDList = [] # ÒѳéÖеĴó½±ÎïÆ·ID
    libType = superAwardIpyData.GetAwardLibType()
    for num in xrange(superLibItemCount):
        itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
        if not itemInfoValue:
            break
        itemID, posNum = itemInfoValue / 100, itemInfoValue % 100
        if posNum and itemID not in superItemIDList:
            GameWorld.ErrLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ÒѳéÖеĴó½±IDΪ±ØÑ¡ID£¡ posNum=%s, itemID=%s not in superItemIDList=%s" 
                             % (posNum, itemID, superItemIDList))
            return
        
        if posNum:
            posNumItemIDList.append(itemID)
            
    GameWorld.DebugLog("    ÒѳéÖеĴó½±ID! %s" % posNumItemIDList)
    
    
    libItemDict = __GetXianXiaMJAwardLibItem(superAwardIpyData.GetLibItemInfo(), actWorldLV)
    layerLimitInfo = superAwardIpyData.GetItemLayerLimitInfo()
    awardTimesTotalInfo = superAwardIpyData.GetItemAwardTimesTotalInfo()
    
    replaceSuperItemIDList = [] # ÐèÒªÌæ»»µÄ´ó½±IDÁбí
    
    for selectItemID in superItemIDList:
        if selectItemID in posNumItemIDList:
            GameWorld.DebugLog("        ÒѳéÖеĴó½±ID£¬²»ÑéÖ¤£¡selectItemID=%s" % (selectItemID))
            continue
        
        if selectItemID not in libItemDict:
            GameWorld.ErrLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±ID²»´æÔڴ󽱿âÖУ¡ selectItemID=%s not in libItemDict=%s" 
                             % (selectItemID, libItemDict))
            return
        
        layerLimit = layerLimitInfo.get(selectItemID, 0)
        if layerLimit > layerNum:
            GameWorld.ErrLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±ID¸Ã²ã²»ÄÜÑ¡Ôñ£¡ selectItemID=%s layerLimit(%s) > layerNum(%s)" 
                             % (selectItemID, layerLimit, layerNum))
            return
        
        totalTimesLimit = awardTimesTotalInfo.get(selectItemID, 0)
        if totalTimesLimit:
            totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, selectItemID))
            if totalTimesNow >= totalTimesLimit:
                GameWorld.ErrLog("ÏÉÏ»Ãؾ³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±IDÒÑ´ïµ½×î´ó½±Àø´ÎÊý£¬²»ÄÜÑ¡Ôñ£¡ selectItemID=%s totalTimesNow(%s) >= totalTimesLimit(%s)" 
                                 % (selectItemID, totalTimesNow, totalTimesLimit))
                return
                
        replaceSuperItemIDList.append(selectItemID)
        
    GameWorld.DebugLog("    Ñé֤ͨ¹ý£¬¿ÉÌæ»»´ó½±ID! replaceSuperItemIDList=%s" % replaceSuperItemIDList)
    if not replaceSuperItemIDList:
        return
    
    for num in xrange(superLibItemCount):
        itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
        itemID, posNum = itemInfoValue / 100, itemInfoValue % 100
        if itemID in posNumItemIDList:
            GameWorld.DebugLog("        ÒѳéÖеĴó½±ID£¬²»Ìæ»»£¡itemID=%s" % (itemID))
            continue
        replaceSuperItemID = replaceSuperItemIDList.pop(0)
        updItemInfoValue = replaceSuperItemID * 100 + posNum
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), updItemInfoValue)
        GameWorld.DebugLog("        Ìæ»»´ó½±IDÑ¡Ôñ£¡num=%s,itemID=%s,posNum=%s,replaceSuperItemID=%s,updItemInfoValue=%s" 
                           % (num, itemID, posNum, replaceSuperItemID, updItemInfoValue))
        
        if not replaceSuperItemIDList:
            break
        
    Sync_XianXiaMJLayerInfo(curPlayer, actNum)
    return
 
#// AA 18 ÏÉÏ»Ãؾ³»î¶¯½±³ØˢР#tagCMActXianXiaMJAwardPoolRefresh
#
#struct    tagCMActXianXiaMJAwardPoolRefresh
#{
#    tagHead        Head;
#    BYTE        ActNum;        //»î¶¯±àºÅ
#};
def OnActXianXiaMJAwardPoolRefresh(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    actNum = clientData.ActNum
    
    GameWorld.DebugLog("ÏÉÏ»Ãؾ³»î¶¯½±³ØË¢ÐÂ: actNum=%s" % (actNum))
    
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    if not actInfo.get(ShareDefine.ActKey_State):
        GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")
        return
    
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)
    if not ipyData:
        return
    
    templateID = ipyData.GetTemplateID()
    if not templateID:
        return
    
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)
    if not awardIpyDataList:
        return
    
    if not __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList):
        return
    
    Sync_XianXiaMJLayerInfo(curPlayer, actNum)
    return
 
def __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList):
    ## Ë¢Ð½±³ØÎïÆ·
    
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
    actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)
    layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)
    
    GameWorld.DebugLog("Ë¢ÐÂÏÉÏ»Ãؾ³½±³ØÎïÆ·: cfgID=%s,actNum=%s,actWorldLV=%s,layerNum=%s" % (cfgID, actNum, actWorldLV, layerNum))
    
    if layerNum:
        # ·Ç0²ã£¬ÑéÖ¤´ó½±ÊÇ·ñÒѳéÍ꣬³éÍê²Å¿ÉÒÔˢн±³Ø²ã
        superLib = False
        for awardIpyData in awardIpyDataList:
            libType = awardIpyData.GetAwardLibType()
            if libType != Def_SuperLibType:
                continue
            superLib = True
            libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())
            for num in xrange(libItemCount):
                itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
                if not itemInfoValue:
                    GameWorld.ErrLog("δѡÔñ´ó½±£¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,num=%s" 
                                     % (cfgID, actNum, layerNum, num))
                    return
                itemID, posNum = itemInfoValue / 100, itemInfoValue % 100
                if itemID and not posNum:
                    GameWorld.ErrLog("Óдó½±Î´³éÖУ¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,num=%s,itemID=%s,posNum=%s" 
                                     % (cfgID, actNum, layerNum, num, itemID, posNum))
                    return
            break
        if not superLib:
            GameWorld.ErrLog("½±³ØÅäÖÃûÓд󽱿⣡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,superLib=%s" % (cfgID, actNum, layerNum, superLib))
            return
        
    layerNum = min(layerNum + 1, 65530) # ¿Éˢн±³Ø£¬Ä¬ÈÏ+1²ã
    GameWorld.DebugLog("    ¿Éˢн±³Ø£¡ÏÂÒ»²ã: layerNum=%s" % (layerNum))
    
    refreshLibDict = {}
    for awardIpyData in awardIpyDataList:
        libType = awardIpyData.GetAwardLibType()
        libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())
        libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)
        layerLimitInfo = awardIpyData.GetItemLayerLimitInfo()
        awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()
        
        canRandItemDict = {}
        for itemID, libItemInfo in libItemDict.items():
            _, weight = libItemInfo
            
            layerLimit = layerLimitInfo.get(itemID, 0)
            if layerLimit > layerNum:
                GameWorld.DebugLog("        ¸Ã²ã²»ÄÜÑ¡Ôñ¸Ã½±Æ·£¡ itemID=%s layerLimit(%s) > layerNum(%s)" 
                                 % (itemID, layerLimit, layerNum))
                continue
            
            totalTimesLimit = awardTimesTotalInfo.get(itemID, 0)
            if totalTimesLimit:
                totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))
                if totalTimesNow >= totalTimesLimit:
                    GameWorld.DebugLog("        ½±Æ·IDÒÑ´ïµ½×î´ó½±Àø´ÎÊý£¬²»ÄÜÑ¡Ôñ£¡ itemID=%s totalTimesNow(%s) >= totalTimesLimit(%s)" 
                                       % (itemID, totalTimesNow, totalTimesLimit))
                    continue
                
            canRandItemDict[itemID] = [weight, itemID]
            
        if libItemCount > len(canRandItemDict):
            GameWorld.ErrLog("½±Æ·¿âÅäÖÿÉÑ¡Ôñ½±Æ·¸öÊý²»¹»£¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,libType=%s,layerNum=%s,libItemCount=%s > %s canRandItemDict(%s)" 
                             % (cfgID, actNum, libType, layerNum, libItemCount, len(canRandItemDict), canRandItemDict))
            return
        
        refreshLibDict[libType] = [libItemCount, canRandItemDict]
        
    for libType, refreshInfo in refreshLibDict.items():
        libItemCount, canRandItemDict = refreshInfo
        GameWorld.DebugLog("    Ëæ»ú½±³ØÎïÆ·: libType=%s,libItemCount=%s,canRandItemDict=%s, %s" % (libType, libItemCount, len(canRandItemDict), canRandItemDict))
        
        if libType == Def_SuperLibType:
            # ´ó½±Ö±½ÓÖØÖã¬ÏµÍ³²»Éú³É£¬ÓÉÍæ¼ÒÊÖ¶¯Ñ¡Ôñ
            for num in xrange(libItemCount):
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), 0)
            continue
        
        for num in xrange(libItemCount):
            weightList = canRandItemDict.values()
            randItemID = GameWorld.GetResultByWeightList(weightList)
            canRandItemDict.pop(randItemID, None)
            
            posNum = 0
            itemInfoValue = randItemID * 100 + posNum
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), itemInfoValue)
            GameWorld.DebugLog("        Ëæ»úÉú³É½±Æ·! libType=%s,num=%s,randItemID=%s" % (libType, num, randItemID))
            
    playCount = 0 # Ã¿²ãÖØÖó齱´ÎÊý
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJLayerNum % actNum, layerNum)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, playCount)
    GameWorld.DebugLog("    Ë¢ÐÂÍê³É! layerNum=%s,playCount=%s" % (layerNum, playCount))
    PlayerActTask.UpdActTaskValue(curPlayer, ChConfig.ActTaskType_XianXiaMJLayer, layerNum)
    if layerNum > 1:
        AddPlayerLotteryScore(curPlayer, actNum, ipyData.GetLayerAddScore(), ipyData.GetIsRelationCrossAct())
    return True
 
#// AA 17 ÏÉÏ»Ãؾ³»î¶¯³é½± #tagCMActXianXiaMJLottery
#
#struct    tagCMActXianXiaMJLottery
#{
#    tagHead        Head;
#    BYTE        ActNum;        //»î¶¯±àºÅ
#    BYTE        PosNum;        //Íæ¼Òµã»÷µÄ½±ÀøλÖñàºÅ£¬´Ó1¿ªÊ¼
#};
def OnActXianXiaMJLottery(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    actNum = clientData.ActNum
    reqPosNum = clientData.PosNum
    
    GameWorld.DebugLog("ÏÉÏ»Ãؾ³»î¶¯³é½±: actNum=%s,reqPosNum=%s" % (actNum, reqPosNum))
    
    if reqPosNum <= 0:
        return
    
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    if not actInfo.get(ShareDefine.ActKey_State):
        GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")
        return
        
    playerID = curPlayer.GetPlayerID()
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)
    if not ipyData:
        return
    
    if ipyData.GetIsRelationCrossAct():
        crossActInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)
        if crossActInfo.get(ShareDefine.ActKey_State, 0):
            if crossActInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:
                GameWorld.Log("¿ç·þÏÉÏ»Ãؾ³·Ç²ÎÓë»î¶¯ÖÐ: actNum=%s" % actNum, playerID)
                return
    else:
        if actInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:
            GameWorld.Log("ÏÉÏ»Ãؾ³·Ç²ÎÓë»î¶¯ÖÐ: actNum=%s" % actNum, playerID)
            return
        
    templateID = ipyData.GetTemplateID()
    if not templateID:
        return
    
    actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)
    if not awardIpyDataList:
        return
    
    checkUseMoney = False
    costItemID = ipyData.GetUseItemID()
    costItemCount = 1
    if costItemID:
        costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)
        lackCnt = costItemCount - bindCnt - unBindCnt
        if lackCnt > 0:
            checkUseMoney = True
    else:
        checkUseMoney = True
        
    costMoneyType, costMoneyValue = ipyData.GetUseMoneyInfo()
    if checkUseMoney:
        if not costMoneyType or not costMoneyValue:
            return
        if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):
            GameWorld.DebugLog("    »õ±Ò²»×㣬ÎÞ·¨³é½±! costMoneyType=%s,costMoneyValue(%s) > curMoneyValue(%s)" 
                               % (costMoneyType, costMoneyValue, PlayerControl.GetMoney(curPlayer, costMoneyType)))
            return
        
    layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)
    playCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJPlayCount % actNum)
    GameWorld.DebugLog("layerNum=%s,playCount=%s" % (layerNum, playCount))
    
    posNumMax = 0
    randLibItemDict = {}
    for awardIpyData in awardIpyDataList:
        libType = awardIpyData.GetAwardLibType()
        libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())
        unlockLimitTimes = GetLayerSetByList(layerNum, awardIpyData.GetUnlockAwardLimitTimesList())
        libWeight = GetLayerSetByList(layerNum, awardIpyData.GetAwardLibWeightList())
        posNumMax += libItemCount
        
        if libType == Def_SuperLibType:
            for num in xrange(libItemCount):
                itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
                if not itemInfoValue:
                    GameWorld.DebugLog("    Î´Ñ¡Ôñ´ó½±£¡ÎÞ·¨³é½±! libType=%s,num=%s,itemInfoValue=%s" % (libType, num, itemInfoValue))         
                    return
                
        if unlockLimitTimes and playCount < unlockLimitTimes:
            GameWorld.DebugLog("    ¸Ã¿âµ±Ç°³é½±´ÎÊýÎÞ·¨½âËø! libType=%s,playCount(%s) < unlockLimitTimes(%s)" % (libType, playCount, unlockLimitTimes))
            continue
        
        awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()
        libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)
        canRandItemList = []
        for num in xrange(libItemCount):
            itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
            if not itemInfoValue:            
                return
            
            itemID, posNum = itemInfoValue / 100, itemInfoValue % 100
            if itemID not in libItemDict:
                continue
            
            if posNum:
                GameWorld.DebugLog("    ¸Ã½±Æ·Òѱ»³éÖÐ! libType=%s,itemID=%s,posNum=%s" % (libType, itemID, posNum))
                if posNum == reqPosNum:
                    GameWorld.ErrLog("    ¸ÃλÖÃÒѾ­Óг齱½á¹û£¬ÎÞ·¨Öظ´Ñ¡Ôñ³é½±! libType=%s,num=%s,itemInfoValue=%s,posNum=%s" 
                                     % (libType, num, itemInfoValue, posNum))                
                    return                
                continue
            
            itemCount, weight = libItemDict[itemID]
            isAddTimes = (itemID in awardTimesTotalInfo)
            canRandItemList.append([weight, itemID, itemCount, num, isAddTimes])
            
        if canRandItemList:
            randLibItemDict[libType] = [libWeight, libType, canRandItemList]
            GameWorld.DebugLog("    ¸Ã¿âÓлú»á³éµ½ÎïÆ·: libType=%s,libWeight=%s,canRandItemList=%s" % (libType, libWeight, canRandItemList))
        else:
            GameWorld.DebugLog("    ¸Ã¿âÎïÆ·ÒÑÈ«±»³éÍê: libType=%s,libWeight=%s,canRandItemList=%s" % (libType, libWeight, canRandItemList))
            
    if reqPosNum > posNumMax:
        GameWorld.DebugLog("    ÇëÇóλÖÃÒì³££¬ÎÞ·¨³é½±! reqPosNum(%s) > posNumMax(%s)" % (reqPosNum, posNumMax))
        return
    
    if not randLibItemDict:
        GameWorld.DebugLog("    Ã»Óпɳ齱µÄ½±Æ·ÁË£¬ÎÞ·¨³é½±!")
        return
    
    randLibInfo = GameWorld.GetResultByWeightList(randLibItemDict.values())
    if not randLibInfo:
        return
    libType, canRandItemList = randLibInfo
    randItemInfo = GameWorld.GetResultByWeightList(canRandItemList)
    if not randItemInfo:
        return
    itemID, itemCount, num, isAddTimes = randItemInfo
    
    # ¿Û³ýÏûºÄ
    if checkUseMoney:
        PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, "ActXianXiaMJ")
        GameWorld.DebugLog("ÏûºÄ»õ±Ò: costMoneyType=%s,costMoneyValue=%s" % (costMoneyType, costMoneyValue))
    else:
        GameWorld.DebugLog("ÏûºÄµÀ¾ß: costItemID=%s,costItemCount=%s %s" % (costItemID, costItemCount, costItemIndexList))
        ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, "XianXiaMJ")
        
    # ¸üÐÂÒѳéÖÐÖµ
    updItemInfoValue = itemID * 100 + reqPosNum
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), updItemInfoValue)
    
    totalTimesNow = 0
    if isAddTimes:
        totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID)) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID), totalTimesNow)
        
    playCount += 1
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, playCount)
    
    GameWorld.DebugLog("    ³éÖÐÎïÆ·: layerNum=%s,libType=%s,itemID=%s,itemCount=%s,num=%s,reqPosNum=%s,updItemInfoValue=%s,totalTimesNow=%s,playCount=%s" 
                       % (layerNum, libType, itemID, itemCount, num, reqPosNum, updItemInfoValue, totalTimesNow, playCount))
    
    # ¸øÎïÆ·
    isAuctionItem = 0
    itemList = [[itemID, itemCount, isAuctionItem]]
    ItemControler.GivePlayerItemOrMail(curPlayer, itemList, event=["XianXiaMJLottery", False, {}])
    
    # ÈÎÎñ
    PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_XianXiaMJLottery, 1)
    
    # ¹ã²¥
    if libType == Def_SuperLibType:
        PlayerControl.WorldNotify(0, "XianXiaMJ%s" % actNum, [curPlayer.GetPlayerName(), itemID, itemCount])
        
    # »ý·Ö
    lotteryScore = AddPlayerLotteryScore(curPlayer, actNum, ipyData.GetLotteryAddScore(), ipyData.GetIsRelationCrossAct())
    
    # Í¨Öª³é½±½á¹û
    clientPack = ChPyNetSendPack.tagMCActXianXiaMJAwardItemResult()
    clientPack.ActNum = actNum
    clientPack.ItemLibType = libType
    clientPack.ItemID = itemID
    clientPack.ItemCount = itemCount
    clientPack.PosNum = reqPosNum
    clientPack.TotalTimesNow = totalTimesNow
    clientPack.LotteryScore = lotteryScore
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def Sync_XianXiaMJActionInfo(curPlayer, actNum):
    ## Í¨Öª»î¶¯ÐÅÏ¢
    
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    if not actInfo.get(ShareDefine.ActKey_State):
        return
    
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)
    if not ipyData:
        return
    costMoneyType, costMoneyValue = ipyData.GetUseMoneyInfo()
    
    personalTempID = ipyData.GetPersonalTemplateID()
    personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJBillTemp", personalTempID) if personalTempID else []
    
    startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)
    
    clientPack = ChPyNetSendPack.tagMCActXianXiaMJInfo()
    clientPack.ActNum = actNum
    clientPack.StartDate = startDateStr
    clientPack.EndtDate = endDateStr
    clientPack.JoinStartTime = ipyData.GetJoinStartTime()
    clientPack.JoinEndTime = ipyData.GetJoinEndTime()
    clientPack.IsDayReset = ipyData.GetIsDayReset()
    clientPack.LimitLV = ipyData.GetLVLimit()
    clientPack.UseItemID = ipyData.GetUseItemID()
    clientPack.MoneyType = costMoneyType
    clientPack.MoneyValue = costMoneyValue
    clientPack.LotteryAddScore = ipyData.GetLotteryAddScore()
    clientPack.LayerAddScore = ipyData.GetLayerAddScore()
    
    clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)
    clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def __GetXianXiaMJAwardLibItem(libItemInfo, actWorldLV):
    ## »ñÈ¡½±Àø¿âÎïÆ·ÐÅÏ¢×ֵ䣬֧³Ö°´ÊÀ½çµÈ¼¶·¶Î§ÅäÖõĸñʽ
    keyList = libItemInfo.keys()
    if not keyList:
        return {}
    if isinstance(keyList[0], tuple) and len(keyList[0]) == 2:
        return GameWorld.GetDictValueByRangeKey(libItemInfo, actWorldLV, {})
    return libItemInfo
 
def Sync_XianXiaMJLayerInfo(curPlayer, actNum):
    
    actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)
    if not actInfo.get(ShareDefine.ActKey_State):
        return
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)
    if not ipyData:
        return
    
    templateID = ipyData.GetTemplateID()
    if not templateID:
        return
    actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)
    layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)
    
    clientPack = ChPyNetSendPack.tagMCActXianXiaMJLayerInfo()
    clientPack.ActNum = actNum
    clientPack.LayerNum = layerNum
    clientPack.LotteryScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)
    clientPack.AwardItemList = [] # ½±³ØÎïÆ·Áбí
    awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)
    if awardIpyDataList:
        for awardIpyData in awardIpyDataList:
            libType = awardIpyData.GetAwardLibType()
            libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())
            libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)
            layerLimitInfo = awardIpyData.GetItemLayerLimitInfo()
            awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()
            
            # ½±³ØÎïÆ·ÁÐ±í£¬ÒÑÉú³ÉµÄ£¬°üº¬ÒÑÑ¡ÔñµÄ´ó½±ÎïÆ·
            for num in xrange(libItemCount):
                itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))
                if not itemInfoValue:
                    break
                itemID, posNum = itemInfoValue / 100, itemInfoValue % 100
                if itemID not in libItemDict:
                    continue
                libItemInfo = libItemDict[itemID]
                
                layerItem = ChPyNetSendPack.tagMCActXianXiaMJLayerItem()
                layerItem.ItemLibType = libType
                layerItem.ItemID = itemID
                layerItem.ItemCount = libItemInfo[0]
                layerItem.PosNum = posNum
                layerItem.TotalTimesMax = awardTimesTotalInfo.get(itemID, 0)
                layerItem.TotalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))
                layerItem.LayerLimit = layerLimitInfo.get(itemID, 0)
                clientPack.AwardItemList.append(layerItem)
                
            # ´ó½±ÎïÆ·´ýÑ¡Ôñ¿â£¬È«²¿Í¬²½
            if libType == Def_SuperLibType:
                for itemID, libItemInfo in libItemDict.items():
                    layerItem = ChPyNetSendPack.tagMCActXianXiaMJLayerItem()
                    layerItem.ItemLibType = libType
                    layerItem.ItemID = itemID
                    layerItem.ItemCount = libItemInfo[0]
                    layerItem.TotalTimesMax = awardTimesTotalInfo.get(itemID, 0)
                    layerItem.TotalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))
                    layerItem.LayerLimit = layerLimitInfo.get(itemID, 0)
                    clientPack.SuperItemList.append(layerItem)
                clientPack.SuperItemCount = len(clientPack.SuperItemList)
                clientPack.SuperItemCanChooseCount = libItemCount
                
    clientPack.AwardItemCount = len(clientPack.AwardItemList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def Sync_CrossActXianXiaMJActionInfo(curPlayer):
    ## Í¨Öª»î¶¯ÐÅÏ¢
    actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)
    if not actInfo:
        return
    
    if not actInfo.get(ShareDefine.ActKey_State):
        return
    
    ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})
    if not ipyDataDict:
        return
    
    personalTempID = ipyDataDict.get("PersonalTemplateID", 0)
    personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJBillTemp", personalTempID) if personalTempID else []
    
    clientPack = ChPyNetSendPack.tagMCCrossActXianXiaMJInfo()
    clientPack.ServerIDRangeInfo = str(actInfo.get(ShareDefine.ActKey_ServerIDRangeList, []))
    clientPack.ServerInfoLen = len(clientPack.ServerIDRangeInfo)
    clientPack.GroupValue1 = ipyDataDict.get("ZoneID", 0)
    clientPack.StartDate = ipyDataDict.get("StartDate", "")
    clientPack.EndtDate = ipyDataDict.get("EndDate", "")
    clientPack.JoinStartTime = ipyDataDict.get("JoinStartTime", "")
    clientPack.JoinEndTime = ipyDataDict.get("JoinEndTime", "")
    clientPack.IsDayReset = ipyDataDict.get("IsDayReset", 0)
    
    clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)
    clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)
    
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def __GetTempRankBillPackList(ipyDataList):
    packBillList = []
    if not ipyDataList:
        return packBillList
    for tempIpyData in ipyDataList:
        rankInfo = ChPyNetSendPack.tagMCActXianXiaMJBillard()
        rankInfo.Rank = tempIpyData.GetRank()
        
        rankInfo.AwardItemList = []
        awardItemList = tempIpyData.GetAwardItemList()
        for itemID, itemCount, isAuctionItem in awardItemList:
            item = ChPyNetSendPack.tagMCActXianXiaMJItem()
            item.Clear()
            item.ItemID = itemID
            item.ItemCount = itemCount
            item.IsBind = isAuctionItem
            rankInfo.AwardItemList.append(item)
        rankInfo.Count = len(rankInfo.AwardItemList)
        
#        rankInfo.MemAwardItemList = []
#        memAwardItemList = tempIpyData.GetMemAwardItemList()
#        for itemID, itemCount, isAuctionItem in memAwardItemList:
#            item = ChPyNetSendPack.tagMCActXianXiaMJItem()
#            item.Clear()
#            item.ItemID = itemID
#            item.ItemCount = itemCount
#            item.IsBind = isAuctionItem
#            rankInfo.MemAwardItemList.append(item)
#        rankInfo.MemCount = len(rankInfo.MemAwardItemList)
        
        rankInfo.NeedScore = tempIpyData.GetNeedScore()
        rankInfo.AwardItemExList = []
        scoreAwardEx = tempIpyData.GetScoreAwardEx()
        scoreExList = scoreAwardEx.keys()
        scoreExList.sort()
        for scoreEx in scoreExList:
            itemExList = scoreAwardEx[scoreEx]
            awardEx = ChPyNetSendPack.tagMCActXianXiaMJAwardEx()
            awardEx.NeedScore = scoreEx
            awardEx.AwardItemList = []
            for itemID, itemCount, isAuctionItem in itemExList:
                item = ChPyNetSendPack.tagMCActXianXiaMJItem()
                item.Clear()
                item.ItemID = itemID
                item.ItemCount = itemCount
                item.IsBind = isAuctionItem
                awardEx.AwardItemList.append(item)
            awardEx.Count = len(awardEx.AwardItemList)
            
            rankInfo.AwardItemExList.append(awardEx)
        rankInfo.CountEx = len(rankInfo.AwardItemExList)
        
        packBillList.append(rankInfo)
    return packBillList