#!/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
|