From d0f8e3b301e3bbd8afd1b37bc70bc30a296dda39 Mon Sep 17 00:00:00 2001 From: xdh <xiefantasy@qq.com> Date: 星期四, 25 十月 2018 15:53:53 +0800 Subject: [PATCH] 4319 【后端】【1.2】超值礼包拆分成精彩活动的3个礼包 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 71 ++++++++++++----------------------- 1 files changed, 24 insertions(+), 47 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py index 421db9c..eef830d 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py @@ -69,6 +69,7 @@ import random import math +import time #--------------------------------------------------------------------- ##开始交易 # @param curPlayer 玩家实例 @@ -201,7 +202,6 @@ def ShopItemOnDay(curPlayer, onEventType): if onEventType == ShareDefine.Def_OnEventType: UpdataSuperGiftTime(curPlayer, True) - SyncSuperGiftInfo(curPlayer) OSSaleOpenMail(curPlayer) refreshType = [3] elif onEventType == ShareDefine.Def_OnEventTypeEx: @@ -629,67 +629,44 @@ #超值礼包购买时间 def UpdataSuperGiftTime(curPlayer, isOnday=False): - superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData) - giftIndex, startDay = superGiftData%10, superGiftData/10 - superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList') - if giftIndex >= len(superGiftTimeList): - return - if isOnday and not giftIndex: - return - openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1 - newIndex = giftIndex + curTime = int(time.time()) if isOnday: - lastDays = 0 - pastDay = openServerDay - startDay - for i in xrange(giftIndex-1, len(superGiftTimeList)): - lastDays += superGiftTimeList[i][1] - if pastDay < lastDays: - break - if pastDay >= lastDays: - newIndex = i+2 - + startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) + if not startTime: + return + superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList') + maxDay = max([info[1] for info in superGiftTimeList]) + if curTime - startTime >= maxDay * 86400: + #活动结束 重置 + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftStartTime, 0) else: - newIndex = min(len(superGiftTimeList), giftIndex+1) - - if newIndex == giftIndex: - return - - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftData, openServerDay*10+newIndex) - #通知 - if not isOnday: - SyncSuperGiftInfo(curPlayer) - if newIndex == 1: + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftStartTime, curTime) addItemList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList', 2) PlayerControl.SendMailByKey('SellMail2', [curPlayer.GetID()], addItemList) + SyncSuperGiftInfo(curPlayer) return True def SyncSuperGiftInfo(curPlayer): - superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData) - giftIndex, startDay = superGiftData%10, superGiftData/10 - superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList') - if giftIndex == 0 or giftIndex > len(superGiftTimeList): + startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) + if not startTime: return - giftID, day = superGiftTimeList[giftIndex-1] - openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1 - remainDay = max(0, day - openServerDay+startDay)-1 - packData = ChPyNetSendPack.tagMCSuperGiftInfo() - packData.GiftID = giftID - packData.EndtDate = str(GameWorld.GetDatetimeByDiffDays(remainDay))[:10] + packData.StartTime = startTime NetPackCommon.SendFakePack(curPlayer, packData) return def CheckSuperGiftBuy(curPlayer, giftID): #超值礼包是否可购买 - superGiftData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftData) - giftIndex, startDay = superGiftData%10, superGiftData/10 - superGiftTimeList = IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList') - if giftIndex == 0 or giftIndex > len(superGiftTimeList): + startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuperGiftStartTime) + if not startTime: return - curGiftID, day = superGiftTimeList[giftIndex-1] - if giftID != curGiftID: + + superGiftTimeDict = dict(IpyGameDataPY.GetFuncEvalCfg('SuperGiftTimeList')) + totalDay = superGiftTimeDict.get(giftID, 0) + if not totalDay: return - openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)+1 - if not max(0, day - openServerDay+startDay): + curTime = int(time.time()) + if (curTime - startTime)/86400 >= totalDay: + #已结束 return return True -- Gitblit v1.8.0