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
    
@@ -358,6 +364,15 @@
def OnPlayerLogin(curPlayer):
    PyDataManager.GetDBPyUnNotifyLoveGiftRecManager().LoginNotify(curPlayer)
    # 同步伴侣亲密度
    playerID = curPlayer.GetPlayerID()
    couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID)
    if couple:
        coupleID = couple.GetCoupleID(playerID)
        intimacys = PyDataManager.GetIntimacyManager().GetIntimacys(playerID)
        intimacys.SyncMapServerIntimacy(curPlayer, coupleID)
    Sync_CoupleInfo(curPlayer)
    Sync_CandyList(curPlayer)
    return
@@ -455,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):
def __DoMarryResponse(curPlayer, playerID, reqPlayer, reqPlayerID, isOK, needResponse=True):
    ''' 提亲回应
    @param curPlayer: 回应玩家
    @param reqPlayer: 提亲玩家
@@ -472,24 +487,26 @@
    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)
    
    responsePack = ChPyNetSendPack.tagGCMarryResponseRet()
    responsePack.PlayerIDA = reqPlayerID
    responsePack.PlayerNameA = reqPlayerName
    responsePack.NameALen = len(responsePack.PlayerNameA)
    responsePack.PlayerIDB = playerID
    responsePack.PlayerNameB = playerName
    responsePack.NameBLen = len(responsePack.PlayerNameB)
    responsePack.IsOK = isOK
    if reqPlayer:
        NetPackCommon.SendFakePack(reqPlayer, responsePack) # 必回复提亲方
    if needResponse:
        responsePack = ChPyNetSendPack.tagGCMarryResponseRet()
        responsePack.PlayerIDA = reqPlayerID
        responsePack.PlayerNameA = reqPlayerName
        responsePack.NameALen = len(responsePack.PlayerNameA)
        responsePack.PlayerIDB = playerID
        responsePack.PlayerNameB = playerName
        responsePack.NameBLen = len(responsePack.PlayerNameB)
        responsePack.IsOK = isOK
        if reqPlayer:
            NetPackCommon.SendFakePack(reqPlayer, responsePack) # 必回复提亲方
    # 拒绝
    if not isOK:
        return
    NetPackCommon.SendFakePack(curPlayer, responsePack) # 回应方仅同意时同步
    if needResponse and curPlayer:
        NetPackCommon.SendFakePack(curPlayer, responsePack) # 回应方仅同意时同步
    
    # ===================== 以下执行成亲逻辑 ===================== 
    GameWorld.Log("执行成亲: reqPlayerID=%s,playerID=%s,bridePriceID=%s" % (reqPlayerID, playerID, bridePriceID), playerID)
@@ -540,7 +557,11 @@
        if not player:
            continue   
        mapServerCoupleInfo = couple.GetSendMapServerCoupleInfo(player.GetPlayerID())
        dataMsg = [reqPlayerID, bridePriceID, mapServerCoupleInfo]
        curIntimacys = PyDataManager.GetIntimacyManager().GetIntimacys(player.GetPlayerID())
        coupleIntimacy = curIntimacys.GetTagIntimacy(couple.GetCoupleID(player.GetPlayerID())) if curIntimacys else 0
        dataMsg = [reqPlayerID, bridePriceID, mapServerCoupleInfo, coupleIntimacy]
        MapServer_QueryPlayer_DoLogic_Love(player, "MarrySuccess", dataMsg, playerID)
        Sync_CoupleInfo(player)
        
@@ -567,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"))
@@ -724,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
@@ -742,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()
    
@@ -803,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)
@@ -820,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:
@@ -841,6 +910,7 @@
    if not __MarryCheckComm(curPlayer, tagPlayer, tagPlayerID, True):
        return
    
    curTime = int(time.time())
    playerID = curPlayer.GetPlayerID()
    
    if (playerID, tagPlayerID) in PyGameData.g_marryCandyInfo or (tagPlayerID, playerID) in PyGameData.g_marryCandyInfo:
@@ -854,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
@@ -865,8 +939,17 @@
            GameWorld.Log("聘礼提亲次数不足,无法提亲! bridePriceID=%s,buyCount(%s) >= canBuyMax(%s)" 
                          % (bridePriceID, buyCount, canBuyMax), playerID)
            return
    curTime = int(time.time())
        GameWorld.Log("已成亲的伴侣再次提亲,直接成亲! tagPlayerID=%s,coupleID=%s" % (tagPlayerID, coupleID), playerID)
        reqData = MarryReq()
        reqData.playerIDA = playerID
        reqData.playerIDB = tagPlayerID
        reqData.bridePriceID = bridePriceID
        reqData.reqTime = curTime
        PyGameData.g_marryReqInfo[playerID] = reqData
        __DoMarryResponse(tagPlayer, tagPlayerID, curPlayer, playerID, 1, False)
        return
    if tagPlayerID in PyGameData.g_marryReqInfo:
        tagReqData = PyGameData.g_marryReqInfo[tagPlayerID]
        tagBridePriceID = tagReqData.bridePriceID
@@ -880,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)
@@ -947,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])
@@ -991,6 +1082,7 @@
    candyObj.fireworksCountDict[playerID] = candyObj.fireworksCountDict.get(playerID, 0) + 1
    Sync_CandyList(None, [candyObj])
    
    PlayerControl.WorldNotify(0, "BuyFireworks", [curPlayer.GetName(), candyObj.playerNameA, candyObj.playerNameB])
    GameWorld.Log("更新婚礼烟花: updProsperity=%s,fireworksCountDict=%s" % (candyObj.prosperity, candyObj.fireworksCountDict), playerID)
    return costMoneyType, costMoneyValue
@@ -1081,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
@@ -1112,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)