From 8c1ca0f0fc214bf9b04c7cf50a50718e60f7180d Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 10 十一月 2023 17:24:47 +0800
Subject: [PATCH] 9756 【BT8】【后端】结婚无限吃喜糖修改(增加可配置每日吃喜糖次数上限)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py   |   52 +++++++++++++++++
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py                        |   52 +++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py |   26 ++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py          |    1 
 4 files changed, 129 insertions(+), 2 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index 76d9b74..eaf1503 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -44932,6 +44932,58 @@
 
 
 #------------------------------------------------------
+# B3 30 情缘相关信息 #tagMCLoveInfo
+
+class  tagMCLoveInfo(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("EatCandyToday", c_int),    # 今日已吃喜糖次数,包含免费及付费的所有次数
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xB3
+        self.SubCmd = 0x30
+        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 = 0xB3
+        self.SubCmd = 0x30
+        self.EatCandyToday = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCLoveInfo)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// B3 30 情缘相关信息 //tagMCLoveInfo:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                EatCandyToday:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.EatCandyToday
+                                )
+        return DumpString
+
+
+m_NAtagMCLoveInfo=tagMCLoveInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCLoveInfo.Cmd,m_NAtagMCLoveInfo.SubCmd))] = m_NAtagMCLoveInfo
+
+
+#------------------------------------------------------
 # B3 27 情戒信息 #tagMCLoveRingInfo
 
 class  tagMCLoveRingInfo(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index a36d117..813fe93 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -4318,6 +4318,7 @@
 Def_PDict_LoveRingStarLV = "LoveRingStarLV" # 情戒 - 星级
 Def_PDict_LoveRingEatCount = "LoveRingEatCount" # 情戒 - 本星已淬炼道具数
 Def_PDict_LoveCoupleIntimacy = "LoveCoupleIntimacy" # 伴侣亲密度
+Def_PDict_LoveEatCandyToday = "LoveEatCandyToday" # 今日已吃喜糖次数
 Def_PDict_CharmLV = "CharmLV"  # 魅力等级
 
 #古宝
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 76d9b74..eaf1503 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -44932,6 +44932,58 @@
 
 
 #------------------------------------------------------
+# B3 30 情缘相关信息 #tagMCLoveInfo
+
+class  tagMCLoveInfo(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("EatCandyToday", c_int),    # 今日已吃喜糖次数,包含免费及付费的所有次数
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xB3
+        self.SubCmd = 0x30
+        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 = 0xB3
+        self.SubCmd = 0x30
+        self.EatCandyToday = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCLoveInfo)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// B3 30 情缘相关信息 //tagMCLoveInfo:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                EatCandyToday:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.EatCandyToday
+                                )
+        return DumpString
+
+
+m_NAtagMCLoveInfo=tagMCLoveInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCLoveInfo.Cmd,m_NAtagMCLoveInfo.SubCmd))] = m_NAtagMCLoveInfo
+
+
+#------------------------------------------------------
 # B3 27 情戒信息 #tagMCLoveRingInfo
 
 class  tagMCLoveRingInfo(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py
index 0feb3be..e86bf90 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py
@@ -29,10 +29,14 @@
 import BuffSkill
 import PyGameData
 
-def DoPlayerOnDay(curPlayer):   
+def DoPlayerOnDay(curPlayer):
+    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday):
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveEatCandyToday, 0)
+        Sync_LoveInfo(curPlayer)
     return
 
 def DoPlayerLogin(curPlayer):
+    Sync_LoveInfo(curPlayer)
     Sync_LoveRingInfo(curPlayer)
     return
 
@@ -133,6 +137,13 @@
     
     playerID = curPlayer.GetPlayerID()
     
+    EatCandyMax = IpyGameDataPY.GetFuncCfg("LoveCandy", 4)
+    if EatCandyMax:
+        eatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday)
+        if eatCandyToday >= EatCandyMax:
+            GameWorld.DebugLog("已达今日吃喜糖次数上限. eatCandyToday=%s >= %s" % (eatCandyToday, EatCandyMax), playerID)
+            return
+        
     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
         PlayerControl.NotifyCode(curPlayer, "RequestLater")
         return
@@ -302,7 +313,11 @@
     if not canBuy:
         return
     
-    GameWorld.Log("吃喜糖结果: isFree=%s" % (isFree), curPlayer.GetPlayerID())
+    updEatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday) + 1
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveEatCandyToday, updEatCandyToday)
+    Sync_LoveInfo(curPlayer)
+    
+    GameWorld.Log("吃喜糖结果: isFree=%s,updEatCandyToday=%s" % (isFree, updEatCandyToday), curPlayer.GetPlayerID())
     
     if not isFree:
         infoDict = {ChConfig.Def_Cost_Reason_SonKey:"EatCandy"}
@@ -557,6 +572,13 @@
     NetPackCommon.SendFakePack(curPlayer, clientPack)
     return
 
+def Sync_LoveInfo(curPlayer):
+    ## 同步情缘相关信息
+    clientPack = ChPyNetSendPack.tagMCLoveInfo()
+    clientPack.EatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday)
+    NetPackCommon.SendFakePack(curPlayer, clientPack)
+    return
+
 def SyncMapServerIntimacy(curPlayer, dataMsg):
     tagID, intimacyValue = dataMsg
     coupleID = PlayerControl.GetCoupleID(curPlayer)

--
Gitblit v1.8.0