ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerLove.py
@@ -25,11 +25,18 @@
import ItemControler
import NetPackCommon
import ChConfig
import SkillCommon
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
@@ -130,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
@@ -219,6 +233,10 @@
    ## 离婚成功
    elif msgType == "ClearCoupleSocial":
        __ClearCoupleSocial(curPlayer, dataMsg)
    ## 同步亲密度
    elif msgType == "SyncMapServerIntimacy":
        SyncMapServerIntimacy(curPlayer, dataMsg)
        
    return
@@ -295,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"}
@@ -326,11 +348,11 @@
def __DoMarrySuccess(curPlayer, dataMsg):
    ## 执行成亲成功
    reqPlayerID, bridePriceID, mapServerCoupleInfo = dataMsg
    reqPlayerID, bridePriceID, mapServerCoupleInfo, coupleIntimacy = dataMsg
    playerID = curPlayer.GetPlayerID()
    PlayerControl.SetCoupleInfo(playerID, mapServerCoupleInfo)
    
    GameWorld.Log("执行成亲成功! reqPlayerID=%s,bridePriceID=%s" % (reqPlayerID, bridePriceID), playerID)
    GameWorld.Log("执行成亲成功! reqPlayerID=%s,bridePriceID=%s,coupleIntimacy=%s" % (reqPlayerID, bridePriceID, coupleIntimacy), playerID)
    
    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV) == 0:
        GameWorld.DebugLog("激活情戒!")
@@ -339,6 +361,9 @@
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, 0)
        Sync_LoveRingInfo(curPlayer)
        
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, coupleIntimacy)
    RefreshCoupleTeamBuff(curPlayer)
    # 提亲的玩家扣除消耗
    if playerID == reqPlayerID:
        ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
@@ -359,6 +384,10 @@
    PlayerControl.SetCoupleInfo(playerID, None)
    
    GameWorld.Log("清除伴侣关系成功! coupleID=%s" % (coupleID), playerID)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, 0)
    RefreshCoupleTeamBuff(curPlayer)
    RefreshLoveAttr(curPlayer)
    return
@@ -543,3 +572,54 @@
    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)
    if coupleID == tagID:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, intimacyValue)
        RefreshCoupleTeamBuff(curPlayer)
    return
def RefreshCoupleTeamBuff(curPlayer):
    ## 刷新伴侣组队buff
    teamID = curPlayer.GetTeamID()
    playerID = curPlayer.GetPlayerID()
    cupleID = PlayerControl.GetCoupleID(curPlayer)
    teamPlayerInfoDict = PyGameData.g_teamPlayerInfoDict.get(teamID, {}) if teamID else {}
    teamPlayerIDList = teamPlayerInfoDict.keys()
    skillLV = 0
    skillTypeID = IpyGameDataPY.GetFuncCfg("IntimacyBuff", 2)
    coupleIntimacy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCoupleIntimacy)
    if cupleID and cupleID in teamPlayerIDList:
        skillLVIntimacyList = IpyGameDataPY.GetFuncEvalCfg("IntimacyBuff", 1)
        for lv, lvIntimacy in enumerate(skillLVIntimacyList, 1):
            if coupleIntimacy >= lvIntimacy:
                skillLV = lv
            else:
                break
    GameWorld.DebugLog("刷新伴侣组队Buff: cupleID=%s,coupleIntimacy=%s,teamID=%s,teamPlayerIDList=%s,skillTypeID=%s,skillLV=%s"
                       % (cupleID, coupleIntimacy, teamID, teamPlayerIDList, skillTypeID, skillLV), playerID)
    tick = GameWorld.GetGameWorld().GetTick()
    if skillLV > 0:
        findBuff = SkillCommon.FindBuffByID(curPlayer, skillTypeID)[0]
        if findBuff:
            if skillLV == findBuff.GetSkill().GetSkillLV():
                return
            BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick)
        SkillCommon.AddBuffBySkillType(curPlayer, skillTypeID, tick, skillLV)
    else:
        if BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick):
            #统一刷新状态
            playerControl = PlayerControl.PlayerControl(curPlayer)
            playerControl.RefreshPlayerAttrByBuff()
    return