| | |
| | | #
|
| | | # @todo:投资
|
| | | # @author hxp
|
| | | # @date 2020-09-10
|
| | | # @date 2025-11-10
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 投资
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2020-09-10 11:00"""
|
| | | #"""Version = 2025-11-10 20:30"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import GameWorld
|
| | | import IpyGameDataPY
|
| | | import NetPackCommon
|
| | | import DataRecordPack
|
| | | import ChPyNetSendPack
|
| | | import ItemControler
|
| | | import PlayerControl
|
| | | import IPY_GameWorld
|
| | | import PlayerMail
|
| | | import ChConfig
|
| | |
|
| | | import time
|
| | |
|
| | | ## 登录
|
| | | def OnLogin(curPlayer):
|
| | | for investType in ChConfig.InvestTypeList:
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType):
|
| | | # 有投资过就同步
|
| | | continue
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | return
|
| | |
|
| | | ## 过天
|
| | | def OnDay(curPlayer):
|
| | | dayAwardDict = IpyGameDataPY.GetFuncEvalCfg("InvestDay", 3, {})
|
| | | for investType in ChConfig.InvestTypeList:
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType):
|
| | | continue
|
| | |
|
| | | # 登录卡
|
| | | if investType == ChConfig.InvestType_Login:
|
| | | progressValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, 0))
|
| | | maxDays = __GetInvestMaxDays(investType)
|
| | | if maxDays and progressValue < maxDays:
|
| | | progressValue += 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, 0), progressValue)
|
| | | GameWorld.DebugLog("更新登录投资可领奖天数进度: %s" % progressValue)
|
| | | |
| | | # 终身卡
|
| | | elif investType == ChConfig.InvestType_Life:
|
| | | __GiveUnGetPerDayReward(curPlayer, investType)
|
| | | for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (investType, keyNum), 0)
|
| | | |
| | | # 每日相同奖励的
|
| | | if str(investType) in dayAwardDict: |
| | | __GiveUnGetPerDayReward(curPlayer, investType, dayAwardDict[str(investType)])
|
| | | |
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | |
| | | return
|
| | |
|
| | | def __GiveUnGetPerDayReward(curPlayer, investType):
|
| | | def __GiveUnGetPerDayReward(curPlayer, investType, dayAwardItemList):
|
| | | ## 补发未领取的每日奖励,一般用于 每日可领取的固定奖励,如永久卡等
|
| | | |
| | | if not dayAwardItemList:
|
| | | return
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | curTime = int(time.time())
|
| | | lastRewardTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestRewardTime % investType)
|
| | | if not lastRewardTime:
|
| | | passDays = __GetInvestPassDays(curPlayer, investType)
|
| | | #GameWorld.DebugLog("补发奖励时,距离开通投资已过天数: %s" % passDays, playerID)
|
| | | else:
|
| | | passDays = GameWorld.GetDiff_Day(curTime, lastRewardTime)
|
| | | #GameWorld.DebugLog("补发奖励时,距离上次领奖已过天数: %s" % passDays, playerID)
|
| | | investTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType)
|
| | | if not investTime:
|
| | | return
|
| | | lastRewardTime = investTime - 3600 * 24 # 让激活当天也可以领
|
| | | #GameWorld.DebugLog("从未领奖过")
|
| | |
|
| | | rewardDays = passDays - 1 # # 需要补发的奖励天数,只补到昨天,不算当天
|
| | | curTime = int(time.time())
|
| | | passDays = GameWorld.GetDiff_Day(curTime, lastRewardTime)
|
| | | #GameWorld.DebugLog("补发奖励时,距离上次领奖已过天数: %s" % passDays, playerID)
|
| | | if not GetInvestState(curPlayer, investType):
|
| | | rewardDays = passDays
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestEndTime % investType)
|
| | | if not endTime:
|
| | | return
|
| | | rewardDayMax = GameWorld.GetDiff_Day(endTime, lastRewardTime)
|
| | | if rewardDayMax <= 0:
|
| | | return
|
| | | GameWorld.DebugLog("已过期: 最大还可奖励天数: %s" % rewardDayMax, playerID)
|
| | | if rewardDays > rewardDayMax:
|
| | | rewardDays = rewardDayMax
|
| | | GameWorld.DebugLog("修正最大还可补发的奖励天数: %s" % rewardDays, playerID)
|
| | | else:
|
| | | rewardDays = passDays - 1 # # 需要补发的奖励天数,只补到昨天,不算当天
|
| | | GameWorld.DebugLog("未过期: rewardDays=%s" % rewardDays, playerID)
|
| | | |
| | | if rewardDays <= 0:
|
| | | GameWorld.DebugLog("不用补发投资卡每日奖励: investType=%s,rewardDays=%s" % (investType, rewardDays), playerID)
|
| | | return
|
| | | updRewardTime = curTime - 3600 * 24 # 最后一次领奖强制设置到昨天
|
| | |
|
| | | rewardIndex = 0 # 每日奖励默认0索引
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Invest", investType * 100 + rewardIndex)
|
| | | if not ipyData:
|
| | | return
|
| | | rewardInfo = ipyData.GetReward()
|
| | | |
| | | rewardKey = "1" # 默认1
|
| | | rewardItemList = rewardInfo.get(str(rewardKey), [])
|
| | | if not rewardItemList:
|
| | | return
|
| | | |
| | | mailItemList = []
|
| | | for itemID, itemCount, isAuctionItem in rewardItemList:
|
| | | mailItemList.append([itemID, itemCount * rewardDays, isAuctionItem])
|
| | | |
| | | for itemInfo in dayAwardItemList:
|
| | | itemID = itemInfo[0]
|
| | | itemCount = itemInfo[1]
|
| | | mailItemList.append([itemID, itemCount * rewardDays])
|
| | | |
| | | GameWorld.DebugLog("邮件补发投资卡每日奖励! investType=%s, rewardDays=%s, updRewardTime=%s, mailItemList=%s"
|
| | | % (investType, rewardDays, updRewardTime, mailItemList), playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestRewardTime % investType, updRewardTime)
|
| | | PlayerControl.SendMailByKey("InvestDayReward_%s" % investType, [playerID], mailItemList, [rewardDays])
|
| | | PlayerMail.SendMailByKey("InvestDayReward_%s" % investType, playerID, mailItemList, [rewardDays])
|
| | | return
|
| | |
|
| | | def __GetInvestPassDays(curPlayer, investType):
|
| | |
| | | curTime = int(time.time())
|
| | | return max(0, GameWorld.GetDiff_Day(curTime, investTime) + 1)
|
| | |
|
| | | def __GetInvestMaxDays(investType):
|
| | | ## 获取投资最大天数,0为永久
|
| | | investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg("InvestMaxDay", 1, {})
|
| | | return investMaxDayDict.get(str(investType), 0)
|
| | |
|
| | | def GetInvestState(curPlayer, investType):
|
| | | ## 获取投资卡状态 0-未投资;1-已投资;
|
| | | ## 获取投资卡状态 0-未投资;1-投资生效中;
|
| | | investTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType)
|
| | | if not investTime:
|
| | | return 0
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestEndTime % investType)
|
| | | if endTime: # 有到期时间的检查到期
|
| | | expiredDays = GameWorld.GetDiff_Day(int(time.time()), endTime)
|
| | | if expiredDays > 0: # 已过期
|
| | | return 0
|
| | | return 1
|
| | |
|
| | | #// A5 40 投资理财 #tagCMGoldInvest
|
| | |
| | | # DWORD InvestGold; // 投资额度
|
| | | #};
|
| | | def OnGoldInvest(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | investType = clientData.InvestType
|
| | | InvestByRealCTG(curPlayer, investType)
|
| | | #curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | #investType = clientData.InvestType
|
| | | return
|
| | |
|
| | | def InvestByRealCTG(curPlayer, investType):
|
| | | ## 真实充值激活投资
|
| | | needRealCTGCoinDict = IpyGameDataPY.GetFuncEvalCfg("InvestCost", 4, {})
|
| | | if str(investType) not in needRealCTGCoinDict:
|
| | | return
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | realNeed = needRealCTGCoinDict[str(investType)]
|
| | | realTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGRealTotal)
|
| | | if realTotal < realNeed:
|
| | | GameWorld.DebugLog("真实充值额度不足,无法激活! investType=%s,realTotal=%s < %s" |
| | | % (investType, realTotal, realNeed), playerID)
|
| | | return
|
| | | __DoLogicInvest(curPlayer, investType)
|
| | | return True
|
| | |
|
| | | ## 充值直购投资
|
| | | def InvestByCTG(curPlayer, ctgID):
|
| | | ctgInvestDict = IpyGameDataPY.GetFuncEvalCfg("InvestCost", 3, {})
|
| | | ## 充值直购投资
|
| | | ctgInvestDict = IpyGameDataPY.GetFuncEvalCfg("InvestCost", 1, {})
|
| | | for investType, ctgIDList in ctgInvestDict.items():
|
| | | if ctgID in ctgIDList:
|
| | | __DoLogicInvest(curPlayer, int(investType))
|
| | | DoLogicInvest(curPlayer, int(investType))
|
| | | break
|
| | | return
|
| | |
|
| | | ## 执行投资逻辑
|
| | | def __DoLogicInvest(curPlayer, investType):
|
| | | if GetInvestState(curPlayer, investType) == 1:
|
| | | GameWorld.DebugLog("已投资,无法重复投资! investType=%s" % investType)
|
| | | return
|
| | | def DoLogicInvest(curPlayer, investType):
|
| | | ## 执行投资逻辑
|
| | | buyDaysDict = IpyGameDataPY.GetFuncEvalCfg("InvestDay", 1, {}) # 购买天数 |
| | | buyDays = buyDaysDict.get(str(investType), 0)
|
| | | curState = GetInvestState(curPlayer, investType)
|
| | | GameWorld.DebugLog("购买投资: investType=%s,buyDays=%s,curState=%s" % (investType, buyDays, curState))
|
| | |
|
| | | # 可投资,更新重置投资相关数据
|
| | | curTime = int(time.time())
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % investType, curTime)
|
| | | for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (investType, keyNum), 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, keyNum), 0)
|
| | | |
| | | # 登录卡,投资当天可领奖,完成设置为1
|
| | | if investType == ChConfig.InvestType_Login:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, 0), 1)
|
| | | # 已过期的重置投资相关数据
|
| | | if not curState:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % investType, curTime)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestEndTime % investType, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestRewardTime % investType, 0)
|
| | |
|
| | | # 额外奖励物品
|
| | | awardItemDict = IpyGameDataPY.GetFuncEvalCfg("InvestCost", 5, {})
|
| | | if str(investType) in awardItemDict:
|
| | | awardItemListEx = awardItemDict[str(investType)]
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, awardItemListEx, event=["Invest", True, {"investType":investType}])
|
| | | # 支持重复购买,累加到期时间
|
| | | # 永久
|
| | | if buyDays <= 0:
|
| | | updEndTime = 0
|
| | |
|
| | | # 广播
|
| | | PlayerControl.WorldNotify(0, "BuyInvest_%s" % investType, [curPlayer.GetName(), __GetTotalGetGold(investType)])
|
| | | |
| | | # 有天数限制
|
| | | elif buyDays > 0:
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestEndTime % investType)
|
| | | if endTime > curTime:
|
| | | updEndTime = endTime + buyDays * 24 * 3600
|
| | | GameWorld.Log(" 累加时长: investType=%s,endTime=%s,updEndTime=%s" |
| | | % (investType, GameWorld.ChangeTimeNumToStr(endTime), GameWorld.ChangeTimeNumToStr(updEndTime)))
|
| | | else:
|
| | | updEndTime = GameWorld.GetEndTimeByZeroTime(curTime, buyDays)
|
| | | GameWorld.Log(" 重新激活: investType=%s,updEndTime=%s" % (investType, GameWorld.ChangeTimeNumToStr(updEndTime)))
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestEndTime % investType, updEndTime)
|
| | | GameWorld.DebugLog("投资理财成功: investType=%s" % (investType))
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | PlayerControl.Sync_ExpRateChange(curPlayer)
|
| | | return
|
| | |
|
| | | def __GetTotalGetGold(investType):
|
| | | ## 获取投资预计总收益仙玉、灵石
|
| | | totalGold = 0
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in xrange(ipyDataMgr.GetInvestCount()):
|
| | | ipyData = ipyDataMgr.GetInvestByIndex(index)
|
| | | if ipyData.GetType() != investType:
|
| | | continue
|
| | | rewardDict = ipyData.GetReward()
|
| | | for rewardInfo in rewardDict.values():
|
| | | for itemID, itemCount, _ in rewardInfo:
|
| | | if itemID in [20, 30]: # 单位1的仙玉、灵石
|
| | | totalGold += itemCount
|
| | | return totalGold
|
| | |
|
| | | def GetAddBossCnt(curPlayer, bossFuncIndex):
|
| | | ## 获取增加的boss次数上限
|
| | | addBossCnt = 0
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | lifeCardAddBossCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 1, {})
|
| | | lifeCardAddCnt = lifeCardAddBossCntDict.get(str(bossFuncIndex), 0)
|
| | | addBossCnt += lifeCardAddCnt
|
| | | return addBossCnt
|
| | |
|
| | | def GetAddFBCnt(curPlayer, mapID):
|
| | | ## 获取增加的副本次数上限
|
| | | ## 获取增加的副本免费次数上限
|
| | | addFBCnt = 0
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | lifeCardAddFBCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 2, {})
|
| | | lifeCardAddCnt = lifeCardAddFBCntDict.get(str(mapID), 0)
|
| | | addFBCnt += lifeCardAddCnt
|
| | | return addFBCnt
|
| | |
|
| | | def GetAddBossBuyCnt(curPlayer, bossFuncIndex):
|
| | | ## 获取增加的boss购买次数上限
|
| | | addBossBuyCnt = 0
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | lifeCardAddBossCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 4, {})
|
| | | lifeCardAddCnt = lifeCardAddBossCntDict.get(str(bossFuncIndex), 0)
|
| | | addBossBuyCnt += lifeCardAddCnt
|
| | | return addBossBuyCnt
|
| | |
|
| | | def GetAddFBBuyCnt(curPlayer, mapID):
|
| | | ## 获取增加的副本购买次数上限
|
| | | addFBBuyCnt = 0
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | lifeCardAddFBCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 5, {})
|
| | | lifeCardAddCnt = lifeCardAddFBCntDict.get(str(mapID), 0)
|
| | | addFBBuyCnt += lifeCardAddCnt
|
| | | addFBBuyCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 1, {})
|
| | | for investType, fbMapIDAddDict in addFBBuyCntDict.items():
|
| | | addCnt = fbMapIDAddDict.get(str(mapID), 0)
|
| | | if not addCnt:
|
| | | continue
|
| | | if not GetInvestState(curPlayer, int(investType)):
|
| | | continue
|
| | | addFBBuyCnt += addCnt
|
| | | return addFBBuyCnt
|
| | |
|
| | | def GetAddFightExpRate(curPlayer):
|
| | | ## 杀怪经验加成
|
| | | fightExpRate = 0
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Life):
|
| | | fightExpRate += IpyGameDataPY.GetFuncCfg("InvestPower2", 1)
|
| | | return fightExpRate
|
| | |
|
| | | def CanQuickFinishMissionFree(curPlayer):
|
| | | ## 可否免费快速完成任务
|
| | | for investType in IpyGameDataPY.GetFuncEvalCfg("InvestPower", 3):
|
| | | if GetInvestState(curPlayer, investType):
|
| | | return True
|
| | | def IsFBCntBuyFree(curPlayer, mapID):
|
| | | ## 副本付费次数购买免费
|
| | | freeSweepDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 2, {})
|
| | | for investType, fbMapIDList in freeSweepDict.items():
|
| | | if mapID not in fbMapIDList:
|
| | | continue
|
| | | if not GetInvestState(curPlayer, int(investType)):
|
| | | continue
|
| | | return True
|
| | | return False
|
| | |
|
| | | def OnKillBoss(curPlayer, npcID):
|
| | | ## 参与击杀boss
|
| | | if GetInvestState(curPlayer, ChConfig.InvestType_Boss) != 1:
|
| | | #GameWorld.DebugLog("boss投资未投资!")
|
| | | return
|
| | | key = "BossInvestNPCIDDict"
|
| | | BossInvestNPCIDDict = IpyGameDataPY.GetConfigEx(key)
|
| | | if not BossInvestNPCIDDict:
|
| | | BossInvestNPCIDDict = {}
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in xrange(ipyDataMgr.GetInvestCount()):
|
| | | ipyData = ipyDataMgr.GetInvestByIndex(index)
|
| | | if ipyData.GetType() != ChConfig.InvestType_Boss:
|
| | | continue
|
| | | if not ipyData.GetNeedNPCID():
|
| | | continue
|
| | | BossInvestNPCIDDict[ipyData.GetNeedNPCID()] = ipyData.GetID()
|
| | | IpyGameDataPY.SetConfigEx(key, BossInvestNPCIDDict)
|
| | | GameWorld.Log("缓存boss投资对应关系: %s" % BossInvestNPCIDDict)
|
| | | |
| | | if npcID not in BossInvestNPCIDDict:
|
| | | #GameWorld.DebugLog(" 该boss没有投资奖励!")
|
| | | return
|
| | | investID = BossInvestNPCIDDict[npcID]
|
| | | investType, rewardIndex = investID / 100, investID % 100
|
| | | if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, True, [investType]):
|
| | | #GameWorld.DebugLog("已设置击杀过该投资boss: npcID=%s,rewardIndex=%s,progressValue=%s" % (npcID, rewardIndex, progressValue))
|
| | | return
|
| | | progressValue, updProgressValue = GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, 1, True, [investType])
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | GameWorld.DebugLog("设置杀过投资boss: npcID=%s,rewardIndex=%s,progressValue=%s,updProgressValue=%s" |
| | | % (npcID, rewardIndex, progressValue, updProgressValue))
|
| | | return
|
| | | def GetArenaTicketMax(curPlayer):
|
| | | ## 演武场门票上限
|
| | | addMax = 0
|
| | | arenaCntDict = IpyGameDataPY.GetFuncEvalCfg("InvestPower", 3, {})
|
| | | for investType, addCnt in arenaCntDict.items():
|
| | | if not GetInvestState(curPlayer, int(investType)):
|
| | | continue
|
| | | addMax += addCnt
|
| | | return addMax
|
| | |
|
| | | #// A5 41 领取投资理财回报 #tagCMGetInvestReward
|
| | | #
|
| | |
| | | GameWorld.DebugLog(" 未投资或已过期,无法领奖!")
|
| | | return
|
| | |
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Invest", investType * 100 + rewardIndex)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | needLV = ipyData.GetNeedLV()
|
| | | if needLV and curPlayer.GetLV() < needLV:
|
| | | GameWorld.DebugLog(" 等级不足,无法领奖! needLV=%s" % needLV)
|
| | | return
|
| | | |
| | | if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, rewardIndex, True, [investType]):
|
| | | GameWorld.DebugLog(" 已领取过该索引奖励! rewardIndex=%s" % rewardIndex)
|
| | | return
|
| | | |
| | | needDay = ipyData.GetNeedDay()
|
| | | rewardInfo = ipyData.GetReward()
|
| | | |
| | | indexProgressState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, True, [investType])
|
| | | |
| | | # 月卡
|
| | | if investType in [ChConfig.InvestType_NewMonth, ChConfig.InvestType_Month1]:
|
| | | passDays = __GetInvestPassDays(curPlayer, investType) # 按投资时间计算天
|
| | | if needDay > passDays:
|
| | | GameWorld.DebugLog(" 投资天数不足,无法领取! needDay=%s > passDays=%s" % (ipyData.GetNeedDay(), passDays))
|
| | | return
|
| | | |
| | | # 登录
|
| | | elif investType == ChConfig.InvestType_Login:
|
| | | loginDays = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, 0)) # 按登录天计算天,有登录才算
|
| | | if needDay > loginDays:
|
| | | GameWorld.DebugLog(" 登录投资天数不足,无法领取! needDay=%s > loginDays=%s" % (needDay, loginDays))
|
| | | return
|
| | | |
| | | # 等级
|
| | | elif investType == ChConfig.InvestType_LV:
|
| | | # 公共等级条件已判断
|
| | | pass
|
| | | |
| | | # Boss
|
| | | elif investType == ChConfig.InvestType_Boss:
|
| | | if not indexProgressState:
|
| | | GameWorld.DebugLog(" Boss投资无参与击杀该boss,无法领取! rewardIndex=%s" % (rewardIndex))
|
| | | return
|
| | | |
| | | # 终身卡
|
| | | elif investType == ChConfig.InvestType_Life:
|
| | | pass
|
| | | |
| | | else:
|
| | | return
|
| | | |
| | | if not ipyData:
|
| | | return
|
| | | |
| | | rewardKey = "1" # 默认1
|
| | | rewardItemList = rewardInfo.get(str(rewardKey), [])
|
| | | curTime = int(time.time())
|
| | | rewardItemList = []
|
| | | # 按每天固定奖励的
|
| | | if rewardIndex == 0:
|
| | | lastRewardTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestRewardTime % investType)
|
| | | if lastRewardTime:
|
| | | if GameWorld.GetDiff_Day(curTime, lastRewardTime) == 0:
|
| | | GameWorld.DebugLog(" 已领取过该索引奖励! rewardIndex=%s" % rewardIndex)
|
| | | return
|
| | | |
| | | dayAwardDict = IpyGameDataPY.GetFuncEvalCfg("InvestDay", 3, {})
|
| | | if str(investType) in dayAwardDict:
|
| | | rewardItemList = dayAwardDict[str(investType)]
|
| | | |
| | | if not rewardItemList:
|
| | | return
|
| | |
|
| | | if not ItemControler.CheckPackSpaceEnough(curPlayer, rewardItemList):
|
| | | return
|
| | | |
| | | rewardValue, updRewardValue = GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, rewardIndex, 1, True, [investType])
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | GameWorld.DebugLog(" rewardValue=%s,updRewardValue=%s,rewardItemList=%s" % (rewardValue, updRewardValue, rewardItemList))
|
| | | |
| | | # 记录最后一次领奖时间
|
| | | if investType == ChConfig.InvestType_Life:
|
| | | if rewardIndex == 0:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestRewardTime % (investType), int(time.time()))
|
| | | |
| | | for itemID, itemCount, isAuctionItem in rewardItemList:
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem],
|
| | | event=["Invest", False, {}])
|
| | | ItemControler.NotifyGiveAwardInfo(curPlayer, rewardItemList, "Invest")
|
| | | |
| | | # 记录领取事件
|
| | | DataRecordPack.DR_GetGoldInvestReward(curPlayer, investType, rewardIndex, rewardItemList)
|
| | | |
| | | # 领完了,重置可重复购买的非永久卡
|
| | | maxDays = __GetInvestMaxDays(investType)
|
| | | canRepetBuyTypeList = IpyGameDataPY.GetFuncEvalCfg("InvestMaxDay", 2)
|
| | | if maxDays > 1 and investType in canRepetBuyTypeList:
|
| | | isAllDayGet = True
|
| | | for i in range(maxDays, -1, -1):
|
| | | if not IpyGameDataPY.GetIpyGameDataNotLog("Invest", investType * 100 + i):
|
| | | continue
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, i, True, [investType]):
|
| | | isAllDayGet = False
|
| | | #GameWorld.DebugLog(" 还有未领取: i=%s,isAllDayGet=%s" % (i, isAllDayGet))
|
| | | break
|
| | | |
| | | if isAllDayGet:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % investType, 0)
|
| | | for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (investType, keyNum), 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, keyNum), 0)
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | GameWorld.DebugLog(" 领完奖励了,重置投资! investType=%s" % investType)
|
| | | |
| | | GameWorld.DebugLog("更新领奖:investType=%s,rewardItemList=%s" % (investType, rewardItemList))
|
| | | Sync_InvestInfo(curPlayer, investType)
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, rewardItemList, event=["Invest", False, {}])
|
| | | return
|
| | |
|
| | | ## 同步投资理财信息
|
| | | def __todayAwardState(curPlayer, investType):
|
| | | lastRewardTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestRewardTime % investType)
|
| | | if lastRewardTime:
|
| | | if GameWorld.GetDiff_Day(int(time.time()), lastRewardTime) == 0:
|
| | | return 1
|
| | | return 0
|
| | |
|
| | | def Sync_InvestInfo(curPlayer, investType):
|
| | | investInfoPack = ChPyNetSendPack.tagMCInvestInfo()
|
| | | investInfoPack.InvestType = investType
|
| | | investInfoPack.CurDay = __GetInvestPassDays(curPlayer, investType)
|
| | | for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
|
| | | investInfoPack.RewardValue.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestReward % (investType, keyNum)))
|
| | | investInfoPack.ProgressValue.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, keyNum)))
|
| | | investInfoPack.ValueCount = len(investInfoPack.RewardValue)
|
| | | NetPackCommon.SendFakePack(curPlayer, investInfoPack)
|
| | | clientPack = ChPyNetSendPack.tagSCInvestInfo()
|
| | | clientPack.InvestType = investType
|
| | | clientPack.InvestBuyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType)
|
| | | clientPack.InvestEndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestEndTime % investType)
|
| | | clientPack.AwardState = __todayAwardState(curPlayer, investType)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
|