hxp
2018-11-25 277715f147476b807ce46a3e839aa41b08ef2fc4
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_FamilyParty.py
@@ -26,28 +26,32 @@
import GameWorldProcess
import PlayerFairyCeremony
import EventReport
import PyGameData
import ItemCommon
import ItemControler
import Item_AddLV
#当前副本地图的状态
(
FB_Step_Open, # 地图开启
FB_Step_Fighting, # 战斗中
FB_Step_Over, # 副本关闭
FB_Step_Open,  # 地图开启
FB_Step_Fighting,  # 战斗中
FB_Step_Over,  # 副本关闭
) = range(3)
#---战盟副本---
Map_FamilyPartyFB_FamilyID = "FamilyPartyFB_FamilyID"     # 对应的家族id
Map_FamilyPartyFB_StartTick = "Map_FamilyPartyFB_StartTick"     # 副本开始时间
GameFBDict_LastEnterFbDay = 'LastEnterFbDay_%s' #上次进入活动的开服天
FBPlayerDict_TotalExp = 'XMYH_TotalExp%s'   # 获得的总经验
FBPlayerDict_TotalExpPoint = 'XMYH_TotalExpPoint%s'   # 获得的总经验点
FBPlayerDict_TotalPoint = 'XMYH_TotalPoint%s'   # 获得的总仙盟贡献值
FBPlayerDict_HasCollect = 'XMYH_HasCollect%s'   # 是否已采集
Map_FamilyPartyFB_StartTick = "Map_FamilyPartyFB_StartTick"  # 副本开始时间
GameFBDict_LastEnterFbDay = 'LastEnterFbDay_%s'  #上次进入活动的开服天
FBPlayerDict_TotalExp = 'XMYH_TotalExp%s'  # 获得的总经验
FBPlayerDict_TotalExpPoint = 'XMYH_TotalExpPoint%s'  # 获得的总经验点
FBPlayerDict_TotalPoint = 'XMYH_TotalPoint%s'  # 获得的总仙盟贡献值
FBPlayerDict_HasCollect = 'XMYH_HasCollect%s'  # 是否已采集
FBPlayerDict_HasSit = 'XMYH_HasSit%s'  # 是否已传功
def OnFBPlayerOnDay(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, 0)
    return
##开启副本
# @param tick 时间戳
@@ -55,8 +59,7 @@
# @remarks 开启副本
def OnOpenFB(tick):
    gameFB = GameWorld.GetGameFB()
    gameFB.SetGameFBDict(Map_FamilyPartyFB_FamilyID, 0)
    gameFB.ClearAllPlayerGameFBDict() # 清除所有玩家对应的副本字典信息
    gameFB.ClearAllPlayerGameFBDict()  # 清除所有玩家对应的副本字典信息
    gameFB.SetGameFBDict(ChConfig.Map_FBDict_NotifyStart, 0)
    return
@@ -105,6 +108,7 @@
# @return posX, posY, 随机半径(可选)
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
    return ipyEnterPosInfo
   
##是否可以进入
# @param ask 请求结构体
@@ -133,6 +137,7 @@
    #可进入
    return IPY_GameWorld.cmeAccept
##玩家进入副本
# @param curPlayer 玩家实例
# @param tick 时间戳
@@ -152,9 +157,7 @@
        PlayerControl.PlayerLeaveFB(curPlayer)
        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())
    GameWorld.DebugLog('closeFB_RemainTick=%s' % closeFB_RemainTick)
       
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
    if gameWorld.GetGameWorldDictByKey(GameFBDict_LastEnterFbDay % playerID) != openServerDay + 1:
@@ -163,6 +166,8 @@
        gameWorld.SetGameWorldDict(FBPlayerDict_TotalExpPoint % playerID, 0)
        gameWorld.SetGameWorldDict(FBPlayerDict_TotalPoint % playerID, 0)
        gameWorld.SetGameWorldDict(FBPlayerDict_HasCollect % playerID, 0)
        gameWorld.SetGameWorldDict(FBPlayerDict_HasSit % playerID, 0)
        FBCommon.ClearAreaRewardRecord(playerID)
        
        FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_FamilyParty)
@@ -173,33 +178,40 @@
    DoFBHelp(curPlayer, tick)
    return
def __GetRemainTick(tick):
    ##活动剩余毫秒
    mapID = GameWorld.GetMap().GetMapID()
    startTick  = GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_FamilyPartyFB_StartTick)
    closeFB_RemainTick = max(0, FBCommon.GetFBLineStepTime(mapID)[0]*1000 - (tick - startTick))
    startTick = GameWorld.GetGameWorld().GetGameWorldDictByKey(Map_FamilyPartyFB_StartTick)
    closeFB_RemainTick = max(0, FBCommon.GetFBLineStepTime(mapID)[0] * 1000 - (tick - startTick))
    return closeFB_RemainTick
##副本定时器
# @param tick 时间戳
# @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):
            FBCommon.SetFBStep(FB_Step_Fighting, tick)
    elif fbStep == FB_Step_Fighting:
        if not FBCommon.GetFBFuncOpenState(ChConfig.Def_FBMapID_FamilyParty):
            GiveJoinPrize()
            FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
            PyGameData.g_familyPartyInfo = []
            FBCommon.SetFBStep(FB_Step_Over, tick)
            FBCommon.DoLogic_FBKickAllPlayer()
            GameWorldProcess.CloseFB(tick)
        else:
            FBCommon.DoLogicAreaReward("FamilyPartyAreaAward", tick)
            FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 10000)
            #FBCommon.DoLogicAreaReward("FamilyPartyAreaAward", tick)
            #FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 10000)
            
            mapID = GameWorld.GetMap().GetMapID()
            notifyIndex = gameFB.GetGameFBDictByKey(ChConfig.Map_FBDict_NotifyStart)
@@ -209,15 +221,12 @@
                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)
            
    return
def FamilyPartyAnswerRight(curPlayer):
@@ -227,14 +236,14 @@
#        return
#    
    addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward',2)
    addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward', 2)
    #仙盟贡献度
    PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, addPoint, True, ShareDefine.Def_AddFAVReason_FamilyParty, True)
    #答题经验更新
    PlayerControl.PlayerControl(curPlayer).AddExp(addExp)
    
    curAnswerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, curAnswerCnt+1)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, curAnswerCnt + 1)
    if GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_FamilyParty:
        DoFBHelp(curPlayer, 0)
@@ -243,33 +252,36 @@
def OnFamilyPartyStateChange(state, tick):
    #活动状态变更
    GameWorld.DebugLog('    仙盟宴会活动状态变更 state=%s' % state)
#    if state == 0:
#        playerManager = GameWorld.GetPlayerManager()
#        for i in xrange(playerManager.GetPlayerCount()):
#            curPlayer = playerManager.GetPlayerByIndex(i)
#            if not curPlayer or curPlayer.IsEmpty():
#                continue
#            #答对题或者进过图的给参与奖励
#            curAnswerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt)
#            if FBCommon.GetEnterFBCount(curPlayer, ChConfig.Def_FBMapID_FamilyParty) or curAnswerCnt:
#                GiveJoinPrize(curPlayer)
    mapID = GameWorld.GetMap().GetMapID()
    if mapID != ChConfig.Def_FBMapID_FamilyParty:
        return
    GameWorld.DebugLog('    仙盟宴会活动状态变更 state=%s'%state)
    if state == 1:
        GameWorld.GetGameWorld().SetGameWorldDict(Map_FamilyPartyFB_StartTick, tick)
    
    return
def GiveJoinPrize():
    #参与奖
    joinAward = IpyGameDataPY.GetFuncCfg('PartyReward')
    if not joinAward:
        return
    copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
    for i in xrange(copyMapPlayerManager.GetPlayerCount()):
        curPlayer = copyMapPlayerManager.GetPlayerByIndex(i)
        if curPlayer == None or curPlayer.IsEmpty():
            continue
        PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, joinAward, True, ShareDefine.Def_AddFAVReason_FamilyParty)
    return
#
#def GiveJoinPrize(curPlayer):
#    #参与奖
#    joinAward = IpyGameDataPY.GetFuncCfg('PartyReward')
#    if not joinAward:
#        return
#
#    PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, joinAward, True, ShareDefine.Def_AddFAVReason_FamilyParty)
#    return
##获得玩家传入副本需要携带的信息
@@ -280,6 +292,7 @@
def GetPlayerResetWorldPosFBMsg(curPlayer, lineId):
    return '%s' % (curPlayer.GetPlayerID())
##玩家退出家族处理
# @param curPlayer 玩家实例
# @param tick 时间戳
@@ -287,7 +300,6 @@
def OnLeaveFamily(curPlayer, tick):
    #GameWorld.DebugLog("OnLeaveFamily...")
    curPlayerID = curPlayer.GetPlayerID()
        
    PlayerControl.PlayerLeaveFB(curPlayer)
    return
@@ -298,6 +310,7 @@
#  @return 是否副本复活
def OnPlayerReborn():
    return True
##获得副本帮助信息
# @param curPlayer 玩家实例
@@ -310,25 +323,33 @@
    playerID = curPlayer.GetPlayerID()
    totalExp = FBCommon.GetFBAreaRewardExp(gameWorld, playerID)
    curAnswerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt)
    addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward',2)
    exp = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExp%playerID)
    expPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExpPoint%playerID)
    addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward', 2)
    exp = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExp % playerID)
    expPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalExpPoint % playerID)
    totalExp = totalExp + expPoint * ChConfig.Def_PerPointValue + exp + addExp * curAnswerCnt
    exp = totalExp % ChConfig.Def_PerPointValue
    expPoint = totalExp / ChConfig.Def_PerPointValue
    
    totalPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalPoint%playerID)
    totalPoint += IpyGameDataPY.GetFuncCfg('PartyReward') #加参与奖
    totalPoint = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TotalPoint % playerID)
    #totalPoint += IpyGameDataPY.GetFuncCfg('PartyReward') #加参与奖
    totalPoint += addPoint * curAnswerCnt
    hasCollect = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasCollect%playerID)
    getCnt = gameWorld.GetGameWorldDictByKey(ChConfig.Map_Player_AreaReward_GetCnt%playerID)
    isFull = 1 if getCnt >= IpyGameDataPY.GetFuncCfg('FamilyPartyAreaAward', 3) else 0
    hasCollect = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasCollect % playerID)
    hasSit = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % playerID)
    
    helpDict = {FBCommon.Help_exp:exp, FBCommon.Help_expPoint:expPoint,FBCommon.Help_score:totalPoint, "hasCollect":hasCollect, "isFullExp":isFull}
    getCnt = gameWorld.GetGameWorldDictByKey(ChConfig.Map_Player_AreaReward_GetCnt % playerID)
    isFull = 1 if getCnt >= IpyGameDataPY.GetFuncCfg('FamilyPartyAreaAward', 3) else 0
    helpDict = {FBCommon.Help_exp:exp, FBCommon.Help_expPoint:expPoint, FBCommon.Help_score:totalPoint, "hasCollect":hasCollect, "isFullExp":isFull, "hasSit":hasSit}
    if PyGameData.g_familyPartyInfo:
        rankList = []
        for i, info in enumerate(PyGameData.g_familyPartyInfo[0], 1):
            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]}
    GameWorld.DebugLog("DoFBHelp %s" % helpDict, playerID)
    FBCommon.Notify_FBHelp(curPlayer, helpDict)
    return
##是否可以采集
# @param curPlayer 玩家实例
@@ -337,11 +358,17 @@
# @return 无意义
# @remarks
def OnCanCollect(curPlayer, curNPC, tick):
    hasCollect = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBPlayerDict_HasCollect%curPlayer.GetID())
    hasCollect = GameWorld.GetGameWorld().GetGameWorldDictByKey(FBPlayerDict_HasCollect % curPlayer.GetID())
    if hasCollect:
        PlayerControl.NotifyCode(curPlayer, 'Party_HadCollected')
        return
    needSpace = len(IpyGameDataPY.GetFuncEvalCfg('FamilyPartyDesk', 3))
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    if needSpace > packSpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
        return
    return True
##副本中,采集物需要Loading时间.
# @param curPlayer 玩家实例
@@ -351,18 +378,22 @@
def GetFBPrepareTime(curPlayer, curNPC):
    return IpyGameDataPY.GetFuncCfg('FamilyPartyDesk', 2) * 1000
##玩家收集成功(塔, 旗)
# @param curPlayer 玩家实例
# @param tick 时间戳
# @return 无意义
# @remarks
def OnCollectOK(curPlayer, tick):
def OnCollectOK(curPlayer, npcID, tick):
    playerID = curPlayer.GetID()
    gameWorld = GameWorld.GetGameWorld()
    gameWorld.SetGameWorldDict(FBPlayerDict_HasCollect % playerID, 1)
    
    GameWorld.DebugLog('    宴会采集成功!', playerID)
    #给奖励
    itemAward = IpyGameDataPY.GetFuncEvalCfg('FamilyPartyDesk', 3)
    for itemID, itemCount, isBind in itemAward:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem])
    addPoint = IpyGameDataPY.GetFuncCfg('FamilyPartyDesk')
    PlayerControl.NotifyCode(curPlayer, 'Party_CollectSuccess', [addPoint])
    PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, addPoint, True, ShareDefine.Def_AddFAVReason_FamilyParty)
@@ -371,4 +402,64 @@
    updPoint = totalPoint + addPoint
    gameWorld.SetGameWorldDict(FBPlayerDict_TotalPoint % playerID, updPoint)
    DoFBHelp(curPlayer, 0)
    return
    return
## 副本行为
#  @param curPlayer 玩家
#  @param actionType 行为类型
#  @param actionInfo 行为信息
#  @param tick 当前时间
#  @return None
def DoFBAction(curPlayer, actionType, actionInfo, tick):
    gameWorld = GameWorld.GetGameWorld()
    playerID = curPlayer.GetID()
    if actionType == 0:  #邀请打坐
        tagPlayerID = actionInfo
        if curPlayer.GetPlayerAction() in [IPY_GameWorld.paSit, IPY_GameWorld.paPreparing]:
            GameWorld.DebugLog('邀请打坐,玩家已处于打坐或采集状态', playerID)
            return
        hasSit = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % playerID)
        if hasSit:
            GameWorld.Log('邀请打坐,玩家已打坐过一次', playerID)
            return
        copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
        tagPlayer = copyMapPlayerManager.FindPlayerByID(tagPlayerID)
        if not tagPlayer:
            GameWorld.DebugLog('邀请%s打坐,该玩家不在副本里' % tagPlayerID, playerID)
            return
        curPlayer.StopMove()
        curPlayer.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:  #打坐结束给奖励
        hasSit = gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % playerID)
        if hasSit:
            GameWorld.Log('打坐结束给奖励,玩家已打坐过一次', playerID)
            return
        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)
        DoFBHelp(curPlayer, 0)
        if curPlayer.GetPlayerAction() == IPY_GameWorld.paSit:
            curPlayer.Stand()
        GameWorld.DebugLog('    传功结束,giveLV=%s, giveExp=%s, worldlv=%s' % (giveLV, giveExp, worldlv))
    return