ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRecover.py
@@ -32,7 +32,9 @@
import GameFuncComm
import PlayerTJG
import PlayerActivity
import PlayerSuccess
import PyGameData
import BossHurtMng
import copy
import datetime
@@ -43,7 +45,7 @@
) = range(2)
Def_TJGRecoverID = 1 #脱机挂找回索引ID
Def_QueenRelics = 11 #娲皇遗迹找回索引ID
## OnDay处理
#  @param curPlayer
#  @return None
@@ -68,6 +70,7 @@
    playerLV = curPlayer.GetLV()
    if playerLV <= 1: #刚创角不增加次数
        return
    RecoverMaxDay = 2 # 最多可找回X天总次数
    lostOnDayNum = __GetLastRecoverPastDay(curPlayer)
    lostOnDayNum = max(0, lostOnDayNum - 1)
    GameWorld.DebugLog('    增加可找回次数 lostOnDayNum=%s'%lostOnDayNum)
@@ -103,8 +106,8 @@
                continue
            remainInfo, limitInfo = FBCommon.GetFBDetailCntInfo(curPlayer, dataMapID)
            rCommonCnt, rExtraCnt, rBuyCnt, rItemAddCnt, noBuyCnt = remainInfo
            rCommonCntlimit, rExtraCntlimit, rBuyCntlimit, rItemAddCntlimit, noBuyCntlimit = limitInfo
            rCommonCnt, rRegainFbCnt, rExtraCnt, rBuyCnt, rItemAddCnt, noBuyCnt = remainInfo
            rCommonCntlimit, rRegainFbCntLimit, rExtraCntlimit, rBuyCntlimit, rItemAddCntlimit, noBuyCntlimit = limitInfo
            if max(remainInfo) == 0 and not lostOnDayNum:
                continue
            #限时活动判断当天是否有开启
@@ -116,11 +119,11 @@
            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:
@@ -129,41 +132,53 @@
            
            #更新可找回次数
            curCommonCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBCommonCnt % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBCommonCnt % index,
                                               min(addCommonCnt + curCommonCnt, rCommonCntlimit * 2))
            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)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBExtraCnt % index,
                                               min(addExtraCnt + curExtraCnt, rExtraCntlimit * 2))
            addExtraCnt = min(addExtraCnt + curExtraCnt, rExtraCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBExtraCnt % index, addExtraCnt)
            curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBBuyCnt % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBBuyCnt % index,
                                               min(addBuyCnt + curBuyCnt, rBuyCntlimit * 2))
            addBuyCnt = min(addBuyCnt + curBuyCnt, rBuyCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBBuyCnt % index, addBuyCnt)
            curItemAddCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBItemAddCnt % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBItemAddCnt % index,
                                               min(addItemAddCnt + curItemAddCnt, rItemAddCntlimit * 2))
            addItemAddCnt = min(addItemAddCnt + curItemAddCnt, rItemAddCntlimit * RecoverMaxDay)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBItemAddCnt % index, addItemAddCnt)
            curnoBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverFBNoBuyCnt % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_RecoverFBNoBuyCnt % index,
                                               min(addnoBuyCnt + curnoBuyCnt, noBuyCntlimit * 2))
            GameWorld.DebugLog('增加找回次数index=%s,addCommonCnt=%s,addExtraCnt=%s,addBuyCnt=%s,addItemAddCnt=%s,addnoBuyCnt=%s'
                               % (index, addCommonCnt, addExtraCnt, addBuyCnt, addItemAddCnt, addnoBuyCnt))
            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 == ShareDefine.DailyActionID_Dice:#我要太极只分是否参加过,没参加过才能找回,次数算1次
            if dailyID in [ShareDefine.DailyActionID_Dice, ShareDefine.DailyActionID_IceLode]:#我要太极只分是否参加过,没参加过才能找回,次数算1次
                dayTimesLimit = 1
                if curDayTimes:
                    curDayTimes = dayTimesLimit
            if curDayTimes >= dayTimesLimit and not lostOnDayNum:
            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) + lostOnDayNum * dayTimesLimit
            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 * 2))
                                               min(addCommonCnt + curCommonCnt, dayTimesLimit * RecoverMaxDay))
            recoverNumList.append(index)
            GameWorld.DebugLog('增加找回次数index=%s,addCommonCnt=%s'
                               % (index, addCommonCnt))
@@ -260,7 +275,12 @@
    
    infoDict = {ChConfig.Def_Cost_Reason_SonKey:recoverWay}
    for moneyType, moneyCnt in costMoneyDict.items():
        PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_RecoverGain, infoDict)
        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:
@@ -282,11 +302,12 @@
            
        else:
            for itemID, itemCnt in totalItemDict.items(): 
                ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 1, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], True, showSysInfo=True)
                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)
@@ -328,39 +349,40 @@
            costMoney = int(normalCostJade * recoverSecond / float(3600))
        else:
            costMoney = min(commonCnt, recoverCnt) * normalCostJade + vipCostJade * max(0, recoverCnt - commonCnt)
        costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
        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
        if PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, costMoney, False):
            costMoneyList = [[IPY_GameWorld.TYPE_Price_Silver_Money, costMoney]]
        else:
            costMoneyList = []
        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 + curExtraCnt + curBuyCnt + curItemAddCnt, curnoBuyCnt
    return curCommonCnt + curRegainCnt + curExtraCnt + curBuyCnt + curItemAddCnt, curnoBuyCnt
def __SetRecoverNum(curPlayer, recoverCntDict):
    #更新找回次数
    #每日刷新次数>Vip买回来没用的次数>卷轴加的没用的次数>Vip额外次数>Vip可购买但未买次数
    #每日刷新次数>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, curExtraCnt, curnoBuyCnt]
        cntList = [curCommonCnt, curBuyCnt, curItemAddCnt, curRegainCnt, curExtraCnt, curnoBuyCnt]
        newCntList = copy.deepcopy(cntList)
        
        sumCnt = 0
@@ -369,15 +391,39 @@
            newCntList[i] = max(0, sumCnt - recoverCnt)
            if recoverCnt <= sumCnt:
                break
        newCommonCnt,newBuyCnt,newItemAddCnt,newExtraCnt,newnoBuyCnt = newCntList
        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)
        if max(newCommonCnt, newBuyCnt, newItemAddCnt, newExtraCnt, newnoBuyCnt) == 0 and index != Def_TJGRecoverID:
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HaveRecover % index, 1)
        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
@@ -393,8 +439,8 @@
    reExp = PlayerControl.GetPlayerReExp(curPlayer)
    expRate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Recover)
    extraData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainData % index, 0)
    extraData2 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainDataEx % index, 0)
    dataEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_RecoverGainDataEx % index, 0)
    realmLV = curPlayer.GetOfficialRank()
    tjgExp = 0 #脱机挂找回经验
    exp = 0
    sp = 0
@@ -419,6 +465,8 @@
        
    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', '')
@@ -427,10 +475,23 @@
            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
@@ -457,6 +518,7 @@
        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)