| | |
| | | Sync_FirstGoldInfo(curPlayer)
|
| | | return
|
| | |
|
| | | ################################ 每日打包直购礼包 ###################################
|
| | |
|
| | | def OnActiviteDailyPackBuyGift(curPlayer, ctgID):
|
| | | ## 激活每日打包直购礼包
|
| | | |
| | | isActivite = False
|
| | | packCTGIDList = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 3) # 打包购买对应充值ID列表
|
| | | if ctgID in packCTGIDList:
|
| | | isActivite = True
|
| | | # 如果是打包购买的,不管什么状态,直接全部重置
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftPackTime, int(time.time()))
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftBuy, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftRecord, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftOnDayTime, 0)
|
| | | GameWorld.Log("激活打包直购礼包: ctgID=%s" % ctgID, curPlayer.GetID())
|
| | | |
| | | else:
|
| | | actCTGIDDict = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 2, {}) # 礼包索引对应充值ID列表,没有配置的代表可免费领取
|
| | | for awardIndexStr, ctgIDList in actCTGIDDict.items():
|
| | | if ctgID not in ctgIDList:
|
| | | continue
|
| | | isActivite = True
|
| | | awardIndex = int(awardIndexStr)
|
| | | buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftBuy)
|
| | | updBuyState = buyState|pow(2, awardIndex)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftBuy, updBuyState)
|
| | | GameWorld.Log("单独激活打包直购礼包: awardIndex=%s,ctgID=%s" % (awardIndex, ctgID), curPlayer.GetID())
|
| | | break
|
| | | |
| | | if isActivite:
|
| | | Sync_DailyPackBuyGiftInfo(curPlayer)
|
| | | |
| | | return isActivite
|
| | |
|
| | | def GetDailyPackBuyGift(curPlayer, awardIndex):
|
| | | ## 领取每日打包直购礼包
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | |
| | | giftItemDict = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 1, {}) # 礼包索引对应礼包物品列表
|
| | | if str(awardIndex) not in giftItemDict:
|
| | | GameWorld.DebugLog("不存在该每日打包直购礼包! awardIndex=%s" % awardIndex, playerID)
|
| | | return
|
| | | itemList = giftItemDict[str(awardIndex)]
|
| | | |
| | | getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftRecord) # 领取记录
|
| | | if getRecord&pow(2, int(awardIndex)):
|
| | | GameWorld.DebugLog("已经领取过该每日打包直购礼包! awardIndex=%s,getRecord=%s" % (awardIndex, getRecord), playerID)
|
| | | return
|
| | | |
| | | packBuyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftPackTime) # 打包购买时间戳
|
| | | # 打包购买的
|
| | | if packBuyTime:
|
| | | curTime = int(time.time())
|
| | | maxDays = IpyGameDataPY.GetFuncCfg("DailyPackBuyGift", 4)
|
| | | curDays = GameWorld.GetDiff_Day(curTime, packBuyTime) + 1 # 打包购买第x天,购买当天为第1天
|
| | | if curDays > maxDays:
|
| | | GameWorld.DebugLog("打包直购礼包超过可领取最大天: curDays=%s > %s" % (curDays, maxDays), playerID)
|
| | | return
|
| | | GameWorld.DebugLog("已打包购买: packBuyTime=%s(%s),curDays=%s" % (packBuyTime, GameWorld.ChangeTimeNumToStr(packBuyTime), curDays), playerID)
|
| | | else:
|
| | | actCTGIDDict = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 2, {}) # 礼包索引对应充值ID列表,没有配置的代表可免费领取
|
| | | buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftBuy) # 单独购买状态
|
| | | if str(awardIndex) in actCTGIDDict and not buyState&pow(2, awardIndex):
|
| | | GameWorld.DebugLog("今日该打包直购礼包未购买,无法领取: awardIndex=%s,buyState=%s" % (awardIndex, buyState), playerID)
|
| | | return
|
| | | GameWorld.DebugLog("已单独购买: awardIndex=%s,buyState=%s" % (awardIndex, buyState), playerID)
|
| | | |
| | | # 检查背包
|
| | | if not ItemControler.CheckPackSpaceEnough(curPlayer, itemList):
|
| | | return
|
| | | |
| | | # 更新已领取成功标记
|
| | | updRecord = getRecord|pow(2, awardIndex)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftRecord, updRecord)
|
| | | Sync_DailyPackBuyGiftInfo(curPlayer)
|
| | | GameWorld.DebugLog("领取打包直购礼包: awardIndex=%s,updRecord=%s" % (awardIndex, updRecord), playerID)
|
| | | |
| | | # 给物品
|
| | | for itemID, itemCount, isAuctionItem in itemList:
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
|
| | | |
| | | return
|
| | |
|
| | | def DoDailyPackBuyGiftOnDay(curPlayer):
|
| | | ## 每日打包直购礼包过天
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | curTime = int(time.time())
|
| | | # 补发未领取的天数奖励
|
| | | lastOnDayTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftOnDayTime) # 上次处理的过天时间
|
| | | packBuyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftPackTime) # 打包购买时间戳
|
| | | getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftRecord) # 领取记录
|
| | | buyState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftBuy) # 单独购买状态
|
| | | |
| | | GameWorld.DebugLog("每日打包直购礼包过天: packBuyTime=%s(%s),lastOnDayTime=%s(%s),getRecord=%s,buyState=%s" |
| | | % (packBuyTime, GameWorld.ChangeTimeNumToStr(packBuyTime), |
| | | lastOnDayTime, GameWorld.ChangeTimeNumToStr(lastOnDayTime), getRecord, buyState), playerID)
|
| | | |
| | | giftItemDict = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 1, {}) # 礼包索引对应礼包物品列表
|
| | | actCTGIDDict = IpyGameDataPY.GetFuncEvalCfg("DailyPackBuyGift", 2, {}) # 礼包索引对应充值ID列表,没有配置的代表可免费领取
|
| | | |
| | | # 打包购买的
|
| | | if packBuyTime:
|
| | | maxDays = IpyGameDataPY.GetFuncCfg("DailyPackBuyGift", 4)
|
| | | curDays = GameWorld.GetDiff_Day(curTime, packBuyTime) + 1 # 打包购买第x天,购买当天为第1天
|
| | | alreadyAwardDays = GameWorld.GetDiff_Day(lastOnDayTime, packBuyTime) if lastOnDayTime else 0 # 已经奖励过的天数
|
| | | GameWorld.DebugLog(" alreadyAwardDays=%s,curDays=%s" % (alreadyAwardDays, curDays), playerID)
|
| | | # 补发上次离线天的
|
| | | awardDays = alreadyAwardDays + 1
|
| | | for awardIndexStr, addItemList in giftItemDict.items():
|
| | | if getRecord&pow(2, int(awardIndexStr)):
|
| | | GameWorld.DebugLog(" 已经领取过该奖励了,不补发! awardIndex=%s,getRecord=%s" % (awardIndexStr, getRecord), playerID)
|
| | | continue
|
| | | GameWorld.DebugLog(" 补发离线天! awardDays=%s,awardIndex=%s" % (awardDays, awardIndexStr), playerID)
|
| | | paramList = [awardDays]
|
| | | PlayerControl.SendMailByKey("DailyPackBuyGift1", [playerID], addItemList, paramList)
|
| | | |
| | | # 补发未登录完整天的
|
| | | for day in range(awardDays + 1, curDays):
|
| | | if day > maxDays:
|
| | | break
|
| | | paramList = [day]
|
| | | GameWorld.DebugLog(" 补发完整天! day=%s" % (day), playerID)
|
| | | for addItemList in giftItemDict.values():
|
| | | PlayerControl.SendMailByKey("DailyPackBuyGift1", [playerID], addItemList, paramList)
|
| | | |
| | | # 超过最大天了,重置所有
|
| | | if curDays > maxDays:
|
| | | GameWorld.DebugLog(" 超过最大天了,重置所有! curDays=%s" % (curDays), playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftPackTime, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftOnDayTime, 0)
|
| | | else:
|
| | | GameWorld.DebugLog(" 未超过最大天,过天重置! curDays=%s" % (curDays), playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftOnDayTime, curTime)
|
| | | else:
|
| | | # 单天补发的
|
| | | for awardIndexStr, addItemList in giftItemDict.items():
|
| | | if awardIndexStr in actCTGIDDict:
|
| | | if not buyState&pow(2, int(awardIndexStr)):
|
| | | GameWorld.DebugLog("没有打包购买且没有单独购买,不补发! awardIndex=%s,packBuyTime=%s,buyState=%s" |
| | | % (awardIndexStr, packBuyTime, buyState), playerID)
|
| | | continue
|
| | | if getRecord&pow(2, int(awardIndexStr)):
|
| | | GameWorld.DebugLog("已经领取过该奖励了,不补发! awardIndex=%s,getRecord=%s" % (awardIndexStr, getRecord), playerID)
|
| | | continue
|
| | | GameWorld.DebugLog(" 补发离线天! awardIndex=%s" % (awardIndexStr), playerID)
|
| | | paramList = []
|
| | | PlayerControl.SendMailByKey("DailyPackBuyGift2", [playerID], addItemList, paramList)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftBuy, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyPackBuyGiftRecord, 0)
|
| | | Sync_DailyPackBuyGiftInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def Sync_DailyPackBuyGiftInfo(curPlayer):
|
| | | clientPack = ChPyNetSendPack.tagMCDailyPackBuyGiftInfo()
|
| | | clientPack.Clear()
|
| | | clientPack.PackBuyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftPackTime)
|
| | | clientPack.BuyStateToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftBuy)
|
| | | clientPack.AwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyPackBuyGiftRecord)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | ###################################################################
|
| | |
|
| | | ## 充值豪礼OnDay
|
| | | # @param curPlayer: 玩家
|
| | | # @return: None
|
| | | def OnDay(curPlayer):
|
| | | DoDailyPackBuyGiftOnDay(curPlayer)
|
| | | return
|
| | |
|
| | | ## 充值豪礼OnLogin
|
| | |
| | | #更新首充提示开始计时时间
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))
|
| | | Sync_DailyPackBuyGiftInfo(curPlayer)
|
| | | return
|
| | |
|
| | | ## 玩家充值元宝
|
| | |
| | | if ctgID in firstGoldCTGIDList:
|
| | | OnActiviteFirstGold(curPlayer)
|
| | |
|
| | | OnActiviteDailyPackBuyGift(curPlayer, ctgID) |
| | | return
|
| | |
|
| | | def OnActiviteFirstGold(curPlayer):
|