#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#
|
#
|
##@package PlayerFB.py
|
#
|
# @todo:Íæ¼Ò¸±±¾
|
#
|
# @author hxp
|
# @date 2013-08-20
|
# @version 2.0
|
# @note:
|
# @change: "2014-08-01 00:30" hxp Ôö¼ÓÇå³ý¸±±¾Àäȴʱ¼äÂß¼
|
# @change: "2014-12-08 17:00" hxp Ôö¼ÓÇ帱±¾CD×êʯÏû·ÑÁ÷Ïò
|
# @change: "2015-02-10 22:30" hxp Ôö¼Ó×êʯÏûºÄÀàÐÍʼþ»ã±¨
|
# @change: "2015-06-29 18:00" xdh Ôö¼ÓÍæ¼Ò¸±±¾·ÅÆÈë¿Ú
|
# @change: "2016-02-30 17:00" hxp ÁìÖ÷°ÔÒµ¡¢¶ñħÊÔÁ¶
|
# @change: "2016-03-20 15:30" hxp ¸±±¾¶à±¶½±Àø£»¹«¹²CD¸±±¾É¨µ´
|
# @change: "2016-04-19 17:30" xdh ¸±±¾É¨µ´Ëã»îÔ¾¶È
|
# @change: "2016-04-26 15:30" hxp ¶à±¶½±Àø°Ù·Ö±È¸ÄΪ½±ÀøµÈ¼¶£» ɨµ´Ôö¼ÓÇëÇóCD
|
# @change: "2016-08-15 11:20" xdh ¸±±¾É¨µ´ÏûºÄµÀ¾ß
|
# @change: "2016-12-02 11:00" xdh ¸±±¾É¨µ´Ôö¼ÓÈËÎïµÈ¼¶ÅжÏ
|
#------------------------------------------------------------------------------
|
#"""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
|
|
#---------------------------------------------------------------------
|
def OnLogin(curPlayer):
|
return
|
|
## Íæ¼Ò¸±±¾ÐÐΪ·â°ü A5 08
|
# @param playerIndex Íæ¼ÒË÷Òý
|
# @param clientData ¿Í»§¶Ë·â°ü
|
# @param tick ʱ¼ä
|
# @return None
|
def OnDoFBAction(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
actionType = clientData.ActionType # ÐÐΪÀàÐÍ
|
actionInfo = clientData.ActionInfo # ÐÐΪÐÅÏ¢
|
FBLogic.DoFBAction(curPlayer, actionType, actionInfo, tick)
|
return
|
|
#//A5 05 Íæ¼Ò¿ªÊ¼¸±±¾É¨µ´ #tagCMBeginFBWipeOut
|
#
|
#struct tagCMBeginFBWipeOut
|
#{
|
# tagHead Head;
|
# 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)
|
if not fbLineIpyData:
|
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):
|
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
|
|
#ÐèÏȿ۳ýÃÅÆ±, ÔÙÔö¼Ó´ÎÊý, ·ñÔò¿ÉÄܵ¼Ö¿۳ýµÄÊýÁ¿´íÎó
|
FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID, cnt)
|
|
#Ôö¼Ó¸±±¾½øÈë´ÎÊý
|
if fbIpyData and fbIpyData.GetDayTimes():
|
FBCommon.AddEnterFBCount(curPlayer, mapID, cnt)
|
|
#ɨµ´½á¹û¸ø½±ÀøµÈ
|
FBLogic.OnPlayerFBSweepResult(curPlayer, mapID, lineID, cnt, isFinish, dataEx)
|
return
|
|
#// B1 08 ¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾ #tagCMFBQuickPass
|
#
|
#struct tagCMFBQuickPass
|
#{
|
# tagHead Head;
|
# DWORD MapID;
|
# WORD LineID;
|
#};
|
def OnFBQuickPass(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
playerID = curPlayer.GetPlayerID()
|
mapID = clientData.MapID
|
lineID = clientData.LineID
|
GameWorld.DebugLog("Íæ¼ÒÇëÇó¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
|
|
fbIpyData = FBCommon.GetFBIpyData(mapID)
|
fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
|
if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
|
return
|
|
reqRet = FBLogic.OnPlayerFBQuickPass(curPlayer, mapID, lineID)
|
if not reqRet or len(reqRet) != 2:
|
GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
|
return
|
bossID, quickCnt = reqRet
|
if bossID:
|
npcData = GameWorld.GetGameData().FindNPCDataByID(bossID)
|
if not npcData:
|
return
|
npcFightPower = NPCCommon.GetSuppressFightPower(npcData)
|
quickNeedRatio = IpyGameDataPY.GetFuncCfg("FBQuickPass", 1)
|
quickNeedFightPower = int(npcFightPower * quickNeedRatio)
|
curFightPower = PlayerControl.GetFightPower(curPlayer)
|
if quickNeedFightPower and curFightPower < quickNeedFightPower:
|
GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾! Õ½Á¦ÏÞÖÆ: mapID=%s,lineID=%s,bossID=%s,npcFightPower=%s,quickNeedFightPower=%s > %s"
|
% (mapID, lineID, bossID, npcFightPower, quickNeedFightPower, curFightPower), playerID)
|
PlayerControl.NotifyCode(curPlayer, 'TaskFeedback4')
|
return
|
|
#Ôö¼Ó¸±±¾½øÈë´ÎÊý
|
if fbIpyData and fbIpyData.GetDayTimes() and quickCnt:
|
# Ìø¹Ø³¬¹ý1¹ØµÄÒªÖØÐÂÑéÖ¤ÏÂ
|
if quickCnt > 1 and FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, quickCnt) != ShareDefine.EntFBAskRet_OK:
|
return
|
FBCommon.AddEnterFBCount(curPlayer, mapID, quickCnt)
|
|
#ɨµ´½á¹û¸ø½±ÀøµÈ
|
FBLogic.OnPlayerFBQuickPassResult(curPlayer, mapID, lineID)
|
return
|
|