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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package PlayerActBossTrial
#
# @todo:bossÀúÁ·
# @author hxp
# @date 2023-10-20
# @version 1.0
#
# ÏêϸÃèÊö: bossÀúÁ·
#
#-------------------------------------------------------------------------------
#"""Version = 2023-10-20 16:00"""
#-------------------------------------------------------------------------------
 
import ShareDefine
import DataRecordPack
import PlayerCompensation
import PlayerDBGSEvent
import PlayerBillboard
import IpyGameDataPY
import GameWorld
import CrossRealmMsg
import CrossActionControl
import CrossBillboard
import PlayerFamily
import PyDataManager
import GameXiangong
import GameWorship
 
def OnActStart(actNum):
    ## »î¶¯¿ªÆô
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum, 0)
    PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_BossTrialSubmit)
    PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_BossTrialSubmitFamily)
    
    familyActionMgr = GameWorld.GetFamilyActionManager()
    familyManager = GameWorld.GetFamilyManager()
    for i in range(0, familyManager.GetCount()):
        family = familyManager.GetAt(i)
        familyID = family.GetID()
        familyActionMgr.DelFamilyAction(familyID, ShareDefine.Def_ActionType_BossTrialSubmit)
        
    return
 
def OnActEnd(actNum, ipyData, dayIndex):
    ## »î¶¯½áÊø
    cfgID = ipyData.GetCfgID() if ipyData else 0
    GameWorld.Log("=== bossÀúÁ·»î¶¯½áÊø£¡ === actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex))
    
    __OnEndAward(actNum, ipyData, dayIndex) # ¼æÈݻûÓÐÅäÖòÎÓëʱ¼ä¶ÎµÄÔڻ½áÊø²¹´¥·¢½áËã½±Àø
    
    PlayerBillboard.CopyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamilyBak, ShareDefine.Def_BT_BossTrialSubmitFamily)
    PlayerBillboard.CopyBillboard(ShareDefine.Def_BT_BossTrialSubmitBak, ShareDefine.Def_BT_BossTrialSubmit)
    GameWorld.Log("=================================================================================")
    return
 
def OnActInStateRefresh(actNum, ipyData, dayIndex):
    ## »î¶¯ÖÐˢУ¬Ã¿´Î¶¼ÐèҪˢеÄÂß¼­£¬°üº¬ÖضÁÅäÖõÈ
    if not ipyData:
        return
    cfgID = ipyData.GetCfgID()
    templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex)
    familyTemplateID = GameWorld.GetTemplateIDByList(ipyData.GetFamilyTemplateIDList(), dayIndex)
    
    billboardMgr = PlayerBillboard.GetBillboardMgr()
    if templateID:
        orderRuleList = GetOrderRuleList(templateID)
        billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmit)
        billboardObj.SetOrderRuleList(orderRuleList)
        
    if familyTemplateID:
        orderRuleList = GetOrderRuleList(familyTemplateID)
        billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmitFamily)
        billboardObj.SetOrderRuleList(orderRuleList)
    return
 
def OnActJoinEnd(actNum, ipyData, dayIndex):
    ## »î¶¯²ÎÓë½áÊø
    __OnEndAward(actNum, ipyData, dayIndex)
    return
 
def __OnEndAward(actNum, ipyData, dayIndex):
    ## ½áËã½±Àø
    if not ipyData:
        return
    cfgID = ipyData.GetCfgID()
    awardState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum)
    if awardState:
        #ÒѾ­½áËã¹ý¸Ã»î¶¯
        GameWorld.Log("bossÀúÁ·»î¶¯ÒѾ­½áËã¹ý½±ÀøÁË! actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex))
        return
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum, 1)
    
    GameWorld.Log("=== ±¾·þbossÀúÁ·»î¶¯·¢·Å°ñµ¥½±Àø£¡ === actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex))
    
    familyTemplateID = GameWorld.GetTemplateIDByList(ipyData.GetFamilyTemplateIDList(), dayIndex)
    __OnEndAward_Family(familyTemplateID, ShareDefine.Def_BT_BossTrialSubmitFamily)
    
    templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex)
    __OnEndAward_Personal(templateID, ShareDefine.Def_BT_BossTrialSubmit)
    
    # Á÷Ïò±¸·Ý     
    DataRecordPack.DR_BillboardData(ShareDefine.Def_BT_BossTrialSubmitFamily, "BossTrial", {"actNum":actNum, "cfgID":cfgID, "dayIndex":dayIndex})
    DataRecordPack.DR_BillboardData(ShareDefine.Def_BT_BossTrialSubmit, "BossTrial", {"actNum":actNum, "cfgID":cfgID, "dayIndex":dayIndex})
    GameWorld.Log("=================================================================================")
    return
 
def __OnEndAward_Personal(templateID, billboardType):
    billBoard = GameWorld.GetBillboard().FindBillboard(billboardType)
    if not billBoard:
        return
    if not templateID:
        GameWorld.Log("±¾´Î»î¶¯Ã»ÓиöÈË°ñ½±Àø!")
        return
    billboardDataCount = billBoard.GetCount()
    billBoard.Sort()
    
    GameWorld.Log("½áËã¸öÈË°ñµ¥½±Àø: billboardType=%s,templateID=%s,billboardDataCount=%s" % (billboardType, templateID, billboardDataCount))
    
    orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID)
    if not orderIpyDataList:
        return
    
    rankPre = 0
    billboardIndex = 0
    for ipyData in orderIpyDataList:
        rank = ipyData.GetRank()
        needScore = ipyData.GetNeedScore()
        scoreAwardEx = ipyData.GetScoreAwardEx()
        scoreAwardExList = scoreAwardEx.keys()
        scoreAwardExList.sort()
        awardItemList = ipyData.GetAwardItemList()
        orderCountTotal = rank - rankPre # ½±ÀøÃû´ÎÊýÁ¿
        rankPre = rank
        
        for index in xrange(billboardIndex, billboardDataCount):
            if orderCountTotal <= 0:
                break
            
            billBoardData = billBoard.At(index)
            playerID = billBoardData.GetID()
            name2 = billBoardData.GetName2()
            cmpValue = billBoardData.GetCmpValue()
            
            if cmpValue < needScore:
                GameWorld.Log("    »ý·Ö²»×ã¸Ã°ñµ¥ËùÐè»ý·Ö£¬Ìø¹ý¸ÃÃû´Î: index=%s,rank=%s,playerID=%s,cmpValue=%s < %s" % (index, rank, playerID, cmpValue, needScore))
                break
            
            awardItemExList = []
            for scoreEx in scoreAwardExList:
                if cmpValue < scoreEx:
                    break
                awardItemExList = scoreAwardEx[scoreEx] # È¡×î´óÂú×ãÌõ¼þµÄÒ»µµ
            finalAwardItemList = awardItemList + awardItemExList
            
            playerRank = rank - orderCountTotal + 1
            GameWorld.Log("    ·¢·ÅbossÀúÁ·¸öÈË°ñµ¥½±Àø: index=%s,rank=%s,playerRank=%s,playerID=%s,cmpValue=%s,awardItemList=%s,scoreAwardEx=%s,finalAwardItemList=%s, %s" 
                          % (index, rank, playerRank, playerID, cmpValue, awardItemList, scoreAwardEx, finalAwardItemList, name2))
            PlayerCompensation.SendMailByKey("BossTrialMail10", [playerID], finalAwardItemList, [playerRank])
            
            orderCountTotal -= 1
            billboardIndex += 1
        
    return
 
def __OnEndAward_Family(familyTemplateID, billboardType):
    billBoard = GameWorld.GetBillboard().FindBillboard(billboardType)
    if not billBoard:
        return
    if not familyTemplateID:
        GameWorld.Log("±¾´Î»î¶¯Ã»ÓÐÏÉÃË°ñ½±Àø!")
        return
    billboardDataCount = billBoard.GetCount()
    billBoard.Sort()
    
    GameWorld.Log("½áËãÏÉÃË°ñµ¥½±Àø: billboardType=%s,familyTemplateID=%s,billboardDataCount=%s" % (billboardType, familyTemplateID, billboardDataCount))
    
    orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", familyTemplateID)
    if not orderIpyDataList:
        return
    
    familyManager = GameWorld.GetFamilyManager()
    rankPre = 0
    billboardIndex = 0
    for ipyData in orderIpyDataList:
        rank = ipyData.GetRank()
        needScore = ipyData.GetNeedScore()
        leaderAwardItemList = ipyData.GetAwardItemList()
        memAwardItemList = ipyData.GetMemAwardItemList()
        orderCountTotal = rank - rankPre # ½±ÀøÃû´ÎÊýÁ¿
        rankPre = rank
        
        for index in xrange(billboardIndex, billboardDataCount):
            if orderCountTotal <= 0:
                break
            
            billBoardData = billBoard.At(index)
            familyID = billBoardData.GetID()
            cmpValue = billBoardData.GetCmpValue()
            
            if cmpValue < needScore:
                GameWorld.Log("    ²»×ã¸Ã°ñµ¥ËùÐèÌá½»Êý£¬Ìø¹ý¸ÃÃû´Î: index=%s,rank=%s,familyID=%s,cmpValue=%s < %s" % (index, rank, familyID, cmpValue, needScore))
                break
            
            familyRank = rank - orderCountTotal + 1
            orderCountTotal -= 1
            billboardIndex += 1
            
            family = familyManager.FindFamily(familyID)
            if not family:
                continue
            
            familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False)
            if not familyActionData:
                GameWorld.ErrLog("¸ÃÏÉÃËûÓÐÌύƾ֤ActionData! familyID=%s" % familyID)
                continue
            awardState = GetFamilyAwardState(familyActionData)
            awardIndex = 0 # ±¾·þ½±Àø״̬Ë÷Òý
            if awardState&pow(2, awardIndex):
                GameWorld.ErrLog("¸ÃÏÉÃ˱¾·þ°ñ½±ÀøÒÑ·¢·Å! familyID=%s" % familyID)
                continue
            updAwardState = awardState|pow(2, awardIndex)
            SetFamilyAwardState(familyActionData, updAwardState)
            
            memSubCountDict = GetFamilyMemSubCountDict(familyActionData)
            
            leaderID = family.GetLeaderID()
            awardMemIDList = []
            for index in xrange(family.GetCount()):
                member = family.GetAt(index)
                memPlayerID = member.GetPlayerID()
                if memPlayerID == leaderID:
                    continue
                awardMemIDList.append(memPlayerID)
                
            paramList = [familyRank]
            if not leaderAwardItemList:
                awardMemIDList.append(leaderID)
            else:
                PlayerCompensation.SendMailByKey("BossTrialFamilyLeader", [leaderID], leaderAwardItemList, paramList)
                
            PlayerCompensation.SendMailByKey("BossTrialFamilyMember", awardMemIDList, memAwardItemList, paramList)
            GameWorld.Log("·¢·ÅbossÀúÁ·»î¶¯ÏÉÃË°ñµ¥½±Àø±¾·þ: index=%s,rank=%s,familyID=%s,Ãû´Î=%s,×ÜÌá½»¸öÊý=%s,updAwardState=%s,awardMemIDList=%s,memSubCountDict=%s" 
                          % (index, rank, familyID, familyRank, cmpValue, updAwardState, awardMemIDList, memSubCountDict))
            
    return
 
def MapServer_BossTrial(curPlayer, msgList):
    mapID = curPlayer.GetRealMapID()
    playerID = curPlayer.GetPlayerID()
    GameWorld.DebugLog("MapServer_BossTrial mapID=%s,msgList=%s" % (mapID, msgList), playerID)
    if not msgList:
        return
    
    msgType, dataMsg = msgList
    ret = None
    
    if msgType == "BossTrialSubmit":
        ret = __OnBossTrialSubmit(curPlayer, dataMsg)
        
    if ret == None:
        return
    return msgList + (ret if isinstance(ret, list) else [ret])
 
def __OnBossTrialSubmit(curPlayer, dataMsg):
    ## µØͼÌá½»bossƾ֤
    playerID = curPlayer.GetPlayerID()
    accID = curPlayer.GetAccID()
    playerName = curPlayer.GetName()
    job = curPlayer.GetJob()
    face = curPlayer.GetFace()
    facePic = curPlayer.GetFacePic()
    realmLV = curPlayer.GetOfficialRank()
    familyID = curPlayer.GetFamilyID()
    submitCount, updSubmitCount = dataMsg
    
    curFamily, familySubmitTotal = __DoBossTrialSubmitFamilyAction(curPlayer, submitCount)
    familyBillInfo = {}
    
    #¸üб¾·þÏÉÃËÌá½»°ñµ¥
    if familyID and curFamily and familySubmitTotal:
        familyBillInfo = PlayerFamily.GetFamilyBillboardInfo(curFamily)
        familyBillInfo["familySubmitTotal"] = familySubmitTotal
        PlayerBillboard.UpdateFamilyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamily, familyBillInfo, familySubmitTotal)
        
    #ͬ²½¿ç·þ
    playerInfo = {"playerID":playerID, "playerName":playerName, "accID":accID, "job":job, "realmLV":realmLV,
                  "playerSubmitTotal":updSubmitCount, "face":face, "facePic":facePic}
    SyncBossTrialSubmitToCrossServer(curPlayer, playerInfo, familyBillInfo)
    return
 
def __DoBossTrialSubmitFamilyAction(curPlayer, submitCount):
    ## Ö´ÐÐÌύƾ֤µ½ÏÉÃËActionÊý¾Ý
    
    curFamily = None
    familySubmitTotal = 0
    playerID = curPlayer.GetPlayerID()
    familyID = curPlayer.GetFamilyID()
    if not familyID:
        return curFamily, familySubmitTotal
    
    familyManager = GameWorld.GetFamilyManager()
    curFamily = familyManager.FindFamily(familyID)
    if not curFamily:
        return curFamily, familySubmitTotal
    
    familyActionData = GetFamilyBossTrialSubmitActionData(familyID, True)
    
    familySubmitTotal = GetFamilySubmitTotal(familyActionData) + submitCount
    SetFamilySubmitTotal(familyActionData, familySubmitTotal)
    
    memSubCountDict = GetFamilyMemSubCountDict(familyActionData)
    memSubCountDict[playerID] = memSubCountDict.get(playerID, 0) + submitCount
    SetFamilyMemSubCountDict(familyActionData, memSubCountDict)
    
    return curFamily, familySubmitTotal
 
def GetFamilyBossTrialSubmitActionData(familyID, isAdd=False):
    ## »ñÈ¡ÏÉÃËbossƾ֤Ìá½»
    familyActionObj = None
    actionType = ShareDefine.Def_ActionType_BossTrialSubmit
    familyAction = GameWorld.GetFamilyActionManager().GetFamilyAction(familyID, actionType)
    if not familyAction.Count():
        if isAdd:
            familyActionObj = familyAction.AddAction()
            familyActionObj.SetFamilyId(familyID)
            familyActionObj.SetActionType(actionType)
    else:
        familyActionObj = familyAction.At(0)
        
    return familyActionObj
 
def GetFamilySubmitTotalByID(familyID):
    ## »ñÈ¡ÏÉÃËÌá½»µÄƾ֤×ÜÊý
    familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False)
    if not familyActionData:
        return 0
    return GetFamilySubmitTotal(familyActionData)
 
def GetFamilySubmitTotal(familyActionData): return familyActionData.GetValue1()
def SetFamilySubmitTotal(familyActionData, submitTotal): familyActionData.SetValue1(submitTotal)
def GetFamilyAwardState(familyActionData): return familyActionData.GetValue2()
def SetFamilyAwardState(familyActionData, state): return familyActionData.SetValue2(state)
 
def GetFamilyMemSubCountDict(familyActionData):
    memSubCountDict = {}
    useData = familyActionData.GetUseData()
    if useData:
        try:
            memSubCountDict = eval(useData)
        except:
            memSubCountDict = {}
    return memSubCountDict
def SetFamilyMemSubCountDict(familyActionData, memSubCountDict):
    useData = str(memSubCountDict).replace(" ", "")
    familyActionData.SetUseData(useData, len(useData))
    return
 
def SyncBossTrialSubmitToCrossServer(curPlayer, playerInfo, familyInfo):
    ## Í¬²½bossƾ֤Ìá½»×ÜÊýµ½¿ç·þ·þÎñÆ÷
    actInfo = CrossActionControl.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_BossTrial)
    if not actInfo.get(ShareDefine.ActKey_State):
        return
    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
    ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})
    if not ipyDataDict:
        return
    zoneID = ipyDataDict.get("ZoneID")
    if not cfgID or not zoneID:
        return
    
    dataMsg = {"cfgID":cfgID, "zoneID":zoneID, "playerInfo":playerInfo, "familyInfo":familyInfo}
    CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_BossTrialSubmit, dataMsg)
    return
 
def CrossServerMsg_CrossBossTrialFamilyAward(msgData):
    ## ÊÕµ½¿ç·þ֪ͨ  - ½áËã¿ç·þÏÉÃË°ñ½±Àø
    cfgID = msgData["cfgID"]
    zoneID = msgData["zoneID"]
    templateID = msgData["templateID"]
    awardFamilyList = msgData["awardFamilyList"]
    
    GameWorld.Log("ÊÕµ½¿ç·þͬ²½µÄ½áËãbossÀúÁ·»î¶¯¿ç·þÏÉÃË°ñ½±Àø: cfgID=%s,zoneID=%s,templateID=%s" % (cfgID, zoneID, templateID))
    
    familyManager = GameWorld.GetFamilyManager()
    
    for familyInfo in awardFamilyList:
        familyID, familyRank, familySubmitTotal, leaderAwardItemList, memAwardItemList = familyInfo
        family = familyManager.FindFamily(familyID)
        if not family:
            GameWorld.DebugLog("·Ç±¾·þÏÉÃË»òÒѽâÉ¢! familyID=%s" % familyID)
            continue
        
        familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False)
        if not familyActionData:
            GameWorld.ErrLog("¸ÃÏÉÃËûÓÐÌύƾ֤ActionData! familyID=%s" % familyID)
            continue
        awardState = GetFamilyAwardState(familyActionData)
        awardIndex = 1 #¿ç·þ½±Àø״̬Ë÷Òý
        if awardState&pow(2, awardIndex):
            GameWorld.ErrLog("¸ÃÏÉÃË¿ç·þ°ñ½±ÀøÒÑ·¢·Å! familyID=%s" % familyID)
            continue
        updAwardState = awardState|pow(2, awardIndex)
        SetFamilyAwardState(familyActionData, updAwardState)
        
        memSubCountDict = GetFamilyMemSubCountDict(familyActionData)
        
        leaderID = family.GetLeaderID()
        awardMemIDList = []
        for index in xrange(family.GetCount()):
            member = family.GetAt(index)
            memPlayerID = member.GetPlayerID()
            if memPlayerID == leaderID:
                continue
            awardMemIDList.append(memPlayerID)
            
        paramList = [familyRank]
        if not leaderAwardItemList:
            awardMemIDList.append(leaderID)
        else:
            PlayerCompensation.SendMailByKey("BossTrialCrossFamilyLeader", [leaderID], leaderAwardItemList, paramList)
            
        PlayerCompensation.SendMailByKey("BossTrialCrossFamilyMember", awardMemIDList, memAwardItemList, paramList)
        GameWorld.Log("·¢·ÅbossÀúÁ·»î¶¯ÏÉÃË°ñµ¥½±Àø¿ç·þ: familyID=%s,Ãû´Î=%s,×ÜÌá½»¸öÊý=%s,updAwardState=%s,awardMemIDList=%s,memSubCountDict=%s" 
                      % (familyID, familyRank, familySubmitTotal, updAwardState, awardMemIDList, memSubCountDict))
        
    return
 
##------------------------------------------ ¿ç·þbossÀúÁ·»î¶¯ ---------------------------------------
 
def ClientServerMsg_BossTrialSubmit(serverGroupID, msgData):
    ## ÊÕµ½×Ó·þ - Ìá½»bossƾ֤
    
    cfgID = msgData["cfgID"]
    zoneID = msgData["zoneID"]
    playerInfo = msgData["playerInfo"]
    familyInfo = msgData["familyInfo"]
    
    actInfo = CrossActionControl.GetCrossActInfoByCfgID(ShareDefine.CrossActName_BossTrial, cfgID, zoneID)
    if not actInfo or not actInfo[ShareDefine.ActKey_State]:
        GameWorld.ErrLog("¿ç·þbossÀúÁ··Ç»î¶¯ÖУ¬ÎÞ·¨Ìá½»! cfgID=%s, zoneID=%s" % (cfgID, zoneID))
        return
    if actInfo[ShareDefine.ActKey_StateJoin] != ShareDefine.ActStateJoin_Start:
        GameWorld.ErrLog("¿ç·þbossÀúÁ··Ç¿É²ÎÓë״̬£¬ÎÞ·¨Ìá½»! cfgID=%s, zoneID=%s" % (cfgID, zoneID))
        return
    ipyData = IpyGameDataPY.GetIpyGameData("CrossActBossTrial", cfgID)
    if not ipyData:
        return
    personlLimit, familyLimit = 0, 0
        
    PersonalTemplateID = ipyData.GetPersonalTemplateID()
    pRankIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", PersonalTemplateID) if PersonalTemplateID else None
    if pRankIpyDataList:
        lastRankIpyData = pRankIpyDataList[-1] # È¡×îºóÒ»¸öΪ×îµÍÉÏ°ñ»ý·ÖÏÞÖÆ
        personlLimit = lastRankIpyData.GetNeedScore()
        
    FamilyTemplateID = ipyData.GetFamilyTemplateID()
    fRankIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", FamilyTemplateID) if FamilyTemplateID else None
    if fRankIpyDataList:
        lastRankIpyData = fRankIpyDataList[-1] # È¡×îºóÒ»¸öΪ×îµÍÉÏ°ñ»ý·ÖÏÞÖÆ
        familyLimit = lastRankIpyData.GetNeedScore()
        
    playerID = playerInfo["playerID"]
    playerName = playerInfo["playerName"]
    job = playerInfo["job"]
    accID = playerInfo["accID"]
    realmLV = playerInfo["realmLV"]
    playerSubmitTotal = playerInfo["playerSubmitTotal"]
    face = playerInfo.get("face", 0)
    facePic = playerInfo.get("facePic", 0)
    
    groupValue1 = zoneID
    
    if playerSubmitTotal >= personlLimit:
        name2, type2, value1, value2 = accID, job, realmLV, 0
        CrossBillboard.UpdCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1, playerID, playerName, 
                                         name2, type2, value1, value2, playerSubmitTotal, value3=face, value4=facePic)
        
    if familyInfo and familyInfo.get("familySubmitTotal", 0) >= familyLimit:
        familySubmitTotal = familyInfo["familySubmitTotal"]
        CrossBillboard.UpdCrossBillboardFamily(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1, familyInfo, familySubmitTotal)
        
    return
 
def OnCrossActIDChange(cfgID, zoneID, ipyData, state):
    ## ¿ç·þ»î¶¯ID±ä¸ü
    if state:
        OnCrossActStart(cfgID, zoneID, ipyData)
    else:
        OnCrossActEnd(cfgID, zoneID, ipyData)
    return
 
def OnCrossActStart(cfgID, zoneID, ipyData):
    ## ¿ç·þ»î¶¯¿ªÆô
    
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID, 0)
    
    groupValue1 = zoneID
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1)
    billboardObj.ClearData() # Ð»ÖØÖðñµ¥Êý¾Ý
    
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1)
    billboardObj.ClearData() # Ð»ÖØÖðñµ¥Êý¾Ý    
    return
 
def OnCrossActEnd(cfgID, zoneID, ipyData):
    ## ¿ç·þ»î¶¯½áÊø
    
    groupValue1 = zoneID
    GameWorld.Log("=== ¿ç·þbossÀúÁ·»î¶¯½áÊø£¡ === cfgID=%s,zoneID=%s" % (cfgID, zoneID))
    __OnCrossEndAward(cfgID, zoneID, ipyData)
    
    # ±¸·Ý¡¢Çå³ý°ñµ¥Êý¾Ý
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1)
    CrossBillboard.CopyBillboardEx(ShareDefine.Def_CBT_BossTrialSubmit, ShareDefine.Def_CBT_BossTrialSubmitBak, groupValue1)
    billboardObj.ClearData()
    
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1)
    CrossBillboard.CopyBillboardEx(ShareDefine.Def_CBT_BossTrialSubmitFamily, ShareDefine.Def_CBT_BossTrialSubmitFamilyBak, groupValue1)
    billboardObj.ClearData()
    GameWorld.Log("=================================================================================")
    return
 
def OnCrossActInStateRefresh(cfgID, zoneID, ipyData):
    ## »î¶¯ÖÐˢУ¬Ã¿´Î¶¼ÐèҪˢеÄÂß¼­£¬°üº¬ÖضÁÅäÖõÈ
    if not ipyData:
        return
    PersonalTemplateID = ipyData.GetPersonalTemplateID()
    FamilyTemplateID = ipyData.GetFamilyTemplateID()
    orderRuleList = GetOrderRuleList(PersonalTemplateID)
    orderRuleListFamily = GetOrderRuleList(FamilyTemplateID)
    
    groupValue1 = zoneID
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1)
    billboardObj.SetOrderRuleList(orderRuleList)
    
    billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1)
    billboardObj.SetOrderRuleList(orderRuleListFamily)
    return
 
def GetOrderRuleList(templateID):
    orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID)
    if not orderIpyDataList:
        return
    orderRuleList = []
    for ipyData in orderIpyDataList:
        orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()])
    return orderRuleList
 
def OnCrossActJoinEnd(cfgID, zoneID, ipyData):
    ## ¿ç·þ»î¶¯²ÎÓë½áÊø
    __OnCrossEndAward(cfgID, zoneID, ipyData)
    return
 
def __OnCrossEndAward(cfgID, zoneID, ipyData):
    ## ½áËã¿ç·þ½±Àø
    awardState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID)
    if awardState:
        #ÒѾ­½áËã¹ý¸Ã»î¶¯
        GameWorld.Log("¿ç·þbossÀúÁ·»î¶¯ÒѾ­½áËã¹ý½±ÀøÁË! cfgID=%s,zoneID=%s" % (cfgID, zoneID))
        return
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID, 1)
    
    GameWorld.Log("=== ¿ç·þbossÀúÁ·»î¶¯·¢·Å°ñµ¥½±Àø£¡ === cfgID=%s,zoneID=%s" % (cfgID, zoneID))
    
    PersonalTemplateID = ipyData.GetPersonalTemplateID()
    FamilyTemplateID = ipyData.GetFamilyTemplateID()
    serverIDRangeList = ipyData.GetServerIDRangeList()
    
    __GiveCrossOrderAwardPersonal(cfgID, zoneID, PersonalTemplateID, ShareDefine.Def_CBT_BossTrialSubmit, serverIDRangeList)
    __GiveCrossOrderAwardFamily(cfgID, zoneID, FamilyTemplateID, ShareDefine.Def_CBT_BossTrialSubmitFamily)
    GameWorld.Log("=================================================================================")
    return
    
def __GiveCrossOrderAwardPersonal(cfgID, zoneID, templateID, billboardType, serverIDRangeList):
    
    groupValue1 = zoneID
    #billboardType = ShareDefine.Def_CBT_BossTrialSubmit #°ñµ¥ÀàÐ͸ÄΪ²ÎÊý´«È룬Òì³£Çé¿öÏ¿ÉÌØÊâ´¦ÀíÓñ¸·Ý°ñµ¥·¢½±Àø
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1)
    billboardDataCount = billboardObj.GetCount()
    if not billboardDataCount:
        GameWorld.Log("¿ç·þBossƾ֤¸öÈËÅÅÐÐÊý¾ÝΪ¿Õ! billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s" % (billboardType, zoneID, cfgID, templateID))
        return
    
    # ½áËãʱÅÅÐò²¢±£´æ°ñµ¥Êý¾ÝÁ÷Ïò
    billboardObj.SortData()
    billboardObj.SaveDRData("BossTrial", {"cfgID":cfgID, "zoneID":zoneID})
    
    GameWorld.Log("½áËã¿ç·þBossƾ֤¸öÈËÅÅÐн±Àø: billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s,billboardDataCount=%s" 
                  % (billboardType, zoneID, cfgID, templateID, billboardDataCount))
    
    orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID)
    if not orderIpyDataList:
        return
    
    worshipType = ShareDefine.Def_WorshipType_CrossBossTrial
    syncNewWorshipList = []
    syncNewXiangongDict = {}
    rankPre = 0
    billboardIndex = 0
    for ipyData in orderIpyDataList:
        rank = ipyData.GetRank()
        needScore = ipyData.GetNeedScore()
        scoreAwardEx = ipyData.GetScoreAwardEx()
        scoreAwardExList = scoreAwardEx.keys()
        scoreAwardExList.sort()
        awardItemList = ipyData.GetAwardItemList()
        xiangongID = ipyData.GetXiangongID()
        orderCountTotal = rank - rankPre # ½±ÀøÃû´ÎÊýÁ¿
        rankPre = rank
        
        for index in xrange(billboardIndex, billboardDataCount):
            if orderCountTotal <= 0:
                break
            
            billboardData = billboardObj.At(index)
            playerID = billboardData.ID
            name2 = billboardData.Name2
            cmpValue = billboardData.CmpValue
            if cmpValue < needScore:
                GameWorld.Log("    »ý·Ö²»×ã¸Ã°ñµ¥ËùÐè»ý·Ö£¬Ìø¹ý¸ÃÃû´Î: index=%s,rank=%s,playerID=%s,cmpValue=%s < %s" % (index, rank, playerID, cmpValue, needScore))
                break
            
            awardItemExList = []
            for scoreEx in scoreAwardExList:
                if cmpValue < scoreEx:
                    break
                awardItemExList = scoreAwardEx[scoreEx] # È¡×î´óÂú×ãÌõ¼þµÄÒ»µµ
            finalAwardItemList = awardItemList + awardItemExList
            
            playerRank = rank - orderCountTotal + 1
            GameWorld.Log("    ·¢·ÅbossÀúÁ·¸öÈË°ñµ¥½±Àø: index=%s,rank=%s,playerRank=%s,playerID=%s,cmpValue=%s,awardItemList=%s,scoreAwardEx=%s,finalAwardItemList=%s, %s" 
                          % (index, rank, playerRank, playerID, cmpValue, awardItemList, scoreAwardEx, finalAwardItemList, name2))
            PlayerCompensation.SendMailByKey("BossTrialCrossPlayer", [playerID], finalAwardItemList, [playerRank], crossMail=True)
            
            orderCountTotal -= 1
            billboardIndex += 1
            
            GameXiangong.AddXiangongPlayer(xiangongID, playerID, serverIDRangeList, playerRank, syncNewXiangongDict)
            GameWorship.AddWorshipPlayer(worshipType, playerRank, playerID, serverIDRangeList, syncList=syncNewWorshipList)
    GameWorship.SendNewWorshipPlayer(syncNewWorshipList)
    GameXiangong.SendNewXiangongPlayerToClientServer(syncNewXiangongDict)
    return
 
def __GiveCrossOrderAwardFamily(cfgID, zoneID, templateID, billboardType):
    
    groupValue1 = zoneID
    #billboardType = ShareDefine.Def_CBT_BossTrialSubmitFamily
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1)
    billboardDataCount = billboardObj.GetCount()
    if not billboardDataCount:
        GameWorld.Log("¿ç·þBossƾ֤ÏÉÃËÅÅÐÐÊý¾ÝΪ¿Õ! billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s" % (billboardType, zoneID, cfgID, templateID))
        return
    
    # ½áËãʱÅÅÐò²¢±£´æ°ñµ¥Êý¾ÝÁ÷Ïò
    billboardObj.SortData()
    billboardObj.SaveDRData("BossTrial", {"cfgID":cfgID, "zoneID":zoneID})
    
    GameWorld.Log("½áËã¿ç·þBossƾ֤ÏÉÃËÅÅÐн±Àø: billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s,billboardDataCount=%s" 
                  % (billboardType, zoneID, cfgID, templateID, billboardDataCount))
    
    orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID)
    if not orderIpyDataList:
        return
    
    awardFamilyList = []
    rankPre = 0
    billboardIndex = 0
    for ipyData in orderIpyDataList:
        rank = ipyData.GetRank()
        needScore = ipyData.GetNeedScore()
        leaderAwardItemList = ipyData.GetAwardItemList()
        memAwardItemList = ipyData.GetMemAwardItemList()
        orderCountTotal = rank - rankPre # ½±ÀøÃû´ÎÊýÁ¿
        rankPre = rank
        
        for index in xrange(billboardIndex, billboardDataCount):
            if orderCountTotal <= 0:
                break
            
            billboardData = billboardObj.At(index)
            familyID = billboardData.ID
            familySubmitTotal = billboardData.CmpValue
            
            if familySubmitTotal < needScore:
                GameWorld.Log("    ²»×ã¸Ã°ñµ¥ËùÐèÌá½»Êý£¬Ìø¹ý¸ÃÃû´Î: index=%s,rank=%s,familyID=%s,familySubmitTotal=%s < %s" % (index, rank, familyID, familySubmitTotal, needScore))
                break
            
            familyRank = rank - orderCountTotal + 1
            GameWorld.Log("    index=%s,rank=%s,familyID=%s,Ãû´Î=%s,×ÜÌá½»¸öÊý=%s" % (index, rank, familyID, familyRank, familySubmitTotal))
            awardFamilyList.append([familyID, familyRank, familySubmitTotal, leaderAwardItemList, memAwardItemList])
            
            orderCountTotal -= 1
            billboardIndex += 1
            
    # ¹ã²¥×Ó·þ·¢·Å½±Àø
    sendMsg = {"cfgID":cfgID, "zoneID":zoneID, "templateID":templateID, "awardFamilyList":awardFamilyList}
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_CrossBossTrialFamilyAward, sendMsg)
    return