hxp
2 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.PlayerRecover
#
# @todo:×ÊÔ´ÕÒ»Ø
# @author xdh
# @date 2018-01-10 22:20
# @version 1.0
#
#
# ÏêϸÃèÊö: ×ÊÔ´ÕÒ»Ø
#---------------------------------------------------------------------
#"""Version = 2018-01-10 22:20"""
#---------------------------------------------------------------------
import GameWorld
import FormulaControl
import PlayerControl
import ChConfig
import ChPyNetSendPack
import NetPackCommon
import IPY_GameWorld
import ShareDefine
import ItemControler
import DataRecordPack
import ItemCommon
import IpyGameDataPY
import FBCommon
import GameFuncComm
import PlayerTJG
import PlayerActivity
import PlayerSuccess
import PyGameData
import BossHurtMng
 
import copy
import datetime
 
(
RecoverWay1, #°óÓñÕÒ»Ø
RecoverWay2, #Í­Ç®ÕÒ»Ø
) = range(2)
 
Def_TJGRecoverID = 1 #ÍÑ»ú¹ÒÕÒ»ØË÷ÒýID
Def_QueenRelics = 11 #æ´»ÊÒż£ÕÒ»ØË÷ÒýID
## OnDay´¦Àí
#  @param curPlayer
#  @return None
def RecoverOnDay(curPlayer):
    AddRecoverTimes(curPlayer)
    curTime = GameWorld.GetCurrentTime()
    
    curTimeNum = GameWorld.ChangeTimeStrToNum(str(curTime)[:10], ChConfig.TYPE_Time_Format_Day)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverGainLastTime, curTimeNum)
    return
 
## OnLogin´¦Àí
#  @param curPlayer
#  @return None
def RecoverOnLogin(curPlayer):
    __NotifyRecoverNum(curPlayer)
    return
 
 
#Ôö¼Ó¿ÉÕһشÎÊý
def AddRecoverTimes(curPlayer):
    playerLV = curPlayer.GetLV()
    if playerLV <= 1: #¸Õ´´½Ç²»Ôö¼Ó´ÎÊý
        return
    RecoverMaxDay = 2 # ×î¶à¿ÉÕÒ»ØXÌì×Ü´ÎÊý
    lostOnDayNum = __GetLastRecoverPastDay(curPlayer)
    lostOnDayNum = max(0, lostOnDayNum - 1)
    GameWorld.DebugLog('    Ôö¼Ó¿ÉÕһشÎÊý lostOnDayNum=%s'%lostOnDayNum)
    recoverNumList = []
    curTime = GameWorld.GetCurrentTime()
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetResourcesBackCount()):
        recoverData = ipyDataMgr.GetResourcesBackByIndex(i)
        index = recoverData.GetID()
        if index == Def_TJGRecoverID:
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HaveRecover % index, 0)
        relatedID = recoverData.GetRelatedID()
        dailyQuestData = IpyGameDataPY.GetIpyGameDataNotLog('DailyQuest', relatedID)
        if not dailyQuestData:
            continue
        unLockFuncID = dailyQuestData.GetUnLockFuncID()
        if unLockFuncID and not GameFuncComm.GetFuncCanUse(curPlayer, unLockFuncID):
            continue
        
        if dailyQuestData.GetRelatedType() == 2: #¸±±¾Àà
            dataMapID = dailyQuestData.GetRelatedID()
            fbIpyData = FBCommon.GetFBIpyData(dataMapID)
            if not fbIpyData:
                continue
            maxTimes = fbIpyData.GetDayTimes()
            if not maxTimes:
                #ûÓÐÿÈÕ¿ÉÌôÕ½´ÎÊý
                continue
            historyMaxLine = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FBHistoryMaxLine % dataMapID)
            if dataMapID in ChConfig.Def_UnRecoverNoPassMap and not historyMaxLine:
                #ûͨ¹Ø¹ýµÄÌØÊ⸱±¾²»¿ÉÕÒ»Ø
                continue
 
            remainInfo, limitInfo = FBCommon.GetFBDetailCntInfo(curPlayer, dataMapID)
            rCommonCnt, rRegainFbCnt, rExtraCnt, rBuyCnt, rItemAddCnt, noBuyCnt = remainInfo
            rCommonCntlimit, rRegainFbCntLimit, rExtraCntlimit, rBuyCntlimit, rItemAddCntlimit, noBuyCntlimit = limitInfo
            if max(remainInfo) == 0 and not lostOnDayNum:
                continue
            #ÏÞʱ»î¶¯Åжϵ±ÌìÊÇ·ñÓпªÆô
            if dataMapID in PyGameData.FBEnterTimeLimiitMapID:
                fbOpenCnt = __GetLimitFBCnt(curPlayer, lostOnDayNum+1, dataMapID)
                if not fbOpenCnt:
                    continue
                addCommonCnt = rCommonCnt + (fbOpenCnt-1)*rCommonCntlimit
            else:
                addCommonCnt = rCommonCnt + lostOnDayNum * rCommonCntlimit
            
            addRegainCnt = rRegainFbCnt + lostOnDayNum * rRegainFbCntLimit
            addExtraCnt = rExtraCnt + lostOnDayNum * rExtraCntlimit
            addBuyCnt = rBuyCnt
            addItemAddCnt = rItemAddCnt #ʹÓÃÎïÆ·Ôö¼ÓµÄ´ÎÊý
            addnoBuyCnt = noBuyCnt + lostOnDayNum * noBuyCntlimit
            
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverGainData % index, historyMaxLine)
            if dataMapID == ChConfig.Def_FBMapID_MunekadoTrial:
                historyStar = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, historyMaxLine-1, False, [dataMapID])
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverGainDataEx % index, historyStar)
            
            #¸üпÉÕһشÎÊý
            curCommonCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBCommonCnt % index, 0)
            addCommonCnt = min(addCommonCnt + curCommonCnt, rCommonCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBCommonCnt % index, addCommonCnt)
            
            curRegainCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBRegainCnt % index, 0)
            addRegainCnt = min(addRegainCnt + curRegainCnt, rRegainFbCntLimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBRegainCnt % index, addRegainCnt)
            
            curExtraCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBExtraCnt % index, 0)
            addExtraCnt = min(addExtraCnt + curExtraCnt, rExtraCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBExtraCnt % index, addExtraCnt)
            
            curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBBuyCnt % index, 0)
            addBuyCnt = min(addBuyCnt + curBuyCnt, rBuyCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBBuyCnt % index, addBuyCnt)
            
            curItemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBItemAddCnt % index, 0)
            addItemAddCnt = min(addItemAddCnt + curItemAddCnt, rItemAddCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBItemAddCnt % index, addItemAddCnt)
            
            curnoBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, 0)
            addnoBuyCnt = min(addnoBuyCnt + curnoBuyCnt, noBuyCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, addnoBuyCnt)
            
            GameWorld.DebugLog('Ôö¼ÓÕһشÎÊýindex=%s,addCommonCnt=%s,addRegainCnt=%s,addExtraCnt=%s,addBuyCnt=%s,addItemAddCnt=%s,addnoBuyCnt=%s'
                               % (index, addCommonCnt, addRegainCnt, addExtraCnt, addBuyCnt, addItemAddCnt, addnoBuyCnt))
            
            
            recoverNumList.append(index)
        elif dailyQuestData.GetRelatedType() == 1:#ÿÈջ
            dailyID = dailyQuestData.GetRelatedID()
            lostOnDay = lostOnDayNum
            curDayTimes, dayTimesLimit = PlayerActivity.GetDailyActionFinishCnt(curPlayer, dailyID)
            if dailyID in [ShareDefine.DailyActionID_Dice, ShareDefine.DailyActionID_IceLode]:#ÎÒҪ̫¼«Ö»·ÖÊÇ·ñ²Î¼Ó¹ý£¬Ã»²Î¼Ó¹ý²ÅÄÜÕһأ¬´ÎÊýËã1´Î
                dayTimesLimit = 1
                if curDayTimes:
                    curDayTimes = dayTimesLimit
            elif dailyID is ShareDefine.DailyActionID_WorldBOSS:
                canKillCnt, dayTimesLimit = BossHurtMng.GetCanKillBossCnt(curPlayer, 0)
                curDayTimes = dayTimesLimit - canKillCnt
            if curDayTimes >= dayTimesLimit and not lostOnDay:
                continue
            addCommonCnt = (dayTimesLimit - curDayTimes) + lostOnDay * dayTimesLimit
            if addCommonCnt <=0:
                continue
            curCommonCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBCommonCnt % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBCommonCnt % index,
                                               min(addCommonCnt + curCommonCnt, dayTimesLimit * RecoverMaxDay))
            recoverNumList.append(index)
            GameWorld.DebugLog('Ôö¼ÓÕһشÎÊýindex=%s,addCommonCnt=%s'
                               % (index, addCommonCnt))
        
    __NotifyRecoverNum(curPlayer)
    return
 
 
 
## »ñÈ¡µ±Ç°¾àÀëÉÏÒ»´ÎÔö¼Ó×ÊÔ´ÕһصÄÌìÊý
def __GetLastRecoverPastDay(curPlayer):
    recoverGainLastTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainLastTime, 0)
    if not recoverGainLastTime:
        return 0
    
    curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr())
    passTick = max(0, curTime - recoverGainLastTime)
    pastDay = passTick / 3600 / 24
    return pastDay
 
def __GetLimitFBCnt(curPlayer, pastDay, dataMapID):
    # »ñÈ¡ÏÞʱ¸±±¾ÔÚ¼¸Ììǰ¹²¿ªÆôÁ˼¸´Î
    if not pastDay:
        return 0
    curTime = GameWorld.GetCurrentTime()
    fbOpenCnt = 0
    for diffDays in range(pastDay):
        timeData = curTime - datetime.timedelta(days = diffDays+1)
        dayStr = '%02d%02d'%(timeData.month, timeData.day)
        #GameWorld.DebugLog('    dataMapID=%s,pastDay=%s,dayStr=%s'%(dataMapID, pastDay, dayStr))
        if not FBCommon.GetFBHasOpenToday(dataMapID, dayStr):
            continue
        fbOpenCnt += 1
    #GameWorld.DebugLog('    111111111111dataMapID=%s,fbOpenCnt=%s'%(dataMapID,fbOpenCnt))
    return fbOpenCnt
 
#// A5 53 ×ÊÔ´Õһؠ#tagCMRecoverGain
#
#struct    tagCMRecoverGain
#{
#    tagHead        Head;
#    BYTE        Type;    // Õһط½Ê½ 0 ÏÉÓñ 1Í­Ç®
#    BYTE        Cnt;    
#    BYTE        IndexList[Cnt];    // ÕÒ»ØË÷ÒýÁбí
#    BYTE        RecoverCntList[Cnt];    // Ë÷Òý¶ÔÓ¦ÕһشÎÊýÁбí
#};
def OnRecoverGain(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    
    GameWorld.DebugLog("==[PlayerRecover]== In->OnRecoverGain(), Name:%s" % curPlayer.GetPlayerName())
    
    recoverWay = clientData.Type
    if recoverWay not in [0, 1]:
        GameWorld.DebugLog("OnRecoverGain() hasn't recover way(%s)" % recoverWay)
        return
    if not clientData.Cnt:
        return
    recoverIndexList = clientData.IndexList
    recoverCntList = clientData.RecoverCntList
    costMoneyDict = {}
    recoverCntDict = {}
    mapIDInfo = []
    totalExp, totalSP, totalMoney, totalItemDict = 0, 0, 0, {}
    for i, index in enumerate(recoverIndexList):
        if index == Def_TJGRecoverID:
            recoverCnt = 1
        else:
            recoverCnt = recoverCntList[i]
        ipyData = IpyGameDataPY.GetIpyGameData('ResourcesBack', index)
        if not ipyData:
            continue
        
        costMoneyList, recoverCnt = __GetRecoverCost(curPlayer, recoverWay, recoverCnt, ipyData)
        if not costMoneyList:
            continue
        for moneyType, moneyCnt in costMoneyList:
            costMoneyDict[moneyType] = costMoneyDict.get(moneyType, 0) + moneyCnt
        #½±Àø
        if ipyData.GetCanBackTimes() and recoverWay == RecoverWay1:
            dataMapID = __DoLogicBackTimes(curPlayer, ipyData, recoverCnt)
            if dataMapID:
                mapIDInfo.append(dataMapID)
        else:
            exp, sp, money, itemDict = __GetRecoverGain(curPlayer, recoverWay, recoverCnt, ipyData)
            totalExp += exp
            totalSP += sp
            totalMoney += money
            for itemID, itemCnt in itemDict.items():
                totalItemDict[itemID] = totalItemDict.get(itemID, 0) + itemCnt
        recoverCntDict[index] = recoverCnt
        
    if not recoverCntDict:
        return
    
    infoDict = {ChConfig.Def_Cost_Reason_SonKey:recoverWay}
    for moneyType, moneyCnt in costMoneyDict.items():
        costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, moneyType, moneyCnt)
        GameWorld.DebugLog('    moneyType=%s,moneyCnt=%s,costMoneyList=%s'%(moneyType, moneyCnt, costMoneyList))
        if not costMoneyList:
            return
        for mType, mCnt in costMoneyList:
            PlayerControl.PayMoney(curPlayer, mType, mCnt, ChConfig.Def_Cost_RecoverGain, infoDict)
        
        
    if totalExp > 0:
        PlayerControl.PlayerControl(curPlayer).AddExp(totalExp)
        
    giveMoneyType = IPY_GameWorld.TYPE_Price_Silver_Money
    if totalMoney > 0:
        PlayerControl.GiveMoney(curPlayer, giveMoneyType, totalMoney, ChConfig.Def_GiveMoney_Recover)
        
    if totalSP > 0:
        PlayerControl.PlayerAddZhenQi(curPlayer, totalSP, True, True, "Recover")
    
    
    if totalItemDict:
        emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)
        if len(totalItemDict) > emptySpace:
            #Óʼþ
            prizeItemList = [[itemID, itemCnt, 1] for itemID, itemCnt in totalItemDict.items()]
            PlayerControl.SendMailByKey('', [curPlayer.GetPlayerID()], prizeItemList)
            
        else:
            for itemID, itemCnt in totalItemDict.items(): 
                ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere])
    #if Def_TJGRecoverID in recoverCntDict:
    #    #ÍÑ»ú¹Ò¾­ÑéÕһغóÖØÖÃ
    #    PlayerTJG.ResetTJGDeadInfo(curPlayer)
    if Def_QueenRelics in recoverCntDict:
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_QueenRelicsEx, recoverCntDict[Def_QueenRelics])
    DataRecordPack.DR_PlayerRecover(curPlayer, recoverWay, recoverCntDict, totalExp, totalMoney, totalSP, totalItemDict)        
    __SetRecoverNum(curPlayer, recoverCntDict)
    __NotifyRecoverNum(curPlayer)
    if mapIDInfo:
        FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapIDInfo)
    GameWorld.DebugLog("==[PlayerRecover]== Out->OnRecoverGain() recoverWay=%s, costMoneyDict=%s, recoverCntDict=%s, totalExp=%s, totalMoney=%s, totalSP=%s, totalItemDict=%s" % (recoverWay, costMoneyDict, recoverCntDict, totalExp, totalMoney, totalSP, totalItemDict))
    ItemControler.NotifyGiveAwardInfo(curPlayer, totalItemDict, "Recover", totalExp, moneyInfo={giveMoneyType:totalMoney})
    return
 
def __DoLogicBackTimes(curPlayer, recoverData, recoverCnt):
    #¸±±¾»ò»î¶¯»Ö¸´´ÎÊý
    relatedID = recoverData.GetRelatedID()
    dailyQuestData = IpyGameDataPY.GetIpyGameData('DailyQuest', relatedID)
    if not dailyQuestData:
        return 0
    if dailyQuestData.GetRelatedType() == 2: #¸±±¾Àà
        dataMapID = dailyQuestData.GetRelatedID()
        recoverFbCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_RecoverFbCnt % dataMapID)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RecoverFbCnt % dataMapID, recoverFbCnt + recoverCnt)
    else:
        return 0
    return dataMapID
 
## »ñÈ¡ÏûºÄ
#  @param curPlayer
#  @param recoverWay Õһط½Ê½
#  @param recoverIndex ÕÒ»ØË÷Òý
#  @return ½ðÇ®ÀàÐÍ,½ðÇ®ÊýÁ¿,ÕһذٷֱÈ
def __GetRecoverCost(curPlayer, recoverWay, recoverCnt, ipyData):
    index = ipyData.GetID()
    if index != Def_TJGRecoverID:
        commonCnt, vipExtraCnt = __GetCanRecoverCnt(curPlayer, index)
        recoverCnt = min(recoverCnt, commonCnt + vipExtraCnt)
    
    recoverSecond = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadPayTime) #¿ÉÕһضàÉÙÃëµÄÍÑ»ú¹Ò¾­Ñé
    if recoverWay == RecoverWay1: #°óÓñ+ÏÉÓñ
        normalCostJade = ipyData.GetNormalCostJade()
        vipCostJade = ipyData.GetVipCostJade()
        if index == Def_TJGRecoverID:
            costMoney = int(normalCostJade * recoverSecond / float(3600))
        else:
            costMoney = min(commonCnt, recoverCnt) * normalCostJade + vipCostJade * max(0, recoverCnt - commonCnt)
        costMoneyList = [[ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney]]
    else:
        costCopper = ipyData.GetCostCopper()
        if index == Def_TJGRecoverID:
            costMoney = int(costCopper * recoverSecond / float(3600))
        else:
            costMoney = recoverCnt * costCopper
        
        costMoneyList = [[IPY_GameWorld.TYPE_Price_Silver_Money, costMoney]]
        
    return costMoneyList, recoverCnt
 
def __GetCanRecoverCnt(curPlayer, index):
    #»ñÈ¡¿ÉÕÒ»ØÆÕͨ´ÎÊý£¬vip´ÎÊý
    curCommonCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBCommonCnt % index, 0)
    curRegainCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBRegainCnt % index, 0)
    curExtraCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBExtraCnt % index, 0)
    curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBBuyCnt % index, 0)
    curItemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBItemAddCnt % index, 0)
    curnoBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, 0)
    return curCommonCnt + curRegainCnt + curExtraCnt + curBuyCnt + curItemAddCnt, curnoBuyCnt
 
def __SetRecoverNum(curPlayer, recoverCntDict):
    #¸üÐÂÕһشÎÊý
    #ÿÈÕˢдÎÊý£¾VipÂò»ØÀ´Ã»ÓõĴÎÊý£¾¾íÖá¼ÓµÄûÓõĴÎÊý£¾Ã¿ÈÕ»Ö¸´´ÎÊý£¾Vip¶îÍâ´ÎÊý£¾Vip¿É¹ºÂòµ«Î´Âò´ÎÊý
    
    for index, recoverCnt in recoverCntDict.items():
        curCommonCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBCommonCnt % index, 0)
        curRegainCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBRegainCnt % index, 0)
        curExtraCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBExtraCnt % index, 0)
        curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBBuyCnt % index, 0)
        curItemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBItemAddCnt % index, 0)
        curnoBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, 0)
        cntList = [curCommonCnt, curBuyCnt, curItemAddCnt, curRegainCnt, curExtraCnt, curnoBuyCnt]
        newCntList = copy.deepcopy(cntList)
        
        sumCnt = 0
        for i, cnt in enumerate(cntList):
            sumCnt += cnt
            newCntList[i] = max(0, sumCnt - recoverCnt)
            if recoverCnt <= sumCnt:
                break
        newCommonCnt, newBuyCnt, newItemAddCnt, newRegainCnt, newExtraCnt, newnoBuyCnt = newCntList
        
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBCommonCnt % index, newCommonCnt)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBRegainCnt % index, newRegainCnt)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBBuyCnt % index, newBuyCnt)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBItemAddCnt % index, newItemAddCnt)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBExtraCnt % index, newExtraCnt)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, newnoBuyCnt)
        GameWorld.DebugLog("×ÊÔ´ÕһشÎÊý: index=%s,recoverCnt=%s" % (index, recoverCnt))
        GameWorld.DebugLog("    curCommonCnt=%s,curBuyCnt=%s,curItemAddCnt=%s,curRegainCnt=%s,curExtraCnt=%s,curnoBuyCnt=%s" 
                           % (curCommonCnt, curBuyCnt, curItemAddCnt, curRegainCnt, curExtraCnt, curnoBuyCnt))
        GameWorld.DebugLog("    newCommonCnt=%s,newBuyCnt=%s,newItemAddCnt=%s,newRegainCnt=%s,newExtraCnt=%s,newnoBuyCnt=%s" 
                           % (newCommonCnt, newBuyCnt, newItemAddCnt, newRegainCnt, newExtraCnt, newnoBuyCnt))
        if index != Def_TJGRecoverID:
            #1£ºÕÒ»ØÁËÆÕͨ  2£ºÕÒ»ØÁËvip  3£º2¸ö¶¼ÓÐÕһؠ 
            recoverData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HaveRecover % index, 0)
            updData = recoverData
            if i < len(cntList) -1:
                if recoverData == 2:
                    updData = 3
                elif recoverData == 0:
                    updData = 1
            else:
                if max(curCommonCnt, curBuyCnt, curItemAddCnt, curRegainCnt, curExtraCnt) == 0:
                    if recoverData == 0:
                        updData = 2
                    elif recoverData == 1:
                        updData = 3
                else:
                    updData = 3
                    
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HaveRecover % index, updData)
     
        
    return
 
## »ñÈ¡×ÊÔ´
#  @param curPlayer
#  @param recoverWay Õһط½Ê½
#  @param recoverIndex ÕÒ»ØË÷Òý
#  @param recoverNumList ÕһشÎÊýÁбí
#  @return ¾­Ñé,½ð±Ò,ħ»ê
def __GetRecoverGain(curPlayer, recoverWay, recoverCnt, ipyData):
    index = ipyData.GetID()
    reLV = curPlayer.GetLV()
    reExp = PlayerControl.GetPlayerReExp(curPlayer)
    expRate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Recover)
    extraData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainData % index, 0)
    dataEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainDataEx % index, 0)
    realmLV = curPlayer.GetOfficialRank()
    tjgExp = 0 #ÍÑ»ú¹ÒÕһؾ­Ñé
    exp = 0
    sp = 0
    money = 0
    itemDict = {}
    if index == Def_TJGRecoverID:
        Exp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadExp)
        Exp1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadExp1)
        tjgExp = Exp1 * ChConfig.Def_PerPointValue + Exp
      
    
    awardDict = ipyData.GetJadeReward() if recoverWay == RecoverWay1 else ipyData.GetCopperReward()
    expFormula = awardDict.get("exp", '')
    if expFormula:
        exp = recoverCnt * eval(FormulaControl.GetCompileFormula('ResourcesBackEXP%s_%s' % (recoverWay, index), expFormula))
    moneyFormula = awardDict.get("money", '')
    if moneyFormula:
        money = recoverCnt * eval(FormulaControl.GetCompileFormula('ResourcesBackMoney%s_%s' % (recoverWay, index), moneyFormula))
    spFormula = awardDict.get("sp", '')
    if spFormula:
        sp = recoverCnt * eval(FormulaControl.GetCompileFormula('ResourcesBacksp%s_%s' % (recoverWay, index), spFormula))
        
    itemInfoList = awardDict.get("item", [])
    if itemInfoList:
        job = curPlayer.GetJob()
        jobItemList = ipyData.GetJobItemList()
        for itemInfo in itemInfoList:
            itemID = itemInfo.get('ItemID', 0)
            itemcntFormula = itemInfo.get('ItemCount', '')
            if not itemcntFormula:
                continue
            itemcnt = recoverCnt * eval(FormulaControl.GetCompileFormula('ResourcesBackitem%s_%s_%s' % (recoverWay, index, itemID), itemcntFormula))
            if not itemcnt:
                continue
            itemID = __GetJobItem(job, itemID, jobItemList)
            itemDict[itemID] = itemcnt
    
    return exp, sp, money, itemDict
 
def __GetJobItem(job, itemID, jobItemList):
    ## »ñÈ¡ÎïÆ·¶ÔÓ¦µÄÖ°ÒµÎïÆ·£¬ Ö°Òµ´Ó1¿ªÊ¼
    for jobItemIDList in jobItemList:
        if type(jobItemIDList) not in [list, tuple]:
            GameWorld.ErrLog("×ÊÔ´ÕÒ»ØÖ°ÒµÎïÆ·×é¸ñʽ´íÎó!itemID=%s,jobItemList=%s" % (itemID, jobItemList))
            return itemID
        if itemID in jobItemIDList:
            if job <= 0 or job > len(jobItemIDList):
                GameWorld.ErrLog("×ÊÔ´ÕÒ»ØÖ°ÒµÎïÆ·ÅäÖôíÎó,ûÓиÃÖ°Òµ¶ÔÓ¦ÎïÆ·ID!itemID=%s,job=%s" % (itemID, job))
                return itemID
            return jobItemIDList[job - 1]
    return itemID
 
## Í¨ÖªÕһشÎÊý
#  @param curPlayer
#  @param recoverIndex ÕÒ»ØË÷Òý
#  @param recoverNumList ÕһشÎÊýÁбí
#  @return None
def __NotifyRecoverNum(curPlayer, recoverNumList=[]):
    sendPack = ChPyNetSendPack.tagMCRecoverNum()
    sendPack.Clear()
    sendPack.NumInfo = []
    
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetResourcesBackCount()):
        recoverData = ipyDataMgr.GetResourcesBackByIndex(i)
        index = recoverData.GetID()
        if recoverNumList and index not in recoverNumList:
            continue
        commonCnt, vipExtraCnt = __GetCanRecoverCnt(curPlayer, index)
        haveRecover = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HaveRecover % index, 0)
        if not commonCnt and not vipExtraCnt and not haveRecover:
            continue
        numInfoPack = ChPyNetSendPack.tagMCRecoverNumInfo()
        numInfoPack.Clear()
        numInfoPack.Index = index
        numInfoPack.RecoverCnt = commonCnt
        numInfoPack.ExtraCnt = vipExtraCnt
        numInfoPack.HaveRecover = haveRecover
        numInfoPack.ExtraData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainData % index, 0)
        numInfoPack.ExtraData2 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainDataEx % index, 0)
        sendPack.NumInfo.append(numInfoPack)  
    sendPack.Num = len(sendPack.NumInfo)
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return