From 6d9404d85f8c48a2b07fed99e2c042f55c3cb573 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 27 十一月 2023 14:20:25 +0800
Subject: [PATCH] 8716 【主干】【后端】【BT2】H.活动-节日祈愿(节日游历封包AA47修改);

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerLove.py |  100 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerLove.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerLove.py
index 111ff1f..6105118 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerLove.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerLove.py
@@ -159,12 +159,18 @@
         syncCoupleInfo = {}
         if syncPlayerIDList == None:
             syncPlayerIDList = self.coupleIDDict.keys()
+        # 分批同步,子服长度不能超过 65535,每批暂定最大同步1000个
         for playerID in syncPlayerIDList:
             couple = self.GetCouple(playerID)
             if not couple:
                 syncCoupleInfo[playerID] = []
             else:
                 syncCoupleInfo[playerID] = couple.GetSendMapServerCoupleInfo(playerID)
+            if len(syncCoupleInfo) >= 1000:
+                GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CoupleInfo, syncCoupleInfo)
+                syncCoupleInfo = {}
+        if not syncCoupleInfo:
+            return
         GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CoupleInfo, syncCoupleInfo)
         return
     
@@ -464,10 +470,10 @@
         PyGameData.g_marryReqInfo.pop(reqPlayerID, None)
         return
     
-    __DoMarryResponse(curPlayer, reqPlayer, reqPlayerID, isOK)
+    __DoMarryResponse(curPlayer, playerID, reqPlayer, reqPlayerID, isOK)
     return
 
-def __DoMarryResponse(curPlayer, reqPlayer, reqPlayerID, isOK, needResponse=True):
+def __DoMarryResponse(curPlayer, playerID, reqPlayer, reqPlayerID, isOK, needResponse=True):
     ''' 提亲回应
     @param curPlayer: 回应玩家
     @param reqPlayer: 提亲玩家
@@ -481,9 +487,9 @@
     if not ipyData:
         return
     
-    playerID = curPlayer.GetPlayerID()
+    #playerID = curPlayer.GetPlayerID()
     reqPlayerName = reqPlayer.GetName() if reqPlayer else PlayerSocial.GetSocialPlayerName(reqPlayerID)
-    playerName = curPlayer.GetName()
+    playerName = curPlayer.GetName() if curPlayer else PlayerSocial.GetSocialPlayerName(playerID)
     
     if needResponse:
         responsePack = ChPyNetSendPack.tagGCMarryResponseRet()
@@ -499,7 +505,7 @@
     # 拒绝
     if not isOK:
         return
-    if needResponse:
+    if needResponse and curPlayer:
         NetPackCommon.SendFakePack(curPlayer, responsePack) # 回应方仅同意时同步
     
     # ===================== 以下执行成亲逻辑 ===================== 
@@ -582,6 +588,45 @@
     PyGameData.g_marryReqInfo.pop(playerID, None) # 可能存在相互提亲的情况,尝试顺便把自身的提亲请求删除,因为已经无用了
     return True
 
+def GMAddCandy(curPlayer, bridePriceID, addCount):
+    ## GM添加测试喜糖宴会
+    fakeID = 0
+    for playerIDA, playerIDB in PyGameData.g_marryCandyInfo.keys():
+        if playerIDA < 10000:
+            fakeID = max(playerIDA, fakeID)
+        if playerIDB < 10000:
+            fakeID = max(playerIDB, fakeID)
+            
+    ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
+    if not ipyData:
+        return 0
+    prosperity = ipyData.GetProsperity()
+    candyTimes = ipyData.GetCandyTimes()
+    
+    syncCandyList = []
+    curTime = int(time.time())
+    for _ in xrange(addCount):
+        playerIDA = fakeID + 1
+        playerIDB = fakeID + 2
+        fakeID = playerIDB
+        
+        candyObj = MarryCandy()
+        candyObj.playerIDA = playerIDA
+        candyObj.playerNameA = PlayerSocial.GetSocialPlayerName(playerIDA)
+        candyObj.playerIDB = playerIDB
+        candyObj.playerNameB = PlayerSocial.GetSocialPlayerName(playerIDB)
+        candyObj.bridePriceID = bridePriceID
+        candyObj.marryTime = curTime
+        candyObj.endTime = curTime + candyTimes
+        AddProsperity(candyObj, prosperity)
+        
+        PyGameData.g_marryCandyInfo[(playerIDA, playerIDB)] = candyObj
+        syncCandyList.append(candyObj)
+        
+    __SortCandy()
+    Sync_CandyList(None, syncCandyList)
+    return addCount
+    
 def __SortCandy():
     PyGameData.g_marryCandySortList = PyGameData.g_marryCandyInfo.values()
     PyGameData.g_marryCandySortList.sort(key=operator.attrgetter("endTime"))
@@ -739,6 +784,10 @@
     tagPlayerID = dataMsg[0]
     playerID = curPlayer.GetPlayerID()
     
+    if not PlayerControl.GetDBPlayerAccIDByID(tagPlayerID):
+        PlayerControl.NotifyCode(curPlayer, "NoInDBPlayer")
+        return
+        
     # 黑名单检查
     if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, tagPlayerID, curPlayer):
         return
@@ -757,8 +806,8 @@
     if not ipyData:
         return
     
-    addCharmSelf = ipyData.GetAddCharmSelf() * giftCount
-    addCharmTag = ipyData.GetAddCharmTag() * giftCount
+    addCharmSelf = int(ipyData.GetAddCharmSelf() * giftCount)
+    addCharmTag = int(ipyData.GetAddCharmTag() * giftCount)
     addIntimacy = ipyData.GetAddIntimacy() * giftCount
     worldNotifyKey = ipyData.GetWorldNotifyKey()
     
@@ -818,12 +867,12 @@
     
     playerID = curPlayer.GetPlayerID()
     
-    # 黑名单检查
-    if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, tagPlayerID, curPlayer):
+    if not PlayerControl.GetDBPlayerAccIDByID(tagPlayerID):
+        PlayerControl.NotifyCode(curPlayer, "NoInDBPlayer")
         return
     
-    if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer):
-        PlayerControl.NotifyCode(curPlayer, "LoveOffline") # 离线
+    # 黑名单检查
+    if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, tagPlayerID, curPlayer):
         return
     
     curCouple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID)
@@ -835,6 +884,11 @@
     if tagCouple and tagCouple.GetCoupleID(tagPlayerID) != playerID:
         PlayerControl.NotifyCode(curPlayer, "TagHaveCouple") # 对方已经有其他伴侣了
         return
+    
+    if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer):
+        if not curCouple:
+            PlayerControl.NotifyCode(curPlayer, "LoveOffline") # 离线
+            return
     
     # 回应方可不检查亲密度
     if checkIntimacy:
@@ -870,6 +924,10 @@
             GameWorld.Log("已成亲伴侣ID不一致,无法提亲! tagPlayerID(%s) != coupleID(%s)" % (tagPlayerID, coupleID), playerID)
             return
         
+        if couple.GetBreakRequestID():
+            PlayerControl.NotifyCode(curPlayer, "LimitByMarryBroke") # 和离中无法操作
+            return
+        
         ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
         if not ipyData:
             return
@@ -889,7 +947,7 @@
         reqData.bridePriceID = bridePriceID
         reqData.reqTime = curTime
         PyGameData.g_marryReqInfo[playerID] = reqData
-        __DoMarryResponse(tagPlayer, curPlayer, playerID, 1, False)
+        __DoMarryResponse(tagPlayer, tagPlayerID, curPlayer, playerID, 1, False)
         return
     
     if tagPlayerID in PyGameData.g_marryReqInfo:
@@ -905,11 +963,11 @@
                 reqData.bridePriceID = bridePriceID
                 reqData.reqTime = curTime
                 PyGameData.g_marryReqInfo[playerID] = reqData
-                if __DoMarryResponse(tagPlayer, curPlayer, playerID, 1):
+                if __DoMarryResponse(tagPlayer, tagPlayerID, curPlayer, playerID, 1):
                     return
             GameWorld.Log("玩家提亲时,目标刚好已经先提过亲,且在有效期内,直接成亲!tagPlayerID=%s,tagBridePriceID=%s,bridePriceID=%s" 
                           % (tagPlayerID, tagBridePriceID, bridePriceID), playerID)
-            if __DoMarryResponse(curPlayer, tagPlayer, tagPlayerID, 1):
+            if __DoMarryResponse(curPlayer, playerID, tagPlayer, tagPlayerID, 1):
                 return
         else:
             GameWorld.DebugLog("对方有提亲,但是对象不一样或已超时! tagPlayerID=%s, timeout=%s" % (tagReqData.playerIDB, __CheckMarryReqTimeout(tagReqData)), playerID)
@@ -972,6 +1030,14 @@
     if canBuy:
         addProsperityValue = IpyGameDataPY.GetFuncCfg("LoveCandy", 3) # 喜糖每次增加繁荣度
         AddProsperity(candyObj, addProsperityValue)
+        PlayerControl.NotifyCode(curPlayer, "EatCandyProsperity", [curPlayer.GetName(), addProsperityValue])
+        for pID in [playerIDA, playerIDB]:
+            if playerID == pID:
+                continue
+            player = GameWorld.GetPlayerManager().FindPlayerByID(pID)
+            if not player or PlayerControl.GetIsTJG(player):
+                continue
+            PlayerControl.NotifyCode(player, "EatCandyProsperity", [curPlayer.GetName(), addProsperityValue])
         if isFree:
             candyObj.playerFreeEatCountDict[playerID] = playerFreeEatCount + 1
         Sync_CandyList(None, [candyObj])
@@ -1107,7 +1173,7 @@
     
     clientPack = ChPyNetSendPack.tagGCCandyList()
     clientPack.CandyInfoList = []
-    for candyObj in PyGameData.g_marryCandySortList:
+    for candyObj in syncCandyList:
         candyInfo = ChPyNetSendPack.tagGCCandyInfo()
         candyInfo.PlayerIDA = candyObj.playerIDA
         candyInfo.PlayerNameA = candyObj.playerNameA
@@ -1138,6 +1204,10 @@
                 continue
             
             for candyInfo in clientPack.CandyInfoList:
+                coupleIDInfo = (candyInfo.PlayerIDA, candyInfo.PlayerIDB)
+                if coupleIDInfo not in PyGameData.g_marryCandyInfo:
+                    continue
+                candyObj = PyGameData.g_marryCandyInfo[coupleIDInfo]
                 candyInfo.FireworksPlayerBuyCount = candyObj.fireworksCountDict.get(curPlayer.GetPlayerID(), 0)
                 candyInfo.PlayerFreeEatCandyCount = candyObj.playerFreeEatCountDict.get(curPlayer.GetPlayerID(), 0)
                 

--
Gitblit v1.8.0