xdh
2019-05-21 c26890bfb6fc43e232d062b241cba11b8797f5b2
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFB.py
@@ -39,11 +39,15 @@
import GameFuncComm
import FBHelpBattle
import ItemControler
import SkillShell
import PyGameData
import time
import math
#---------------------------------------------------------------------
def OnLogin(curPlayer):
    NotifyBuyFBBuffInfo(curPlayer)
    return
## 玩家副本行为封包 A5 08
#  @param playerIndex 玩家索引  
@@ -449,6 +453,83 @@
    FBLogic.OnClientStartFB(curPlayer, tick)
    return
#// A2 31 前端开始自定义场景 #tagCMClientStartCustomScene
#
#struct    tagCMClientStartCustomScene
#{
#    tagHead        Head;
#    DWORD        MapID;
#    WORD        FuncLineID;
#};
def OnClientStartCustomScene(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    mapID = clientData.MapID
    funcLineID = clientData.FuncLineID
    DoEnterCustomScene(curPlayer, mapID, funcLineID, tick)
    return
#// A2 33 前端退出自定义场景 #tagCMClientExitCustomScene
#
#struct    tagCMClientExitCustomScene
#{
#    tagHead        Head;
#};
def OnClientExitCustomScene(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    DoExitCustomScene(curPlayer)
    return
def DoEnterCustomScene(curPlayer, mapID, lineID, tick):
    ## 进入自定义场景状态
    resultPack = ChPyNetSendPack.tagMCStartCustomSceneResult()
    resultPack.MapID = mapID
    resultPack.FuncLineID = lineID
    #进入副本通用检查
    if mapID:
        fbIpyData = FBCommon.GetFBIpyData(mapID)
        fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
        if PlayerControl.CheckMoveToFB(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, tick) != ShareDefine.EntFBAskRet_OK:
            resultPack.Result = 0
            NetPackCommon.SendFakePack(curPlayer, resultPack)
            return
    curPlayer.SetCanAttack(False)
    curPlayer.SetVisible(False)
    curPlayer.SetSight(0)
    curPet = curPlayer.GetPetMgr().GetFightPet()
    if curPet:
        curPet.SetVisible(False)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomScene, 1) # 由于前端不一定有发mapID,所以这里额外记录这个状态,不能直接用mapID判断
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneMapID, mapID)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneLineID, lineID)
    GameWorld.Log("玩家开始自定义场景!mapID=%s,lineID=%s" % (mapID, lineID), curPlayer.GetPlayerID())
    if mapID:
        FBLogic.OnEnterCustomScene(curPlayer, mapID, lineID)
    #通知进入状态
    resultPack.Result = 1
    NetPackCommon.SendFakePack(curPlayer, resultPack)
    return
def DoExitCustomScene(curPlayer):
    ## 退出自定义场景状态
    curPlayer.SetCanAttack(True)
    curPlayer.SetVisible(True)
    curPlayer.SetSight(0)
    curPlayer.RefreshView()
    curPlayer.SetSight(ChConfig.Def_PlayerSight_Default)
    curPlayer.RefreshView()
    curPet = curPlayer.GetPetMgr().GetFightPet()
    if curPet:
        curPet.SetVisible(True)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomScene, 0)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneMapID, 0)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_ClientCustomSceneLineID, 0)
    GameWorld.Log("玩家退出自定义场景!", curPlayer.GetPlayerID())
    return
#// B1 08 刷新自定义副本奖励 #tagCMRefreshCustomFBPrize
#
@@ -512,3 +593,71 @@
    return
#// B1 0A 副本购买buff #tagCMFBBuyBuff
#struct    tagCMFBBuyBuff
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        MoneyCnt;
#};
def OnFBBuyBuff(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    mapID = clientData.MapID
    moneyCnt = clientData.MoneyCnt
    ipyData = IpyGameDataPY.GetIpyGameData('FBBuyBuff', mapID, moneyCnt)
    if not ipyData:
        return
    addBuffID = ipyData.GetBuffID()
    curSkill = GameWorld.GetGameData().GetSkillBySkillID(addBuffID)
    if not curSkill:
        return
    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
    if crossMapID and mapID !=crossMapID:
        return
    if not crossMapID and mapID != GameWorld.GetMap().GetMapID():
        return
    curTime = int(time.time())
    #判断CD
    timeKey = (mapID, moneyCnt)
    lastTime = PyGameData.g_fbBuyBuffTimeDict.get(playerID, {}).get(timeKey, 0)
    if lastTime and curTime - lastTime < ipyData.GetBuffCD():
        GameWorld.DebugLog('副本购买buff CD未到 ')
        return
    #扣钱
    infoDict =  {"MapID":mapID, "addBuffID":addBuffID}
    if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, moneyCnt, ChConfig.Def_Cost_FBBuyBuff, infoDict):
        return
    if playerID not in PyGameData.g_fbBuyBuffTimeDict:
        PyGameData.g_fbBuyBuffTimeDict[playerID] = {}
    PyGameData.g_fbBuyBuffTimeDict[playerID][timeKey] = curTime
    NotifyBuyFBBuffInfo(curPlayer)
    if crossMapID:
        msgDict = {"PlayerID":curPlayer.GetPlayerID(), "buffID":addBuffID}
        GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_AddBuff, msgDict)
        GameWorld.DebugLog("跨服中请求复活, crossMapID=%s,msgDict=%s" % (crossMapID, msgDict), playerID)
        return
    SkillShell.__DoLogic_AddBuff(curPlayer, curPlayer, curSkill, False, tick, 0, 0)
    #SkillCommon.AddBuffBySkillType(curPlayer, addBuffID, tick)
    return
def NotifyBuyFBBuffInfo(curPlayer):
    playerID = curPlayer.GetPlayerID()
    buffTimeDict = PyGameData.g_fbBuyBuffTimeDict.get(playerID, {})
    if not buffTimeDict:
        return
    packData = ChPyNetSendPack.tagMCFBBuyBuffInfo()
    packData.InfoList = []
    for timeKey, buyTime in buffTimeDict.items():
        mapID, moneyCnt = timeKey
        timeInfo = ChPyNetSendPack.tagMCFBBuyBuffTime()
        timeInfo.MapID = mapID
        timeInfo.MoneyCnt = moneyCnt
        timeInfo.BuyTime = buyTime
        packData.InfoList.append(timeInfo)
    packData.Cnt = len(packData.InfoList)
    NetPackCommon.SendFakePack(curPlayer, packData)
    return