ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_FamilyParty.py
@@ -39,7 +39,6 @@
) = range(3)
#---战盟副本---
Map_FamilyPartyFB_FamilyID = "FamilyPartyFB_FamilyID"  # 对应的家族id
Map_FamilyPartyFB_StartTick = "Map_FamilyPartyFB_StartTick"  # 副本开始时间
GameFBDict_LastEnterFbDay = 'LastEnterFbDay_%s'  #上次进入活动的开服天
FBPlayerDict_TotalExp = 'XMYH_TotalExp%s'  # 获得的总经验
@@ -48,7 +47,7 @@
FBPlayerDict_HasCollect = 'XMYH_HasCollect%s'  # 是否已采集
FBPlayerDict_HasSit = 'XMYH_HasSit%s'  # 是否已传功
g_familyMapPlayerIDDict = {}#{lineid:[playerid,..]}
def OnFBPlayerOnDay(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, 0)
    return
@@ -60,7 +59,6 @@
# @remarks 开启副本
def OnOpenFB(tick):
    gameFB = GameWorld.GetGameFB()
    gameFB.SetGameFBDict(Map_FamilyPartyFB_FamilyID, 0)
    gameFB.ClearAllPlayerGameFBDict()  # 清除所有玩家对应的副本字典信息
    gameFB.SetGameFBDict(ChConfig.Map_FBDict_NotifyStart, 0)
    return
@@ -146,6 +144,7 @@
# @return 无意义
# @remarks 玩家进入副本
def DoEnterFB(curPlayer, tick):
    global g_familyMapPlayerIDDict
    mapID = GameWorld.GetGameWorld().GetMapID()
    playerID = curPlayer.GetPlayerID()
    if not __CheckEnter(curPlayer, mapID):
@@ -160,8 +159,6 @@
        return
    curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, closeFB_RemainTick, True) 
    GameWorld.DebugLog('closeFB_RemainTick=%s' % closeFB_RemainTick)
    if not gameFB.GetGameFBDictByKey(Map_FamilyPartyFB_FamilyID):
        gameFB.SetGameFBDict(Map_FamilyPartyFB_FamilyID, curPlayer.GetFamilyID())
       
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
    if gameWorld.GetGameWorldDictByKey(GameFBDict_LastEnterFbDay % playerID) != openServerDay + 1:
@@ -178,8 +175,19 @@
        PlayerFamily.AddFamilyActivity(curPlayer, ShareDefine.FamilyActive_Party)
        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_FamilyParty, 0, ChConfig.CME_Log_Start)
        PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FamilyParty, 1)
    lineID = GameWorld.GetGameWorld().GetLineID()
    if lineID not in g_familyMapPlayerIDDict:
        g_familyMapPlayerIDDict[lineID] = []
    if playerID not in g_familyMapPlayerIDDict[lineID]:
        g_familyMapPlayerIDDict[lineID].append(playerID)
    
    DoFBHelp(curPlayer, tick)
    playerManager = GameWorld.GetMapCopyPlayerManager()
    for index in xrange(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not curPlayer:
            continue
        DoFBHelp(curPlayer, tick, True)
    return
@@ -196,8 +204,12 @@
# @return 返回值无意义
# @remarks 副本定时器
def OnProcess(tick):
    familyID = GameWorld.GetGameWorld().GetPropertyID()
    if not familyID:
        return
    gameFB = GameWorld.GetGameFB()
    fbStep = gameFB.GetFBStep()
    #GameWorld.DebugLog("    OnProcess...")
    if fbStep == FB_Step_Open:
        if FBCommon.GetFBFuncOpenState(ChConfig.Def_FBMapID_FamilyParty):
@@ -211,7 +223,7 @@
            GameWorldProcess.CloseFB(tick)
        else:
            #FBCommon.DoLogicAreaReward("FamilyPartyAreaAward", tick)
            #FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 10000)
            FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 10000)
            
            mapID = GameWorld.GetMap().GetMapID()
            notifyIndex = gameFB.GetGameFBDictByKey(ChConfig.Map_FBDict_NotifyStart)
@@ -221,7 +233,7 @@
                remaindTick = max(0, __GetRemainTick(tick) - 1000)
                if remaindTick <= (notifySecond + 1) * 1000:   
                    #remaindSecond = remaindTick / 1000
                    familyID = gameFB.GetGameFBDictByKey(Map_FamilyPartyFB_FamilyID)
                    PlayerControl.FamilyNotify(familyID, "Party_OverTime", [notifySecond])
                     
                    GameWorld.GetGameFB().SetGameFBDict(ChConfig.Map_FBDict_NotifyStart, notifyIndex + 1)
@@ -268,9 +280,11 @@
    if mapID != ChConfig.Def_FBMapID_FamilyParty:
        return
    if state == 1:
        GameWorld.GetGameWorld().SetGameWorldDict(Map_FamilyPartyFB_StartTick, tick)
    if state:
        if not GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_FamilyPartyFB_StartTick):
            GameWorld.GetGameWorld().SetGameWorldDict(Map_FamilyPartyFB_StartTick, tick)
    else:
        GameWorld.GetGameWorld().SetGameWorldDict(Map_FamilyPartyFB_StartTick, 0)
    return
#
@@ -317,7 +331,7 @@
# @param tick 时间戳
# @return 无意义
# @remarks 用于通知阵营比分条
def DoFBHelp(curPlayer, tick):
def DoFBHelp(curPlayer, tick, isSyncPlayerID=False):
    #gameFB = GameWorld.GetGameFB()
    gameWorld = GameWorld.GetGameWorld()
    playerID = curPlayer.GetPlayerID()
@@ -345,7 +359,10 @@
            rankList.append({"rank":i, "name":info[1], "cnt":info[2]})
        helpDict['familyPartyRank'] = rankList
        helpDict['familyPartyTop'] = {'name':PyGameData.g_familyPartyInfo[1], "cnt":PyGameData.g_familyPartyInfo[2]}
    if isSyncPlayerID:
        lineID = GameWorld.GetGameWorld().GetLineID()
        helpDict['familyPartyPlayer'] = g_familyMapPlayerIDDict.get(lineID, [])
    GameWorld.DebugLog("DoFBHelp %s" % helpDict, playerID)
    FBCommon.Notify_FBHelp(curPlayer, helpDict)
    return
@@ -404,6 +421,25 @@
    DoFBHelp(curPlayer, 0)
    return
##玩家退出副本
# @param curPlayer 玩家实例
# @param tick 时间戳
# @return 无意义
def DoExitFB(curPlayer, tick):
    global g_familyMapPlayerIDDict
    __GiveSitAward(curPlayer)
    lineID = GameWorld.GetGameWorld().GetLineID()
    playerID = curPlayer.GetID()
    if playerID in g_familyMapPlayerIDDict.get(lineID, []):
        g_familyMapPlayerIDDict[lineID].remove(playerID)
        if g_familyMapPlayerIDDict[lineID]:
            playerManager = GameWorld.GetMapCopyPlayerManager()
            for index in xrange(playerManager.GetPlayerCount()):
                curPlayer = playerManager.GetPlayerByIndex(index)
                if not curPlayer:
                    continue
                DoFBHelp(curPlayer, tick, True)
    return
## 副本行为
#  @param curPlayer 玩家
@@ -428,33 +464,52 @@
        tagPlayer = copyMapPlayerManager.FindPlayerByID(tagPlayerID)
        if not tagPlayer:
            GameWorld.DebugLog('邀请%s打坐,该玩家不在副本里' % tagPlayerID, playerID)
            PlayerControl.NotifyCode(curPlayer, 'PartySitFail')
            return
        curPlayer.StopMove()
        curPlayer.Sit()
        if tagPlayer.GetPlayerAction() not in [IPY_GameWorld.paSit, IPY_GameWorld.paPreparing]:
            tagPlayer.StopMove()
            tagPlayer.Sit()
#        if not gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % tagPlayerID):
#            if tagPlayer.GetPlayerAction() not in [IPY_GameWorld.paSit, IPY_GameWorld.paPreparing]:
#                tagPlayer.StopMove()
#                tagPlayer.Sit()
    elif actionType == 1:  #打坐结束给奖励
        reLV = curPlayer.GetLV()
        worldlv = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
        giveLV = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward', 2))
        addExp = 0
        if giveLV:
            addExp = Item_AddLV.DoAddLVEx(curPlayer, giveLV, True, True, 0)
        reLV = curPlayer.GetLV()
        reExp = PlayerControl.GetPlayerReExp(curPlayer)
        giveExp = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward'))
        if giveExp:
            PlayerControl.PlayerControl(curPlayer).AddExp(giveExp)
            exp = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExp % playerID)
            expPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExpPoint % playerID)
            newTotalExp = expPoint*ChConfig.Def_PerPointValue+exp+giveExp+addExp
            gameWorld.SetGameWorldDict(FBPlayerDict_TotalExp % playerID, newTotalExp%ChConfig.Def_PerPointValue)
            gameWorld.SetGameWorldDict(FBPlayerDict_TotalExpPoint % playerID, newTotalExp/ChConfig.Def_PerPointValue)
        gameWorld.SetGameWorldDict(FBPlayerDict_HasSit % playerID, 1)
        if not __GiveSitAward(curPlayer):
            return
        DoFBHelp(curPlayer, 0)
        if curPlayer.GetPlayerAction() == IPY_GameWorld.paSit:
            curPlayer.Stand()
        GameWorld.DebugLog('    传功结束,giveLV=%s, giveExp=%s, worldlv=%s' % (giveLV, giveExp, worldlv))
    return
def __GiveSitAward(curPlayer):
    #给打坐奖励
    gameWorld = GameWorld.GetGameWorld()
    playerID = curPlayer.GetID()
    hasSit = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % playerID)
    if hasSit:
        GameWorld.Log('打坐结束给奖励,玩家已打坐过一次', playerID)
        return
    if curPlayer.GetPlayerAction() != IPY_GameWorld.paSit:
        GameWorld.Log('打坐结束给奖励,玩家不在打坐状态', playerID)
        return
    curPlayer.Stand()
    reLV = curPlayer.GetLV()
    worldlv = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
    giveLV = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward', 2))
    addExp = 0
    if giveLV:
        addExp = Item_AddLV.DoAddLVEx(curPlayer, giveLV, True, True, 0)
    reLV = curPlayer.GetLV()
    reExp = PlayerControl.GetPlayerReExp(curPlayer)
    giveExp = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward'))
    if giveExp:
        PlayerControl.PlayerControl(curPlayer).AddExp(giveExp)
        exp = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExp % playerID)
        expPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExpPoint % playerID)
        newTotalExp = expPoint*ChConfig.Def_PerPointValue+exp+giveExp+addExp
        gameWorld.SetGameWorldDict(FBPlayerDict_TotalExp % playerID, newTotalExp%ChConfig.Def_PerPointValue)
        gameWorld.SetGameWorldDict(FBPlayerDict_TotalExpPoint % playerID, newTotalExp/ChConfig.Def_PerPointValue)
    gameWorld.SetGameWorldDict(FBPlayerDict_HasSit % playerID, 1)
    GameWorld.DebugLog('    传功结束,giveLV=%s, giveExp=%s, worldlv=%s' % (giveLV, giveExp, worldlv))
    return True