| | |
| | | if awardSeconds <= 0:
|
| | | return
|
| | |
|
| | | addExp, giveMoneyDict, giveItemDict = CalcGuajiAward(curPlayer, awardSeconds, False)
|
| | | addExp, giveMoneyDict, giveItemDict = CalcGuajiAward(curPlayer, awardSeconds, True)
|
| | |
|
| | | updAwardSeconds = curAwardSeconds + awardSeconds
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiAwardSeconds, updAwardSeconds)
|
| | |
| | | curRealmLV = curPlayer.GetOfficialRank()
|
| | | realmAddHours = 0
|
| | | realmAddHoursDict = IpyGameDataPY.GetFuncEvalCfg("GuajiTime", 3, {})
|
| | | realmLVList = realmAddHoursDict.keys()
|
| | | realmLVList = [int(k) for k in realmAddHoursDict.keys()]
|
| | | realmLVList.sort()
|
| | | for realmLV in realmLVList:
|
| | | if curRealmLV >= realmLV:
|
| | | realmAddHours = realmAddHoursDict[realmLV]
|
| | | realmAddHours = realmAddHoursDict[str(realmLV)]
|
| | | else:
|
| | | break
|
| | |
|
| | |
| | |
|
| | | return awardSeconds, exp, moneyDict, itemDict
|
| | |
|
| | | def CalcGuajiAward(curPlayer, awardSeconds, isQuick):
|
| | | def CalcGuajiAward(curPlayer, awardSeconds, useUnsecond):
|
| | | ## 计算挂机收益,只计算收益,不做结算,结算逻辑由外层决定
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
| | | lvIpyData = PlayerControl.GetPlayerLVIpyData(reLV)
|
| | | reExp = lvIpyData.GetReExp() if lvIpyData else 0
|
| | | worldLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
| | | GameWorld.DebugLog("计算挂机收益: awardSeconds=%s,isQuick=%s,reLV=%s,reExp=%s,worldLV=%s" |
| | | % (awardSeconds, isQuick, 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)
|
| | |
| | | perMoneyTimeFromulaDict = IpyGameDataPY.GetFuncEvalCfg("GuajiAward", 3, {}) # 每x秒获得1个货币公式 {货币类型:"x秒公式", ...}
|
| | | for moneyType, formula in perMoneyTimeFromulaDict.items():
|
| | | moneyAwardSeconds = awardSeconds
|
| | | if not isQuick:
|
| | | if useUnsecond:
|
| | | moneyAwardSeconds += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GuajiMoneyUnSeconds % moneyType)
|
| | | oneMoneyNeedSeconds = int(eval(FormulaControl.GetCompileFormula("GuajiMoney_%s" % moneyType, formula)))
|
| | | moneyValue = moneyAwardSeconds / oneMoneyNeedSeconds
|
| | |
| | | GameWorld.DebugLog(" 每X秒货币: moneyType=%s,oneMoneyNeedSeconds=%s,moneyValue=%s,moneyAwardSeconds=%s"
|
| | | % (moneyType, oneMoneyNeedSeconds, moneyValue, moneyAwardSeconds), playerID)
|
| | |
|
| | | if not isQuick:
|
| | | if useUnsecond:
|
| | | unSeconds = moneyAwardSeconds % oneMoneyNeedSeconds
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiMoneyUnSeconds % moneyType, unSeconds)
|
| | | GameWorld.DebugLog(" moneyType=%s,unSeconds=%s" % (moneyType, unSeconds), playerID)
|
| | |
| | | giveItemSecondsSet = IpyGameDataPY.GetFuncCfg("GuajiAward", 4) # 每x秒获得一次随机物品机会
|
| | | lvItemRateDict = IpyGameDataPY.GetFuncEvalCfg("GuajiAward", 5, {})
|
| | | itemAwardSeconds = awardSeconds
|
| | | if not isQuick:
|
| | | if useUnsecond:
|
| | | itemAwardSeconds += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GuajiItemUnSeconds)
|
| | |
|
| | | itemAwardTimes = itemAwardSeconds / giveItemSecondsSet # 给物品次数
|
| | | GameWorld.DebugLog(" 给物品次数: %s, itemAwardSeconds=%s,giveItemSecondsSet=%s" % (itemAwardTimes, itemAwardSeconds, giveItemSecondsSet), playerID)
|
| | |
|
| | | if not isQuick:
|
| | | if useUnsecond:
|
| | | unSeconds = itemAwardSeconds % giveItemSecondsSet
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiItemUnSeconds, unSeconds)
|
| | | GameWorld.DebugLog(" 给物品未处理秒数=%s" % unSeconds, playerID)
|
| | |
| | | itemDict[itemID] = itemDict.get(itemID, 0) + itemCount
|
| | |
|
| | | # 集字掉落
|
| | | dropWordsCountDict = PlayerActCollectWords.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick)
|
| | | dropWordsCountDict = PlayerActCollectWords.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, useUnsecond)
|
| | | for itemID, dropCount in dropWordsCountDict.items():
|
| | | itemDict[itemID] = itemDict.get(itemID, 0) + dropCount
|
| | |
|
| | | # 垃圾回收
|
| | | giveGarbageItemList = PlayerActGarbageSorting.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick)
|
| | | giveGarbageItemList = PlayerActGarbageSorting.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, useUnsecond)
|
| | | for itemID, dropCount in giveGarbageItemList.items():
|
| | | itemDict[itemID] = itemDict.get(itemID, 0) + dropCount
|
| | |
|
| | |
| | | return
|
| | |
|
| | | awardSeconds = IpyGameDataPY.GetFuncCfg("GuajiQuick", 1) * 3600
|
| | | exp, moneyDict, itemDict = CalcGuajiAward(curPlayer, awardSeconds, True)
|
| | | exp, moneyDict, itemDict = CalcGuajiAward(curPlayer, awardSeconds, False)
|
| | |
|
| | | quickCountToday += 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiQuickCount, quickCountToday)
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GuajiItemCount % num, 0)
|
| | | Sync_GuajiAward(curPlayer)
|
| | |
|
| | | GameWorld.DebugLog(" 挂机收益: awardSeconds=%s,exp=%s,moneyDict=%s,itemDict=%s" % (awardSeconds, exp, moneyDict, itemDict), playerID)
|
| | | __DoGiveGuajiAward(curPlayer, awardSeconds, exp, moneyDict, itemDict)
|
| | | return
|
| | |
|
| | | def GiveGuajiAward(curPlayer, awardSeconds):
|
| | | ## 直接给挂机收益
|
| | | GameWorld.DebugLog("直接给挂机收益: awardSeconds=%s" % awardSeconds, curPlayer.GetPlayerID())
|
| | | exp, moneyDict, itemDict = CalcGuajiAward(curPlayer, awardSeconds, False)
|
| | | __DoGiveGuajiAward(curPlayer, awardSeconds, exp, moneyDict, itemDict)
|
| | | return
|
| | |
|
| | | def __DoGiveGuajiAward(curPlayer, awardSeconds, exp, moneyDict, itemDict):
|
| | | ## 实际给挂机收益,仅做发放收益
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("给挂机收益: awardSeconds=%s,exp=%s,moneyDict=%s,itemDict=%s" % (awardSeconds, exp, moneyDict, itemDict), playerID)
|
| | |
|
| | | playerControl = PlayerControl.PlayerControl(curPlayer)
|
| | | playerControl.AddExp(exp, ShareDefine.Def_ViewExpType_Guaji)
|