From c490fac390e7c495424462d769c52c70b47a34ba Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 27 十一月 2023 17:20:51 +0800
Subject: [PATCH] 10014 【主干】【港台】【砍树】多个直购一次打包购买功能
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py | 60 ++++++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py | 3
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py | 60 ++++++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py | 169 ++++++++++++++++++++++++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 10 +
5 files changed, 300 insertions(+), 2 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index 3eb55f0..03c840d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -37069,6 +37069,66 @@
#------------------------------------------------------
+# AA 03 每日打包直购礼包 #tagMCDailyPackBuyGiftInfo
+
+class tagMCDailyPackBuyGiftInfo(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("PackBuyTime", c_int), # 打包购买的时间戳,如果有该值,代表已经一次性打包购买了,可根据次时间戳算出当前是第几天
+ ("BuyStateToday", c_int), # 今日礼包购买状态,按礼包索引二进制位计算代表是否已购买,仅非打包购买状态下有用
+ ("AwardState", c_int), # 今日礼包领奖状态,按礼包索引二进制位计算代表是否已领取
+ ]
+
+ def __init__(self):
+ self.Clear()
+ self.Cmd = 0xAA
+ self.SubCmd = 0x03
+ return
+
+ def ReadData(self, stringData, _pos=0, _len=0):
+ self.Clear()
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
+
+ def Clear(self):
+ self.Cmd = 0xAA
+ self.SubCmd = 0x03
+ self.PackBuyTime = 0
+ self.BuyStateToday = 0
+ self.AwardState = 0
+ return
+
+ def GetLength(self):
+ return sizeof(tagMCDailyPackBuyGiftInfo)
+
+ def GetBuffer(self):
+ return string_at(addressof(self), self.GetLength())
+
+ def OutputString(self):
+ DumpString = '''// AA 03 每日打包直购礼包 //tagMCDailyPackBuyGiftInfo:
+ Cmd:%s,
+ SubCmd:%s,
+ PackBuyTime:%d,
+ BuyStateToday:%d,
+ AwardState:%d
+ '''\
+ %(
+ self.Cmd,
+ self.SubCmd,
+ self.PackBuyTime,
+ self.BuyStateToday,
+ self.AwardState
+ )
+ return DumpString
+
+
+m_NAtagMCDailyPackBuyGiftInfo=tagMCDailyPackBuyGiftInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCDailyPackBuyGiftInfo.Cmd,m_NAtagMCDailyPackBuyGiftInfo.SubCmd))] = m_NAtagMCDailyPackBuyGiftInfo
+
+
+#------------------------------------------------------
# AA 24 每日免费直购礼包信息 #tagMCDayFreeGoldGiftState
class tagMCDayFreeGoldGiftState(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 0317678..abd54b5 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -4041,6 +4041,13 @@
Def_PDict_GodGiftResetCount = "ActGodGiftResetCount_%s" #已重置次数,参数:(活动编号)
Def_PDict_GodGiftAwardPool = "ActGodGiftAwardPool_%s" #奖池状态,参数:(活动编号) 0-未选择;1-已选择;2-已抽完
Def_PDict_GodGiftItemState = "ActGodGiftItemState_%s_%s_%s" #库物品状态,参数:(活动编号, 库, 编号) 已被选择次数*100+本奖池是否被选择*10+本奖池是否已被抽中
+
+#每日打包直购礼包
+Def_PDict_DailyPackBuyGiftBuy = "DailyPackBuyGiftBuy" # 每日打包直购礼包 - 今日购买状态,按索引位记录今日是否已购买
+Def_PDict_DailyPackBuyGiftRecord = "DailyPackBuyGiftRecord" # 每日打包直购礼包 - 今日领取记录,按索引位记录今日是否已领取
+Def_PDict_DailyPackBuyGiftPackTime = "DailyPackBuyGiftPackTime" # 每日打包直购礼包 - 打包购买时间戳
+Def_PDict_DailyPackBuyGiftOnDayTime = "DailyPackBuyGiftOnDayTime" # 每日打包直购礼包 - 上次处理过天时间戳
+
#-------------------------------------------------------------------------------
#开服活动,Def_PDictType_OpenServerCampaign
@@ -5805,7 +5812,8 @@
Def_RewardType_CustomAward, #自定义奖励 61
Def_RewardType_RealmXXZL, #境界修仙之路奖励 62
Def_RewardType_FamilyBossHurt, #仙盟boss伤害奖励 63
-)= range(64)
+Def_RewardType_DailyPackBuyGift, #打包直购礼包奖励 64
+)= range(65)
#boss复活相关活动定义
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 3eb55f0..03c840d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -37069,6 +37069,66 @@
#------------------------------------------------------
+# AA 03 每日打包直购礼包 #tagMCDailyPackBuyGiftInfo
+
+class tagMCDailyPackBuyGiftInfo(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("PackBuyTime", c_int), # 打包购买的时间戳,如果有该值,代表已经一次性打包购买了,可根据次时间戳算出当前是第几天
+ ("BuyStateToday", c_int), # 今日礼包购买状态,按礼包索引二进制位计算代表是否已购买,仅非打包购买状态下有用
+ ("AwardState", c_int), # 今日礼包领奖状态,按礼包索引二进制位计算代表是否已领取
+ ]
+
+ def __init__(self):
+ self.Clear()
+ self.Cmd = 0xAA
+ self.SubCmd = 0x03
+ return
+
+ def ReadData(self, stringData, _pos=0, _len=0):
+ self.Clear()
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
+
+ def Clear(self):
+ self.Cmd = 0xAA
+ self.SubCmd = 0x03
+ self.PackBuyTime = 0
+ self.BuyStateToday = 0
+ self.AwardState = 0
+ return
+
+ def GetLength(self):
+ return sizeof(tagMCDailyPackBuyGiftInfo)
+
+ def GetBuffer(self):
+ return string_at(addressof(self), self.GetLength())
+
+ def OutputString(self):
+ DumpString = '''// AA 03 每日打包直购礼包 //tagMCDailyPackBuyGiftInfo:
+ Cmd:%s,
+ SubCmd:%s,
+ PackBuyTime:%d,
+ BuyStateToday:%d,
+ AwardState:%d
+ '''\
+ %(
+ self.Cmd,
+ self.SubCmd,
+ self.PackBuyTime,
+ self.BuyStateToday,
+ self.AwardState
+ )
+ return DumpString
+
+
+m_NAtagMCDailyPackBuyGiftInfo=tagMCDailyPackBuyGiftInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCDailyPackBuyGiftInfo.Cmd,m_NAtagMCDailyPackBuyGiftInfo.SubCmd))] = m_NAtagMCDailyPackBuyGiftInfo
+
+
+#------------------------------------------------------
# AA 24 每日免费直购礼包信息 #tagMCDayFreeGoldGiftState
class tagMCDayFreeGoldGiftState(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
index cec15c4..e2439bf 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -5695,6 +5695,9 @@
#仙盟boss伤害奖励
elif rewardType == ChConfig.Def_RewardType_FamilyBossHurt:
GameLogic_FamilyBoss.GetFamilyBossHurtAward(curPlayer, dataEx, dataExStr)
+ #打包直购礼包奖励
+ elif rewardType == ChConfig.Def_RewardType_DailyPackBuyGift:
+ PlayerGoldGift.GetDailyPackBuyGift(curPlayer, dataEx)
#玩法前瞻奖励
elif rewardType == ChConfig.Def_RewardType_GameNotice:
OnGiveAwardByClient(curPlayer, rewardType, ChConfig.Def_PDict_GameNoticeAwardState, IpyGameDataPY.GetFuncEvalCfg("GameNoticeReward", 1))
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
index f9f4319..a0f95ee 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
@@ -169,12 +169,177 @@
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
@@ -188,6 +353,7 @@
#更新首充提示开始计时时间
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime):
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))
+ Sync_DailyPackBuyGiftInfo(curPlayer)
return
## 玩家充值元宝
@@ -202,7 +368,8 @@
firstGoldCTGIDList = IpyGameDataPY.GetFuncEvalCfg("FirstGold", 4)
if ctgID in firstGoldCTGIDList:
OnActiviteFirstGold(curPlayer)
-
+
+ OnActiviteDailyPackBuyGift(curPlayer, ctgID)
return
def OnActiviteFirstGold(curPlayer):
--
Gitblit v1.8.0