xdh
2019-05-24 5a027b7b71bc1b3044942f7d2b98ccbdd7d776bc
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package PlayerFBHelpBattle
#
# @todo:¸±±¾Öúսϵͳ
# @author hxp
# @date 2018-11-24
# @version 1.0
#
# ÏêϸÃèÊö: ¸±±¾Öúսϵͳ
#
#-------------------------------------------------------------------------------
#"""Version = 2018-11-24 22:30"""
#-------------------------------------------------------------------------------
 
import PlayerFriend
import IpyGameDataPY
import PlayerViewCache
import IPY_GameServer
import PlayerControl
import ShareDefine
import PyGameData
import GameWorld
import ChConfig
 
import random
import time
 
MaxRobotID = 100 # ×î´ó»úÆ÷ÈËNPC¶¨ÒåID
 
Def_RecType_CheckInPlayer = ShareDefine.Def_UniversalGameRecType_FBHelpBattleCheckInPlayer
Def_RecType_HelpRecord = ShareDefine.Def_UniversalGameRecType_FBHelpBattleRecord
 
## ÖúÕ½Íæ¼Ò¼òÒªÐÅÏ¢
class HelpBattlePlayer():
    
    def __init__(self, playerID):
        self.playerID = playerID
        self.job = 0
        self.playerName = ""
        self.playerLV = 0
        self.realmLV = 0
        self.fightPower = 0
        self.familyID = 0
        self.vipLV = 0
        self.checkInCount = 0 # ÀۼƵǼǴÎÊý
        self.checkInTime = 0
        self.todayHelpCountDict = {} # ½ñÌìÒÑÖúÕ½´ÎÊý {(mapID, lineID):count, ...}, Í¨ÓôÎÊýʱlineIDĬÈÏΪ0
        self.todayXianyuanCoin = 0 # ½ñÈÕÒÑ»ñµÃÏÉÔµ±Ò
        return
 
## ÖúÕ½¼Ç¼ - Ä¿Ç°Ö»¼ÇÂ¼Î´Í¨ÖªÍæ¼ÒµÄÖúÕ½ÐÅÏ¢
class FBHelpBattleRecord():
    
    def __init__(self):
        self.callPlayerID = 0 # ÕÙ»½ËûµÄÍæ¼ÒID
        self.callPlayerName = ""
        self.mapID = 0
        self.funcLineID = 0
        self.xianyuanCoinAdd = 0 # 0´ú±íµ½´ïÉÏÏÞ
        self.relation = 0 # µ±Ê±µÄ¹ØÏµ
        self.vipLV = 0 # µ±Ê±µÄVIPµÈ¼¶
        self.recordTime = 0 # ¼Ç¼µÄʱ¼ä
        return
 
def OnServerStart():
    GameWorld.Log("¿ª·þ¼ÓÔØÖúÕ½Ïà¹ØÐÅÏ¢...")
    universalRecMgr = GameWorld.GetUniversalRecMgr()
    checkInPlayerRecList = universalRecMgr.GetTypeList(Def_RecType_CheckInPlayer)
    for index in xrange(checkInPlayerRecList.Count()):
        recData = checkInPlayerRecList.At(index)
        playerID = recData.GetValue1()
        helpBattlePlayer = HelpBattlePlayer(playerID)
        helpBattlePlayer.checkInTime = recData.GetTime()
        helpBattlePlayer.fightPower = recData.GetValue2()
        helpBattlePlayer.familyID = recData.GetValue3()
        helpBattlePlayer.checkInCount = recData.GetValue4()
        value5 = recData.GetValue5()
        helpBattlePlayer.playerLV = value5 / 100000
        helpBattlePlayer.vipLV = int(str(value5)[-5:-3])
        helpBattlePlayer.realmLV = int(str(value5)[-3:-1])
        helpBattlePlayer.job = value5 % 10
        helpBattlePlayer.playerName = recData.GetStrValue1()
        helpBattlePlayer.todayXianyuanCoin = int(recData.GetStrValue2())
        helpCountDictStr = recData.GetStrValue3()
        if helpCountDictStr.startswith("{") and helpCountDictStr.endswith("}"):
            helpBattlePlayer.todayHelpCountDict = eval(helpCountDictStr)
        else:
            GameWorld.ErrLog("LoadCheckInPlayerError: helpCountDictStr=%s" % helpCountDictStr, playerID)
        PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID] = helpBattlePlayer
    GameWorld.Log("¼ÓÔØÖúÕ½µÇ¼ÇÍæ¼Ò¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))
    
    helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)
    for index in xrange(helpRecordRecList.Count()):
        recData = helpRecordRecList.At(index)
        playerID = recData.GetValue1()
        
        helpRecord = FBHelpBattleRecord()
        helpRecord.callPlayerID = int(recData.GetStrValue2())
        helpRecord.callPlayerName = recData.GetStrValue1()
        helpRecord.mapID = recData.GetValue2()
        helpRecord.funcLineID = recData.GetValue3()
        helpRecord.xianyuanCoinAdd = recData.GetValue4()
        helpRecord.relation = recData.GetValue5() % 10
        helpRecord.vipLV = recData.GetValue5() / 10
        helpRecord.recordTime = recData.GetTime()
        
        unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(playerID, [])
        unNotifyRecordList.append(helpRecord)
        PyGameData.g_fbHelpBattleRecord[playerID] = unNotifyRecordList
        
    GameWorld.Log("¼ÓÔØÍæ¼Òδͬ²½ÖúÕ½: %s" % len(PyGameData.g_fbHelpBattleRecord))
    for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():
        GameWorld.Log("¼ÓÔØÍæ¼Òδͬ²½ÖúÕ½¼Ç¼: %s" % (len(helpList)), playerID)
    return
 
def OnServerClose():
    GameWorld.Log("¹Ø·þ±£´æÖúÕ½Ïà¹ØÐÅÏ¢...")
    universalRecMgr = GameWorld.GetUniversalRecMgr()
    universalRecMgr.Delete(Def_RecType_CheckInPlayer)
    universalRecMgr.Delete(Def_RecType_HelpRecord)
    
    GameWorld.Log("±£´æÖúÕ½µÇ¼ÇÍæ¼Ò¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))
    checkInPlayerRecList = universalRecMgr.GetTypeList(Def_RecType_CheckInPlayer)
    for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():
        recData = checkInPlayerRecList.AddRec()
        recData.SetTime(checkInPlayer.checkInTime)
        recData.SetValue1(playerID)
        recData.SetValue2(checkInPlayer.fightPower)
        recData.SetValue3(checkInPlayer.familyID)
        recData.SetValue4(checkInPlayer.checkInCount)
        recData.SetValue5(int("%d%02d%02d%d" % (checkInPlayer.playerLV, checkInPlayer.vipLV, checkInPlayer.realmLV, checkInPlayer.job)))
        recData.SetStrValue1(checkInPlayer.playerName)
        recData.SetStrValue2(str(checkInPlayer.todayXianyuanCoin))
        recData.SetStrValue3(str(checkInPlayer.todayHelpCountDict).replace(" ", ""))
        
    GameWorld.Log("±£´æÖúսδͬ²½¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleRecord))
    helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)
    for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():
        GameWorld.Log("Íæ¼Òδͬ²½ÖúÕ½¼Ç¼: %s" % (len(helpList)), playerID)
        for helpRecord in helpList:
            recData = helpRecordRecList.AddRec()
            recData.SetTime(helpRecord.recordTime)
            recData.SetValue1(playerID)
            recData.SetValue2(helpRecord.mapID)
            recData.SetValue3(helpRecord.funcLineID)
            recData.SetValue4(helpRecord.xianyuanCoinAdd)
            recData.SetValue5(helpRecord.vipLV*10+helpRecord.relation)
            recData.SetStrValue1(helpRecord.callPlayerName)
            recData.SetStrValue2(str(helpRecord.callPlayerID))
    return
 
def HelpBattleOnDay():
    curTime = int(time.time())
    checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±
    # ÕâÀïÑÓ³¤30·ÖÖÓÇå³ý£¬·ÀÖ¹ÒѾ­±»ÕÙ»½»¹Ã»½áËãµÄµ¼ÖÂÕÒ²»µ½µÇ¼ÇÐÅÏ¢
    checkInValidSeconds = checkInValidHours * 3600 + 30 * 60
    
    # Ç峬ʱµÇ¼Ç£¬ÖØÖÃÐÅÏ¢
    for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():
        checkInTime = checkInPlayer.checkInTime
        if curTime - checkInTime > checkInValidSeconds:
            PyGameData.g_fbHelpBattleCheckInPlayerDict.pop(playerID)
            GameWorld.Log("Çå³ý³¬Ê±ÖúÕ½µÇ¼ÇÍæ¼Ò: curTime=%s,checkInTime=%s" % (curTime, checkInTime), playerID)
            continue
        checkInPlayer.todayHelpCountDict = {}
        checkInPlayer.todayXianyuanCoin = 0
    return
 
def OnHelpPlayerLogin(curPlayer):
    playerID = curPlayer.GetPlayerID()
    if playerID not in PyGameData.g_fbHelpBattleRecord:
        return
    unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.pop(playerID)
    SendMapServer_FBHelpBattleRecord(curPlayer, unNotifyRecordList, True)
    return
 
def OnMinuteProcess():
    ''' Ã¿·ÖÖÓ´¦Àí
            Ç°X´ÎµÇ¼Çºó£¬·Ö±ðÔڵǼǺóµÄµÚX·ÖÖÓÔùËÍÍæ¼Ò×ÚÃÅÊÔÁ¶Ò»²ãµÄÖúÕ½ÏÉÔµ±Ò£¬²¢Î±ÔìÒ»·ÝÖúÕ½¼Ç¼¡£
            ÖúÕ½¼ÇÂ¼Ëæ»ú´ÓÖúÕ½µÇ¼Ç¿âÀïËæ»úÌôÑ¡1Ãû³ý×Ô¼ºÍâµÄÍæ¼Ò£¬Èç¹ûûÓÐÍæ¼Ò£¬¸ÃÌØÊâÂß¼­²»ÉúЧ
    '''
    
    if not PyGameData.g_fbHelpBattleCheckInPlayerDict:
        return
    helpPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
    
    curTime = int(time.time())
    
    playerManager = GameWorld.GetPlayerManager()
    newbieCheckInCount = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 2) # ÐÂÊÖǰX´ÎµÇ¼ÇÌØÊâÂß¼­
    sysAutoCallHelpDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattleCheckIn", 3) # ÏµÍ³×Ô¶¯ÕÙ»½ÖúÕ½£¬Ä¬ÈϹ¦ÄÜÏß·0£¬ {µÇ¼Ç¶àÉÙ·ÖÖÓºó:[Ëæ»úµØÍ¼ID, ...], ...}
    for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():
        
        curPlayer = playerManager.FindPlayerByID(playerID)
        
        if not curPlayer or PlayerControl.GetIsTJG(curPlayer):
            #GameWorld.DebugLog("    ÀëÏß»òÍÑ»ú²»´¦Àí, playerID=%s" % playerID)
            continue
        
        checkInCount = checkInPlayer.checkInCount
        if checkInCount > newbieCheckInCount:
            #GameWorld.DebugLog("    ³¬¹ý¹æ¶¨µÄµÇ¼Ç´ÎÊý£¬²»´¦Àí, playerID=%s,checkInCount=%s > newbieCheckInCount=%s" 
            #                   % (playerID, checkInCount, newbieCheckInCount))
            continue
        
        checkInTime = checkInPlayer.checkInTime
        checkInMinutes = (curTime - checkInTime) / 60 
        if checkInMinutes not in sysAutoCallHelpDict:
            #GameWorld.DebugLog("    Ç©µ½Ê±¼ä²»Âú×㣬²»´¦Àí, playerID=%s,checkInMinutes=%s not in %s" 
            #                   % (playerID, checkInMinutes, sysAutoCallHelpDict))
            continue
        
        randHelpMapList = sysAutoCallHelpDict[checkInMinutes]
        # Ëæ»úÒ»¸ö²»ÊÇ×Ô¼ºµÄµÇ¼ÇÍæ¼Ò
        for _ in xrange(20):
            randPlayerID = random.choice(helpPlayerIDList)
            if randPlayerID != playerID:
                break
            
        # Ö»ÓÐ×Ô¼º²»´¦Àí
        if randPlayerID == playerID:
            #GameWorld.DebugLog("    µÇ¼ÇÍæ¼ÒÖ»ÓÐ×Ô¼º£¬²»´¦Àí, playerID=%s" % (playerID))
            continue
        
        randHelpMapID = random.choice(randHelpMapList)
        lineID = 0 # Ä¬ÈÏ0
        
        helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[randPlayerID]
        relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
        calledPlayerID = playerID # ÒòΪÕâÀïÊÇϵͳģÄâÍæ¼Ò±»ÕÙ»½ÖúÕ½£¬ËùÒÔ±»ÕÙ»½Íæ¼Ò¾ÍÊǵ±Ç°±»´¦ÀíµÄÍæ¼ÒID
        GameWorld.DebugLog("    ÏµÍ³Ä£ÄâÕÙ»½ÐÂÊֵǼÇÍæ¼Ò: checkInMinutes=%s,playerID=%s,callPlayerID=%s" % (checkInMinutes, playerID, randPlayerID))
        
        calledPlayerDict = {calledPlayerID:relation}
        msgList = ["Call", randHelpMapID, lineID, calledPlayerDict]
        __DoFBHelpBattleCall(randPlayerID, helpBattlePlayer.playerName, msgList)
        
    return
 
## ÊÇ·ñÔÚÖúÕ½µÇ¼ÇÁбíÀï
def IsInHelpBattleCheckInList(playerID): return playerID in PyGameData.g_fbHelpBattleCheckInPlayerDict
 
def MapServer_FBHelpBattle(curPlayer, msgList):
    ## µØÍ¼Íæ¼ÒÇëÇóÖúÕ½Ïà¹Ø²Ù×÷
    GameWorld.DebugLog("MapServer_FBHelpBattle %s" % str(msgList), curPlayer.GetPlayerID())
    if not msgList:
        return ""
    
    cmd = msgList[0]
    result = []
    
    # µÇ¼Ç
    if cmd == "CheckIn":
        result = __DoPlayerFBHelpBattleCheckIn(curPlayer, msgList)
        
    # Ë¢ÐÂÖúÕ½ÁÐ±í    
    elif cmd == "Refresh":
        result = __DoFBHelpBattleRefresh(curPlayer, msgList)
        
    # ÕÙ»½
    elif cmd == "Call":
        result = __DoFBHelpBattleCall(curPlayer.GetPlayerID(), curPlayer.GetName(), msgList)
    
    # É¨µ´ÕÙ»½
    elif cmd == "SweepCall":
        result = __DoFBHelpBattleSweepCall(curPlayer, msgList)
        
    if result == None:
        return
    
    return msgList + result
 
def __DoPlayerFBHelpBattleCheckIn(curPlayer, msgList):
    ## Íæ¼ÒµÇ¼Ç
    checkInCount, fightPower = msgList[1:]
    curTime = int(time.time())
    playerID = curPlayer.GetPlayerID()
    curCache = PlayerViewCache.FindViewCache(playerID)
    haveViewCache = 1 if curCache else 0
    todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer)
    
    helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict.get(playerID)
    if not helpBattlePlayer:
        helpBattlePlayer = HelpBattlePlayer(playerID)
        PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID] = helpBattlePlayer
    helpBattlePlayer.playerName = curPlayer.GetName()
    helpBattlePlayer.playerLV = curPlayer.GetLV()
    helpBattlePlayer.job = curPlayer.GetJob()
    helpBattlePlayer.realmLV = curPlayer.GetOfficialRank()
    helpBattlePlayer.fightPower = fightPower
    helpBattlePlayer.familyID = curPlayer.GetFamilyID()
    helpBattlePlayer.vipLV = curPlayer.GetVIPLv()
    helpBattlePlayer.checkInCount = checkInCount + 1
    helpBattlePlayer.checkInTime = curTime
    helpBattlePlayer.todayXianyuanCoin = todayXianyuanCoin
    
    isOK = 1 # Ä¬Èϳɹ¦
    GameWorld.Log("Íæ¼ÒÖúÕ½µÇ¼Ç: playerLV=%s,fightPower=%s,familyID=%s,vipLV=%s,todayXianyuanCoin=%s,checkInCount=%s,haveViewCache=%s" 
                  % (curPlayer.GetLV(), fightPower, curPlayer.GetFamilyID(), curPlayer.GetVIPLv(), todayXianyuanCoin, checkInCount + 1, haveViewCache), playerID)
    return [isOK, haveViewCache]
 
def UpdateCheckInPlayerInfo(playerID, fightPower, familyID, playerName):
    ## ¸üеǼǵÄÖúÕ½Íæ¼ÒµÈ¼¶Õ½Á¦
    if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
        return
    helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]
    helpBattlePlayer.fightPower = fightPower
    helpBattlePlayer.familyID = familyID
    helpBattlePlayer.playerName = playerName
    GameWorld.DebugLog("¸üÐÂÖúÕ½Íæ¼ÒµÈ¼¶Õ½Á¦: fightPower=%s,familyID=%s" % (fightPower, familyID), playerID)
    return
 
def UpdateCheckInPlayerInfoByRefresh(curPlayer, refreshType, value):
    ## ¸üеǼǵÄÖúÕ½Íæ¼ÒÏÉÃËID
    playerID = curPlayer.GetPlayerID()
    if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
        return
    helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]
    if refreshType == IPY_GameServer.CDBPlayerRefresh_LV:
        helpBattlePlayer.playerLV = value
    elif refreshType == IPY_GameServer.CDBPlayerRefresh_ExAttr11:
        helpBattlePlayer.todayXianyuanCoin = value        
    elif refreshType == IPY_GameServer.CDBPlayerRefresh_VIPLv:
        helpBattlePlayer.vipLV = value
    else:
        return
    GameWorld.DebugLog("¸üÐÂÖúÕ½Íæ¼ÒÐÅÏ¢: refreshType=%s,value=%s" % (refreshType, value), playerID)
    return
 
def __DoFBHelpBattleRefresh(curPlayer, msgList):
    ## ÖúÕ½ÁбíË¢ÐÂ
    mapID, funcLineID, isClientRefresh, costMoneyList, calledPlayerIDDict = msgList[1:]
    
    helpBattlePlayerDict = {} # Í¬²½¸øµØÍ¼·þÎñÆ÷µÄ´ýÑ¡ÖúÕ½Íæ¼ÒÁбíÐÅÏ¢
    
    ipyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)
    if not ipyData:
        return [helpBattlePlayerDict]
    
    fightPowerMin = ipyData.GetFightPowerMin()
    fightPowerMax = ipyData.GetFightPowerMax()
    limitLV = ipyData.GetLVLimit()
    dayFreeHelpCountInfo = ipyData.GetDayFreeHelpCount() # Ã¿ÈÕÃâ·ÑÖúÕ½´ÎÊý£¬[ÿÈÕÃâ·ÑÖúÕ½´ÎÊý, ÊÇ·ñËùÓвãͨÓÃ]
    dayFreeHelpCount = 0 # 0ΪÎÞÏÞÖÆ´ÎÊý
    helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0
    if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:
        dayFreeHelpCount, isAllLineCount = dayFreeHelpCountInfo
        if isAllLineCount:
            helpCountLineID = 0
    helpCountKey = (mapID, helpCountLineID)
    
    playerID = curPlayer.GetPlayerID()
    GameWorld.Log("Ë¢ÐÂÖúÕ½Áбí: mapID=%s,funcLineID=%s,helpCountLineID=%s,isClientRefresh=%s,costMoneyList=%s,calledPlayerIDDict=%s" 
                  % (mapID, funcLineID, helpCountLineID, isClientRefresh, costMoneyList, calledPlayerIDDict), playerID)
    
    onlyFree = False
    goldCallCount = 0
    nowFreeRelationCount, nowRelationCount = 0, 0
    atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # ÖÁÉÙÃâ·ÑÉç½»ÈËÊý£¬ÎÞÉç½»ÔòºöÂÔ
    atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # ÖÁÉÙÉç½»ÈËÊý£¬ÎÞÉç½»ÔòºöÂÔ£¨ÈËÊý°üº¬Ãâ·ÑÉç½»ÈËÊý£©
    GameWorld.DebugLog("    atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))
    
    #ÒѾ­ÕÙ»½µÄ±£Áô
    for calledPlayerID, callInfo in calledPlayerIDDict.items():
        needGoldCall, job, relation = callInfo
        # Íæ¼Ò¾µÏñ
        if calledPlayerID in PyGameData.g_fbHelpBattleCheckInPlayerDict:
            helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[calledPlayerID]
            helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, job, relation)
            if needGoldCall:
                goldCallCount += 1
            if relation:
                nowRelationCount += 1
                if not needGoldCall:
                    nowFreeRelationCount += 1
        # »úÆ÷ÈËNPC
        elif 1 <= calledPlayerID <= MaxRobotID:
            helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
        else:
            GameWorld.ErrLog("ÒÑÕÙ»½µÄÖúÕ½Íæ¼ÒÕÒ²»µ½¾µÏñ»º´æ£¡ÀíÂÛÉϲ»´æÔÚ¸ÃÇé¿ö£¬¾µÏñ»º´æÊÍ·Å»á±ÈµÇ¼ÇÓÐЧʱ³¤¶à°ëСʱ£¡")
            continue
            
    if helpBattlePlayerDict:
        GameWorld.Log("ÒÑÕÙ»½µÄÖúÕ½: %s" % str(helpBattlePlayerDict), playerID)
        
    curTime = int(time.time())
    maxHelpPlayerSelectCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # ×î´ó¿ÉÒÔÑ¡ÔñÖúÕ½µÄÍæ¼Ò¸öÊý
    maxGoldHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 3) # ×î´ó¸¶·ÑÕÙ»½ÈËÊý
    checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±
    checkInValidSeconds = checkInValidHours * 3600
    
    checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
    random.shuffle(checkInPlayerIDList)
    GameWorld.Log("    µÇ¼ÇÖúÕ½ÈËÊý=%s" % (len(checkInPlayerIDList)), playerID)
    
    # 1. ÖÁÉÙÉç½»¹ØÏµÈËÊý»¹²»×ãµÄ£¬ÏÈ´¦ÀíÖÁÉÙÉç½»¹ØÏµÈËÊý
    if nowRelationCount < atleastRelationCount:
        relationIDList = []
        friendIDList = PlayerFriend.GetFriendStruct(playerID).GetSocialIDList()
        relationIDList += friendIDList
        #GameWorld.DebugLog("    ºÃÓÑIDÁбí, friendIDList=%s" % friendIDList, playerID)
        curFamily = curPlayer.GetFamily()
        familyMemList = []
        if curFamily:
            for index in xrange(curFamily.GetCount()):
                member = curFamily.GetAt(index)
                memberID = member.GetPlayerID()
                familyMemList.append(memberID)
                if memberID != playerID and memberID not in relationIDList:
                    relationIDList.append(memberID)
        #GameWorld.DebugLog("    ÃËÓÑIDÁбí, familyMemList=%s" % familyMemList, playerID)
        
        random.shuffle(relationIDList)
        #GameWorld.DebugLog("    ÓÐÉç½»µÄIDÁбí, relationIDList=%s" % relationIDList, playerID)
        tempRelationHelpPlayerList = []
        for relationID in relationIDList:
            if nowRelationCount >= atleastRelationCount:
                break
            if relationID not in checkInPlayerIDList:
                continue
            helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[relationID]
            canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
                                                       checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
            if not canHelp:
                continue
            
            # Ãâ·ÑÉç½»ÈËÊý²»×ãÇÒÃâ·Ñ   or  Ãâ·ÑÉç½»ÈËÊý¹»ÁËÇÒ×ÜÉç½»ÈËÊý»¹²»¹»  ; ¶¼Ö±½Ó¼ÓÈëÖúÕ½Áбí
            if (nowFreeRelationCount < atleastFreeRelationCount and not needGoldCall) \
                or (nowFreeRelationCount >= atleastFreeRelationCount and nowRelationCount < atleastRelationCount):
                goldCallCount, nowRelationCount, nowFreeRelationCount = \
                    __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
            else:
                lackRelationCount = atleastRelationCount - nowRelationCount
                if len(tempRelationHelpPlayerList) < lackRelationCount:
                    tempRelationHelpPlayerList.append([helpBattlePlayer, needGoldCall])
                    
        lackRelationCount = atleastRelationCount - nowRelationCount
        if lackRelationCount > 0:
            for helpBattlePlayer, needGoldCall in tempRelationHelpPlayerList[:lackRelationCount]:
                goldCallCount, nowRelationCount, nowFreeRelationCount = \
                    __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
    
    # 2. ³£¹æÌí¼ÓÖúÕ½ÈËÊý        
    for checkInPlayerID in checkInPlayerIDList:
        if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
            GameWorld.DebugLog("    ³¬¹ý×î´ó¸öÊýÁ˲»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)
            break
        helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
        canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
                                                   checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
        if not canHelp:
            continue
        
        goldCallCount, nowRelationCount, nowFreeRelationCount = \
            __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
        
    # 3. ²»×ãµÄ»úÆ÷ÈËNPC²¹×ã
    openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # ¿ª·ÅµÄÖ°Òµ
    lackCount = maxHelpPlayerSelectCount - len(helpBattlePlayerDict)
    robotID = 0 # »úÆ÷ÈËNPC¶¨ÒåID´Ó1¿ªÊ¼
    while lackCount > 0 and robotID < MaxRobotID:
        robotID += 1
        if robotID in helpBattlePlayerDict:
            continue
        lackCount -= 1
        randJob = random.choice(openJobList)
        helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
    
    GameWorld.Log("    helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
    return [helpBattlePlayerDict]
 
def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
                       checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree=False, goldCallCount=0, maxGoldHelpPlayerCount=0):            
    ## ³£¹æ¼ì²éÊÇ·ñÂú×ãÖúÕ½Ìõ¼þ
    if checkInPlayerID == playerID:
        GameWorld.DebugLog("    ×Ô¼º²»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)
        return False, False
    if checkInPlayerID in helpBattlePlayerDict:
        GameWorld.DebugLog("    ÒѾ­ÔÚÖúÕ½ÀïµÄ²»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)
        return False, False
    checkInPlayerLV = helpBattlePlayer.playerLV
    checkInPlayerFightPower = helpBattlePlayer.fightPower
    checkInTime = helpBattlePlayer.checkInTime
    if checkInPlayerLV < limitLV:
        GameWorld.DebugLog("    µÈ¼¶²»×ã, checkInPlayerID=%s,checkInPlayerLV=%s < limitLV=%s" % (checkInPlayerID, checkInPlayerLV, limitLV))
        return False, False
    if fightPowerMin and checkInPlayerFightPower < fightPowerMin:
        GameWorld.DebugLog("    Õ½Á¦²»×ã, checkInPlayerID=%s,checkInPlayerFightPower=%s < fightPowerMin=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMin))
        return False, False
    if fightPowerMax and checkInPlayerFightPower > fightPowerMax:
        GameWorld.DebugLog("    Õ½Á¦³¬³ö, checkInPlayerID=%s,checkInPlayerFightPower=%s > fightPowerMax=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMax))
        return False, False
    passTime = curTime - checkInTime
    if passTime > checkInValidSeconds:
        GameWorld.DebugLog("    µÇ¼Ç³¬Ê±, checkInPlayerID=%s,checkInTime=%s,passTime=%s > checkInValidSeconds=%s" % (checkInPlayerID, checkInTime, passTime, checkInValidSeconds))
        return False, False
    todayHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0)
    needGoldCall = dayFreeHelpCount and todayHelpCount >= dayFreeHelpCount
    if needGoldCall:
        if onlyFree:
            GameWorld.DebugLog("    ²»ÊÇÃâ·Ñ, checkInPlayerID=%s,todayHelpCount=%s > dayFreeHelpCount=%s" % (checkInPlayerID, todayHelpCount, dayFreeHelpCount))
            return False, needGoldCall
        if goldCallCount >= maxGoldHelpPlayerCount:
            GameWorld.DebugLog("    ³¬¹ý×î´ó¸¶·ÑÕÙ»½ÈËÊý, checkInPlayerID=%s,goldCallCount=%s > maxGoldHelpPlayerCount=%s" % (checkInPlayerID, goldCallCount, maxGoldHelpPlayerCount))
            return False, needGoldCall
    return True, needGoldCall
 
def __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount):
    ## Ìí¼ÓÖúÕ½Íæ¼Òµ½ÖúÕ½Áбí
    if needGoldCall:
        goldCallCount += 1
    relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
    if relation:
        nowRelationCount += 1
        if not needGoldCall:
            nowFreeRelationCount += 1
    helpPlayerID = helpBattlePlayer.playerID
    helpBattlePlayerDict[helpPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
    GameWorld.DebugLog("    ÖúÕ½ÁбíÌí¼ÓÍæ¼Ò: helpPlayerID=%s,needGoldCall=%s,relation=%s,goldCallCount=%s,nowRelationCount=%s,nowFreeRelationCount=%s" 
                       % (helpPlayerID, needGoldCall, relation, goldCallCount, nowRelationCount, nowFreeRelationCount))
    return goldCallCount, nowRelationCount, nowFreeRelationCount
 
def __GetHelpBattleRelation(curPlayer, helpBattlePlayer):
    ## »ñÈ¡ÖúÕ½Éç½»¹ØÏµ 0-ÎÞ£¬1-ºÃÓÑ£¬2-ÃËÓÑ
    if not helpBattlePlayer:
        return 0
    playerID = curPlayer.GetPlayerID()
    tagPlayerID = helpBattlePlayer.playerID
    tagFamilyID = helpBattlePlayer.familyID
    relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # Éç½»¹ØÏµÓÅÏȼ¶
    for checkRelation in relationList:
        if checkRelation == 1:
            if PlayerFriend.IsFriend(playerID, tagPlayerID):
                return checkRelation
        if checkRelation == 2:
            if tagFamilyID and curPlayer.GetFamilyID() == tagFamilyID:
                return checkRelation
    return 0
 
def __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, job, relation=0):
    ## »ñȡͬ²½¸øµØÍ¼µÄÖúÕ½Íæ¼Ò¼òÒªÐÅÏ¢
    helpPlayerDict = {"Job":job}
    if not helpBattlePlayer:
        return helpPlayerDict
    if needGoldCall:
        helpPlayerDict["NeedGoldCall"] = 1
    helpPlayerDict["Name"] = helpBattlePlayer.playerName
    helpPlayerDict["LV"] = helpBattlePlayer.playerLV
    #helpPlayerDict["Job"] = helpBattlePlayer.job
    helpPlayerDict["RealmLV"] = helpBattlePlayer.realmLV
    helpPlayerDict["FightPower"] = helpBattlePlayer.fightPower
    helpPlayerDict["Relation"] = relation
    return helpPlayerDict
 
def __DoFBHelpBattleSweepCall(curPlayer, msgList):
    ''' É¨µ´ÖúÕ½ÁбíË¢ÐÂÇÒÖ±½ÓÕÙ»½
            Ëæ»úÑ¡ÔñÃâ·ÑµÄÍæ¼Ò¡¢¹ýÂËÏÉÔµ±ÒÒÑ´ïÉÏÏÞ»òÒç³öµÄÍæ¼Ò
    '''
    mapID, funcLineID = msgList[1:]
    
    helpBattlePlayerDict = {} # Í¬²½¸øµØÍ¼·þÎñÆ÷µÄ´ýÑ¡ÖúÕ½Íæ¼ÒÁбíÐÅÏ¢
    
    fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)
    fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)
    if not fbFuncIpyData or not fbHelpIpyData:
        return [helpBattlePlayerDict]
    
    fightPowerMin = fbHelpIpyData.GetFightPowerMin()
    fightPowerMax = fbHelpIpyData.GetFightPowerMax()
    limitLV = fbHelpIpyData.GetLVLimit()
    dayFreeHelpCountInfo = fbHelpIpyData.GetDayFreeHelpCount() # Ã¿ÈÕÃâ·ÑÖúÕ½´ÎÊý£¬[ÿÈÕÃâ·ÑÖúÕ½´ÎÊý, ÊÇ·ñËùÓвãͨÓÃ]
    dayFreeHelpCount = 0 # 0ΪÎÞÏÞÖÆ´ÎÊý
    helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0
    if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:
        dayFreeHelpCount, isAllLineCount = dayFreeHelpCountInfo
        if isAllLineCount:
            helpCountLineID = 0
    helpCountKey = (mapID, helpCountLineID)
    
    playerID = curPlayer.GetPlayerID()
    tagPlayerID = playerID
    tagPlayerName = curPlayer.GetName()
    GameWorld.Log("ɨµ´Ë¢ÐÂÖúÕ½Áбí: mapID=%s,funcLineID=%s,helpCountLineID=%s" % (mapID, funcLineID, helpCountLineID), playerID)
    
    curTime = int(time.time())
    maxHelpPlayerCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # ×î´óÖúÕ½ÈËÊý
    checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±
    checkInValidSeconds = checkInValidHours * 3600
    
    xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # Ã¿ÈÕÏÉÔµ±ÒÉÏÏÞ
    baseHelpPoint = fbFuncIpyData.GetHelpPoint() # ÖúÕ½ - »ù´¡ÏÉÔµ±Ò
    relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # Éç½»¹ØÏµ¼Ó³É {"Éç½»¹ØÏµ":[¹ý¹Ø¼Ó³É, ÖúÕ½¼Ó³É], ...} 
    
    isSweep = True
    onlyFree = True
    checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
    random.shuffle(checkInPlayerIDList) # Ë¢Ð´¿Ëæ»ú
    GameWorld.Log("    µÇ¼ÇÖúÕ½ÈËÊý=%s" % (len(checkInPlayerIDList)), playerID)
    for checkInPlayerID in checkInPlayerIDList:
        if len(helpBattlePlayerDict) >= maxHelpPlayerCount:
            GameWorld.DebugLog("    ³¬¹ý×î´ó¸öÊýÁ˲»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)
            break
        helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
        canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
                                                   checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)
        if not canHelp:
            continue
        
        relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
        if not __DoCallHelpPlayer(tagPlayerID, tagPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep, 
                                  curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):
            continue
        
        helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
        
    # ²»×ãµÄ»úÆ÷ÈËNPC²¹×ã
    openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # ¿ª·ÅµÄÖ°Òµ
    lackCount = maxHelpPlayerCount - len(helpBattlePlayerDict)
    robotID = 0 # »úÆ÷ÈËNPC¶¨ÒåID´Ó1¿ªÊ¼
    while lackCount > 0 and robotID < MaxRobotID:
        robotID += 1
        if robotID in helpBattlePlayerDict:
            continue
        lackCount -= 1
        randJob = random.choice(openJobList)
        helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
    
    GameWorld.Log("    helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
    return [helpBattlePlayerDict]
 
def __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep, curTime, 
                       xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):
    
    calledPlayerID = helpBattlePlayer.playerID
    addCoinRate = 10000 # »ù´¡±¶ÂÊ
    playerXianyuanCoinUpper = xianyuanCoinUpper
    relationAddList = relationCoinAddDict.get(str(relation), [])
    relationAdd = relationAddList[1] if len(relationAddList) == 2 else 0
    
    todayXianyuanCoin = helpBattlePlayer.todayXianyuanCoin # ½ñÈÕÒÑ»ñµÃÏÉÔµ±Ò
    vipLV = helpBattlePlayer.vipLV
    if vipLV:
        xianyuanCoinUpperAdd = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)
        xianyuanCoinAddPer = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinAddPer)
        
        playerXianyuanCoinUpper += xianyuanCoinUpperAdd
        addCoinRate += xianyuanCoinAddPer
        
    # ÏÉÔµ±Ò¹«Ê½=£¨Í¨¹ØÏÉÔµ±Ò»òÖúÕ½ÏÉÔµ±Ò+Éç½»¹ØÏµ¼Ó³É£©*VIP±¶Êý
    coinAdd = int((baseHelpPoint + relationAdd) * addCoinRate / 10000.0)
    canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)
    
    # É¨µ´²»¿ÉÒç³ö
    if isSweep and coinAdd > canAddMax:
        GameWorld.DebugLog("    ½ñÈÕÏÉÔµ±ÒÒÑ´ïÉÏÏÞ, calledPlayerID=%s,coinAdd=%s > canAddMax=%s" % (calledPlayerID, coinAdd, canAddMax))
        return
    coinAddReal = min(coinAdd, canAddMax) # Êµ¼Ê¼ÓÏÉÔµ±Ò
    
    todayMapHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
    helpBattlePlayer.todayHelpCountDict[helpCountKey] = todayMapHelpCount
    GameWorld.DebugLog("    ÖúÕ½Ôö¼ÓÏÉÔµ±Ò: todayXianyuanCoin=%s,coinUpper=%s,canAddMax=%s,coinAdd=%s,coinAddReal=%s,todayMapHelpCount=%s" 
                       % (todayXianyuanCoin, playerXianyuanCoinUpper, canAddMax, coinAdd, coinAddReal, todayMapHelpCount), calledPlayerID)
    
    # GameServer Ö±½ÓÏȼÓ
    helpBattlePlayer.todayXianyuanCoin += coinAddReal
    
    helpRecord = FBHelpBattleRecord()
    helpRecord.callPlayerID = callPlayerID # ÕÙ»½ËûµÄÍæ¼ÒID
    helpRecord.callPlayerName = callPlayerName
    helpRecord.mapID = mapID
    helpRecord.funcLineID = funcLineID
    helpRecord.xianyuanCoinAdd = coinAddReal
    helpRecord.relation = relation
    helpRecord.vipLV = vipLV
    helpRecord.recordTime = curTime
    
    calledPlayer = GameWorld.GetPlayerManager().FindPlayerByID(calledPlayerID)
    # ·ÇÍÑ»úÔÚÏßÖ±½Ó֪ͨµØÍ¼
    if calledPlayer and not PlayerControl.GetIsTJG(calledPlayer):
        SendMapServer_FBHelpBattleRecord(calledPlayer, [helpRecord])
    else:
        unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(calledPlayerID, [])
        unNotifyRecordList.append(helpRecord)
        PyGameData.g_fbHelpBattleRecord[calledPlayerID] = unNotifyRecordList
    return True
 
def __DoFBHelpBattleCall(callPlayerID, callPlayerName, msgList):
    ''' ÖúÕ½ÕÙ»½£¬²»¹Ü×îÖÕ¹ý¹ØÓë·ñ£¬±»ÕÙ»½·½¶¼Ö±½ÓËãÖúÕ½³É¹¦£¬ÕâÀï´¦Àí±»ÕÙ»½µÄ£¬Ö÷¶¯·½ÔÚµØÍ¼Ö±½Ó´¦Àí
    '''
    # calledPlayerDict = {} # {±»ÕÙ»½µÄÍæ¼ÒID:¹ØÏµ, ...}
    mapID, funcLineID, calledPlayerDict = msgList[1:]
    fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)
    fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)
    if not fbFuncIpyData or not fbHelpIpyData or not calledPlayerDict:
        return
    
    helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0
    dayFreeHelpCountInfo = fbHelpIpyData.GetDayFreeHelpCount()
    if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:
        isAllLineCount = dayFreeHelpCountInfo[1]
        if isAllLineCount:
            helpCountLineID = 0
    helpCountKey = (mapID, helpCountLineID)
    
    curTime = int(time.time())
    xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # Ã¿ÈÕÏÉÔµ±ÒÉÏÏÞ
    baseHelpPoint = fbFuncIpyData.GetHelpPoint() # ÖúÕ½ - »ù´¡ÏÉÔµ±Ò
    relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # Éç½»¹ØÏµ¼Ó³É {"Éç½»¹ØÏµ":[¹ý¹Ø¼Ó³É, ÖúÕ½¼Ó³É], ...} 
    GameWorld.DebugLog("ÕÙ»½ÖúÕ½: mapID=%s, funcLineID=%s, helpCountKey=%s, calledPlayerDict=%s" % (mapID, funcLineID, helpCountKey, calledPlayerDict), callPlayerID)
    isSweep = False
    for calledPlayerID, relation in calledPlayerDict.items():
        if calledPlayerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
            continue
        helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[calledPlayerID]
        __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep, 
                           curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint)
    return
 
def SendMapServer_FBHelpBattleRecord(curPlayer, syncHelpRecordList, isLogin=False):
    if not syncHelpRecordList:
        return
    
    helpRecordList = []
    for record in syncHelpRecordList:
        helpRecordList.append([record.callPlayerID, record.callPlayerName, record.mapID, record.funcLineID, 
                               record.xianyuanCoinAdd, record.relation, record.vipLV, record.recordTime])
    addXianyuanCoinMsg = str(["HelpRecord", helpRecordList, isLogin])
    curPlayer.MapServer_QueryPlayerResult(0, 0, 'FBHelpBattle', addXianyuanCoinMsg, len(addXianyuanCoinMsg))
    GameWorld.DebugLog("    MapServer_QueryPlayerResult %s" % addXianyuanCoinMsg, curPlayer.GetPlayerID())
    return