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 ++++++-----------
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearFirstGold.py | 2
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py | 60 ++++++---------
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py | 60 ++++++---------
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 2
5 files changed, 74 insertions(+), 121 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index cedf488..1e6813d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -21811,64 +21811,52 @@
# AA 16 通知超值礼包信息 #tagMCSuperGiftInfo
class tagMCSuperGiftInfo(Structure):
- Head = tagHead()
- GiftID = 0 #(DWORD GiftID)//商品ID
- EndtDate = "" #(char EndtDate[10])// 结束日期 y-m-d
- data = None
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("StartTime", c_int),
+ ]
def __init__(self):
self.Clear()
- self.Head.Cmd = 0xAA
- self.Head.SubCmd = 0x16
+ self.Cmd = 0xAA
+ self.SubCmd = 0x16
return
- def ReadData(self, _lpData, _pos=0, _Len=0):
+ def ReadData(self, stringData, _pos=0, _len=0):
self.Clear()
- _pos = self.Head.ReadData(_lpData, _pos)
- self.GiftID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.EndtDate,_pos = CommFunc.ReadString(_lpData, _pos,10)
- return _pos
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
def Clear(self):
- self.Head = tagHead()
- self.Head.Clear()
- self.Head.Cmd = 0xAA
- self.Head.SubCmd = 0x16
- self.GiftID = 0
- self.EndtDate = ""
+ self.Cmd = 0xAA
+ self.SubCmd = 0x16
+ self.StartTime = 0
return
def GetLength(self):
- length = 0
- length += self.Head.GetLength()
- length += 4
- length += 10
-
- return length
+ return sizeof(tagMCSuperGiftInfo)
def GetBuffer(self):
- data = ''
- data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
- data = CommFunc.WriteDWORD(data, self.GiftID)
- data = CommFunc.WriteString(data, 10, self.EndtDate)
- return data
+ return string_at(addressof(self), self.GetLength())
def OutputString(self):
- DumpString = '''
- Head:%s,
- GiftID:%d,
- EndtDate:%s
+ DumpString = '''// AA 16 通知超值礼包信息 //tagMCSuperGiftInfo:
+ Cmd:%s,
+ SubCmd:%s,
+ StartTime:%d
'''\
%(
- self.Head.OutputString(),
- self.GiftID,
- self.EndtDate
+ self.Cmd,
+ self.SubCmd,
+ self.StartTime
)
return DumpString
m_NAtagMCSuperGiftInfo=tagMCSuperGiftInfo()
-ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuperGiftInfo.Head.Cmd,m_NAtagMCSuperGiftInfo.Head.SubCmd))] = m_NAtagMCSuperGiftInfo
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuperGiftInfo.Cmd,m_NAtagMCSuperGiftInfo.SubCmd))] = m_NAtagMCSuperGiftInfo
#------------------------------------------------------
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 05eb2cc..c9a568c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3398,7 +3398,7 @@
Def_PDict_FirstGoldTry = "FirstGoldTry" # 首充试用状态 0-不可试用 1-可试用 2-已试用
Def_PDict_DailyGoldChargeState = "DailyGoldChargeState" # 天天首充活动状态,0-未开启;1-已开启
Def_PDict_DailyChargeState = "DailyChargeState" # 当日是否已充值
-Def_PDict_SuperGiftData = "SuperGiftData" # 超值礼包数据
+Def_PDict_SuperGiftStartTime = "SuperGiftStartTime" # 超值礼包开始时间
Def_PDict_DailyGoldChargePrizeRecord = "DailyGoldChargePrizeRecord" # 天天首充领奖记录,0-不可领;1-可领;2-已领
Def_PDict_DailyGoldChargeCnt = "DailyGoldChargeCnt" # 当日已充值数
Def_PDict_SingleGoldGiftIndex = "SingleGoldGiftIndex" # 单日充值多选一礼包领取状态, 0-未领取,>0已领取索引
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index cedf488..1e6813d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -21811,64 +21811,52 @@
# AA 16 通知超值礼包信息 #tagMCSuperGiftInfo
class tagMCSuperGiftInfo(Structure):
- Head = tagHead()
- GiftID = 0 #(DWORD GiftID)//商品ID
- EndtDate = "" #(char EndtDate[10])// 结束日期 y-m-d
- data = None
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("StartTime", c_int),
+ ]
def __init__(self):
self.Clear()
- self.Head.Cmd = 0xAA
- self.Head.SubCmd = 0x16
+ self.Cmd = 0xAA
+ self.SubCmd = 0x16
return
- def ReadData(self, _lpData, _pos=0, _Len=0):
+ def ReadData(self, stringData, _pos=0, _len=0):
self.Clear()
- _pos = self.Head.ReadData(_lpData, _pos)
- self.GiftID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.EndtDate,_pos = CommFunc.ReadString(_lpData, _pos,10)
- return _pos
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
def Clear(self):
- self.Head = tagHead()
- self.Head.Clear()
- self.Head.Cmd = 0xAA
- self.Head.SubCmd = 0x16
- self.GiftID = 0
- self.EndtDate = ""
+ self.Cmd = 0xAA
+ self.SubCmd = 0x16
+ self.StartTime = 0
return
def GetLength(self):
- length = 0
- length += self.Head.GetLength()
- length += 4
- length += 10
-
- return length
+ return sizeof(tagMCSuperGiftInfo)
def GetBuffer(self):
- data = ''
- data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
- data = CommFunc.WriteDWORD(data, self.GiftID)
- data = CommFunc.WriteString(data, 10, self.EndtDate)
- return data
+ return string_at(addressof(self), self.GetLength())
def OutputString(self):
- DumpString = '''
- Head:%s,
- GiftID:%d,
- EndtDate:%s
+ DumpString = '''// AA 16 通知超值礼包信息 //tagMCSuperGiftInfo:
+ Cmd:%s,
+ SubCmd:%s,
+ StartTime:%d
'''\
%(
- self.Head.OutputString(),
- self.GiftID,
- self.EndtDate
+ self.Cmd,
+ self.SubCmd,
+ self.StartTime
)
return DumpString
m_NAtagMCSuperGiftInfo=tagMCSuperGiftInfo()
-ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuperGiftInfo.Head.Cmd,m_NAtagMCSuperGiftInfo.Head.SubCmd))] = m_NAtagMCSuperGiftInfo
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuperGiftInfo.Cmd,m_NAtagMCSuperGiftInfo.SubCmd))] = m_NAtagMCSuperGiftInfo
#------------------------------------------------------
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
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearFirstGold.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearFirstGold.py
index 2fe7ef1..d5bf7b5 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearFirstGold.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearFirstGold.py
@@ -35,7 +35,7 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTry, 0)
# 重置今日已充值数
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyGoldChargeCnt, 0)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftData, 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftStartTime, 0)
# 重置充值次数信息
syncRecordIDList = []
ipyDataMgr = IpyGameDataPY.IPY_Data()
--
Gitblit v1.8.0