ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFB.py
@@ -23,17 +23,12 @@
#------------------------------------------------------------------------------ 
#"""Version = 2016-12-02 11:00"""
#------------------------------------------------------------------------------ 
import IPY_GameWorld
import PlayerControl
import GameWorld
import FBCommon
import ChConfig
import FBLogic
import PlayerSuccess
import ItemCommon
import IpyGameDataPY
import ShareDefine
import GameFuncComm
import NPCCommon
#---------------------------------------------------------------------
@@ -60,100 +55,48 @@
#    DWORD        MapID;
#    WORD        LineID;
#    BYTE        Cnt;    // 扫荡次数
#    BYTE        IsFinish;    // 是否立即完成; 0-否;1-花钱立即完成;2-客户端自行倒计时间到后发送2代表领取扫荡完成奖励
#    DWORD        DataEx;    //附带信息
#    BYTE        IsLittleHelper;    // 是否小助手扫荡
#};
def OnPlayerFBWipeOut(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    
    #if not GameWorld.CheckPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_BeginFBWipeOut, tick):
    #    GameWorld.DebugLog("玩家副本扫荡请求CD中...", curPlayer.GetPlayerID())
    #    return
    mapID = clientData.MapID
    lineID = clientData.LineID
    cnt = clientData.Cnt
    #isFinish = clientData.IsFinish
    isFinish = 1 # 暂时默认1,之后有需要扫荡等待的再说
    dataEx = clientData.DataEx
    isLittleHelper = clientData.IsLittleHelper
    if isLittleHelper:
        if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_LittleHelper):
            GameWorld.DebugLog("玩家没有小助手功能权限!", curPlayer.GetPlayerID())
            return
    
    if cnt <= 0:
        return
    
    fbIpyData = FBCommon.GetFBIpyData(mapID)
    if FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID()) == FBCommon.GetRecordMapID(mapID):
        if fbIpyData and fbIpyData.GetDayTimes():#没有限制进入次数的不限制在目标地图扫荡
            GameWorld.DebugLog("玩家在扫荡目标地图中,无法扫荡!mapID=%s" % mapID)
            return
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID, False)
    if not fbIpyData or not fbLineIpyData:
        GameWorld.DebugLog("不存在该副本或线路无法扫荡!mapID=%s, lineID=%s" % (mapID, lineID))
        return
    
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
    if not fbLineIpyData:
        GameWorld.DebugLog("找不到该副本线路,无法扫荡!mapID=%s, lineID=%s" % (mapID, lineID))
    if not FBCommon.IsFBPass(curPlayer, mapID, lineID):
        GameWorld.DebugLog("未过关无法扫荡!mapID=%s, lineID=%s" % (mapID, lineID))
        return
    
    if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, cnt) != ShareDefine.EntFBAskRet_OK:
        return
    costMoneyList = []
    sweepCostindexList = []
    sweepCostCnt = 0
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    if fbLineIpyData:
        #扫荡等级判断
        sweepLVLimit = fbLineIpyData.GetSweepLVLimit()
        if sweepLVLimit and curPlayer.GetLV() < sweepLVLimit:
            GameWorld.DebugLog('玩家副本扫荡,等级不足!mapID=%s, lineID=%s, playerLV=%s, sweepLVLimit=%s'
                               % (mapID, lineID, curPlayer.GetLV(), sweepLVLimit), curPlayer.GetPlayerID())
            return
        #扫荡道具判断,小助手不消耗扫荡道具
        sweepItemID = fbLineIpyData.GetSweepItemID()
        if sweepItemID and not isLittleHelper:
            sweepItemCnt = fbLineIpyData.GetSweepCostCnt()
            sweepCostCnt = sweepItemCnt * cnt
            #isEnough, sweepCostindexList = ItemCommon.GetItem_FromPack_ByID(sweepItemID, itemPack, sweepCostCnt)
            isEnough, sweepCostindexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(sweepItemID, itemPack, sweepCostCnt)
            if not isEnough:
                itemPrice = ItemCommon.GetShopItemPrice(sweepItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
                if itemPrice:
                    costMoney = itemPrice * lackCnt
                    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
                if not costMoneyList:
                    GameWorld.DebugLog("扫荡消耗道具不足, mapID=%s,lineID=%s,sweepItemID=%s,sweepCostCnt=%s"
                                   % (mapID, lineID, sweepItemID, sweepCostCnt), curPlayer.GetPlayerID())
                    return
    
    # 副本是否可扫荡, 这里只判断副本自身的特殊条件, 公共条件上面已经判断
    if not FBLogic.OnPlayerFBSweepAsk(curPlayer, mapID, lineID, cnt, isFinish, dataEx):
    if not FBLogic.OnPlayerFBSweepAsk(curPlayer, mapID, lineID, cnt, dataEx):
        GameWorld.DebugLog("该副本当前无法扫荡!mapID=%s, lineID=%s" % (mapID, lineID))
        return
    
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_FBSweep, 1, [mapID])
    #扣除扫荡道具
    if sweepCostindexList and sweepCostCnt:
        ItemCommon.ReduceItem(curPlayer, itemPack, sweepCostindexList, sweepCostCnt, False, 'FBSweepCostItem')
    if costMoneyList:
        infoDict = {"MapID":mapID, "LineID":lineID, 'SweepCount':cnt}
        for moneyType, moneyNum in costMoneyList:
            if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep, infoDict):
                return False, hasBind
    #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_FBSweep, 1, [mapID])
    
    #需先扣除门票, 再增加次数, 否则可能导致扣除的数量错误
    FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID, cnt)
    #FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID, cnt)
    #增加副本进入次数
    if fbIpyData and fbIpyData.GetDayTimes():
        FBCommon.AddEnterFBCount(curPlayer, mapID, cnt)
        
    #扫荡结果给奖励等
    FBLogic.OnPlayerFBSweepResult(curPlayer, mapID, lineID, cnt, isFinish, dataEx)
    FBLogic.OnPlayerFBSweepResult(curPlayer, mapID, lineID, cnt, dataEx)
    return
#// B1 08 快速一键过关副本 #tagCMFBQuickPass