| | |
| | | ## 挂机定时处理收益
|
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | |
| | | if curPlayer.GetRealPlayerID() != 0:
|
| | | return
|
| | | |
| | | if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Guaji):
|
| | | return
|
| | |
|
| | |
| | | curAwardSeconds = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GuajiAwardSeconds)
|
| | | maxSeconds = GetGuajiSecondsMax(curPlayer)
|
| | | if curAwardSeconds >= maxSeconds:
|
| | | GameWorld.DebugLog("挂机收益时长已达上限: curAwardSeconds=%s >= %s" % (curAwardSeconds, maxSeconds), playerID)
|
| | | #GameWorld.DebugLog("挂机收益时长已达上限: curAwardSeconds=%s >= %s" % (curAwardSeconds, maxSeconds), playerID)
|
| | | return
|
| | |
|
| | | awardSeconds = min(maxSeconds - curAwardSeconds, awardSeconds)
|
| | |
| | |
|
| | | updAwardSeconds = curAwardSeconds + awardSeconds
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiAwardSeconds, updAwardSeconds)
|
| | | GameWorld.DebugLog("保存挂机累计收益: curAwardSeconds=%s,updAwardSeconds=%s,maxSeconds=%s" % (curAwardSeconds, updAwardSeconds, maxSeconds), playerID)
|
| | | #GameWorld.DebugLog("保存挂机累计收益: curAwardSeconds=%s,updAwardSeconds=%s,maxSeconds=%s" % (curAwardSeconds, updAwardSeconds, maxSeconds), playerID)
|
| | |
|
| | | # 经验
|
| | | exp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GuajiExpPoint) * ChConfig.Def_PerPointValue \
|
| | |
| | | updExp = exp % ChConfig.Def_PerPointValue
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiExpPoint, updExpPoint)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiExp, updExp)
|
| | | GameWorld.DebugLog(" 累计经验: %s亿%s" % (updExpPoint, updExp), playerID)
|
| | | #GameWorld.DebugLog(" 累计经验: %s亿%s" % (updExpPoint, updExp), playerID)
|
| | |
|
| | | # 货币
|
| | | for moneyType, addValue in giveMoneyDict.items():
|
| | |
| | | updMoney = min(moneyValue + addValue, ChConfig.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiMoneyType % saveNum, moneyType)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiMoneyValue % saveNum, updMoney)
|
| | | GameWorld.DebugLog(" 累计货币: moneyType=%s,updMoney=%s,saveNum=%s" % (moneyType, updMoney, saveNum), playerID)
|
| | | #GameWorld.DebugLog(" 累计货币: moneyType=%s,updMoney=%s,saveNum=%s" % (moneyType, updMoney, saveNum), playerID)
|
| | |
|
| | | # 物品
|
| | | for itemID, addCount in giveItemDict.items():
|
| | |
| | | updCount = min(curCount + addCount, ChConfig.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiItemID % saveNum, itemID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiItemCount % saveNum, updCount)
|
| | | GameWorld.DebugLog(" 累计物品: itemID=%s,updCount=%s,saveNum=%s" % (itemID, updCount, saveNum), playerID)
|
| | | #GameWorld.DebugLog(" 累计物品: itemID=%s,updCount=%s,saveNum=%s" % (itemID, updCount, saveNum), playerID)
|
| | |
|
| | | Sync_GuajiAward(curPlayer)
|
| | | return True
|
| | |
| | | lvIpyData = PlayerControl.GetPlayerLVIpyData(reLV)
|
| | | reExp = lvIpyData.GetReExp() if lvIpyData else 0
|
| | | worldLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
| | | GameWorld.DebugLog("计算挂机收益: awardSeconds=%s,useUnsecond=%s,reLV=%s,reExp=%s,worldLV=%s" |
| | | % (awardSeconds, useUnsecond, reLV, reExp, worldLV), playerID)
|
| | | #GameWorld.DebugLog("计算挂机收益: awardSeconds=%s,useUnsecond=%s,reLV=%s,reExp=%s,worldLV=%s" |
| | | # % (awardSeconds, useUnsecond, reLV, reExp, worldLV), playerID)
|
| | |
|
| | | # 经验
|
| | | expRate = GetGuajiExpRate(curPlayer)
|
| | | secondBaseExp = int(eval(FormulaControl.GetCompileFormula("GuajiExp", IpyGameDataPY.GetFuncCfg("GuajiAward", 1))))
|
| | | secondExp = int(secondBaseExp * expRate / float(ChConfig.Def_MaxRateValue))
|
| | | addExp = awardSeconds * secondExp
|
| | | GameWorld.DebugLog(" 每秒经验: %s, addExp=%s,secondBaseExp=%s,expRate=%s" % (secondExp, addExp, secondBaseExp, expRate), playerID)
|
| | | #GameWorld.DebugLog(" 每秒经验: %s, addExp=%s,secondBaseExp=%s,expRate=%s" % (secondExp, addExp, secondBaseExp, expRate), playerID)
|
| | |
|
| | | # 每秒产出货币
|
| | | moneyDict = {}
|
| | |
| | | secondMoney = int(eval(FormulaControl.GetCompileFormula("GuajiMoney_%s" % moneyType, formula)))
|
| | | moneyValue = awardSeconds * secondMoney
|
| | | moneyDict[moneyType] = moneyValue
|
| | | GameWorld.DebugLog(" 每秒货币: moneyType=%s,secondMoney=%s,moneyValue=%s" % (moneyType, secondMoney, moneyValue), playerID)
|
| | | #GameWorld.DebugLog(" 每秒货币: moneyType=%s,secondMoney=%s,moneyValue=%s" % (moneyType, secondMoney, moneyValue), playerID)
|
| | |
|
| | | # 每x秒产出1货币
|
| | | perMoneyTimeFromulaDict = IpyGameDataPY.GetFuncEvalCfg("GuajiAward", 3, {}) # 每x秒获得1个货币公式 {货币类型:"x秒公式", ...}
|
| | |
| | | oneMoneyNeedSeconds = int(eval(FormulaControl.GetCompileFormula("GuajiMoney_%s" % moneyType, formula)))
|
| | | moneyValue = moneyAwardSeconds / oneMoneyNeedSeconds
|
| | | moneyDict[moneyType] = moneyValue
|
| | | GameWorld.DebugLog(" 每X秒货币: moneyType=%s,oneMoneyNeedSeconds=%s,moneyValue=%s,moneyAwardSeconds=%s" |
| | | % (moneyType, oneMoneyNeedSeconds, moneyValue, moneyAwardSeconds), playerID)
|
| | | #GameWorld.DebugLog(" 每X秒货币: moneyType=%s,oneMoneyNeedSeconds=%s,moneyValue=%s,moneyAwardSeconds=%s" |
| | | # % (moneyType, oneMoneyNeedSeconds, moneyValue, moneyAwardSeconds), playerID)
|
| | |
|
| | | if useUnsecond:
|
| | | unSeconds = moneyAwardSeconds % oneMoneyNeedSeconds
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiMoneyUnSeconds % moneyType, unSeconds)
|
| | | GameWorld.DebugLog(" moneyType=%s,unSeconds=%s" % (moneyType, unSeconds), playerID)
|
| | | #GameWorld.DebugLog(" moneyType=%s,unSeconds=%s" % (moneyType, unSeconds), playerID)
|
| | |
|
| | | # 物品
|
| | | giveItemSecondsSet = IpyGameDataPY.GetFuncCfg("GuajiAward", 4) # 每x秒获得一次随机物品机会
|
| | |
| | | itemAwardSeconds += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GuajiItemUnSeconds)
|
| | |
|
| | | itemAwardTimes = itemAwardSeconds / giveItemSecondsSet # 给物品次数
|
| | | GameWorld.DebugLog(" 给物品次数: %s, itemAwardSeconds=%s,giveItemSecondsSet=%s" % (itemAwardTimes, itemAwardSeconds, giveItemSecondsSet), playerID)
|
| | | #GameWorld.DebugLog(" 给物品次数: %s, itemAwardSeconds=%s,giveItemSecondsSet=%s" % (itemAwardTimes, itemAwardSeconds, giveItemSecondsSet), playerID)
|
| | |
|
| | | if useUnsecond:
|
| | | unSeconds = itemAwardSeconds % giveItemSecondsSet
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiItemUnSeconds, unSeconds)
|
| | | GameWorld.DebugLog(" 给物品未处理秒数=%s" % unSeconds, playerID)
|
| | | #GameWorld.DebugLog(" 给物品未处理秒数=%s" % unSeconds, playerID)
|
| | |
|
| | | lvList = lvItemRateDict.keys()
|
| | | lvList.sort()
|
| | |
| | | dropCountTotal = 0
|
| | | itemDict = {}
|
| | | maxRate = itemRateList[-1][0]
|
| | | GameWorld.DebugLog(" itemRateList=%s,maxRate=%s" % (itemRateList, maxRate), playerID)
|
| | | #GameWorld.DebugLog(" itemRateList=%s,maxRate=%s" % (itemRateList, maxRate), playerID)
|
| | | if itemAwardTimes > 100: # 超过x次的,先进行批量处理
|
| | | preRate = 0
|
| | | for rateInfo in itemRateList:
|
| | |
| | | if GameWorld.CanHappen(rateEx, maxRate):
|
| | | dropCount += 1
|
| | | dropCountTotal += dropCount # 产出是是空物品也要算执行掉落次数
|
| | | GameWorld.DebugLog(" 挂机物品: itemInfo=%s,curRate=%s,totalRate=%s,rateEx=%s,dropCount=%s,dropCountTotal=%s" |
| | | % (itemInfo, curRate, totalRate, rateEx, dropCount, dropCountTotal), playerID)
|
| | | #GameWorld.DebugLog(" 挂机物品: itemInfo=%s,curRate=%s,totalRate=%s,rateEx=%s,dropCount=%s,dropCountTotal=%s" |
| | | # % (itemInfo, curRate, totalRate, rateEx, dropCount, dropCountTotal), playerID)
|
| | | if not dropCount:
|
| | | continue
|
| | |
|
| | |
| | | itemDict[itemID] = itemDict.get(itemID, 0) + itemCount * dropCount
|
| | |
|
| | | awardTimesEx = itemAwardTimes - dropCountTotal
|
| | | GameWorld.DebugLog(" awardTimesEx=%s" % awardTimesEx, playerID)
|
| | | #GameWorld.DebugLog(" awardTimesEx=%s" % awardTimesEx, playerID)
|
| | | if awardTimesEx > 0:
|
| | | for _ in range(awardTimesEx):
|
| | | itemInfo = GameWorld.GetResultByRandomList(itemRateList)
|
| | |
| | | for itemID, dropCount in giveGarbageItemList.items():
|
| | | itemDict[itemID] = itemDict.get(itemID, 0) + dropCount
|
| | |
|
| | | GameWorld.DebugLog(" itemDict=%s" % (itemDict), playerID)
|
| | | #GameWorld.DebugLog(" itemDict=%s" % (itemDict), playerID)
|
| | | return addExp, moneyDict, itemDict
|
| | |
|
| | | def GetGuajiExpRate(curPlayer):
|