#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GameWorldLogic.FBProcess.GameLogic_KillDevil
|
#
|
# @todo:ÌÖ·¥Ñýħ
|
# @author hxp
|
# @date 2020-01-07
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÌÖ·¥Ñýħ£¬×é¶Ó/µ¥ÈË
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2020-01-07 19:00"""
|
#-------------------------------------------------------------------------------
|
|
import FBCommon
|
import EventShell
|
import PlayerAssist
|
import GameWorldProcess
|
import NPCCustomRefresh
|
import ItemControler
|
import IPY_GameWorld
|
import GameWorld
|
import ChConfig
|
|
(
|
Def_PrepareTime, # ×¼±¸Ê±¼ä, Ãë
|
Def_FightTime, # ¸±±¾Ê±¼ä, Ãë
|
Def_ExitTime, # Í˳öʱ¼ä, Ãë
|
) = range(3)
|
|
# ¸±±¾×´Ì¬
|
(
|
FB_Step_Open, #¿ªÆô
|
FB_Step_Prepare, #×¼±¸ÖÐ
|
FB_Step_Fight, # Õ½¶·ÖÐ
|
FB_Step_Over, # ½áÊøµÈ´ý
|
FB_Step_Close, # ¹Ø±ÕÖÐ
|
) = range(5)
|
|
FBDict_FBBossID = "FBBossID" # ¸±±¾bossID
|
FBDict_KillNPCCount = "KillNPCCount_%s" # ÒÑ»÷ɱNPCÊý£¬²ÎÊýnpcID
|
|
## ¿ªÆô¸±±¾
|
def OnOpenFB(tick):
|
return
|
|
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
|
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
|
teamID = curPlayer.GetTeamID()
|
if teamID:
|
if curPlayer.GetTeamLV() != IPY_GameWorld.tmlLeader:
|
return True
|
|
taskID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PiaomiaoMaxGradeTaskID)
|
curMission = curPlayer.FindMission(taskID)
|
if curMission == None:
|
GameWorld.DebugLog("ûÓиø±±¾ÈÎÎñ£¬ÎÞ·¨½øÈë!taskID=%s" % taskID)
|
return False
|
missionState = curMission.GetMissionState()
|
if missionState != IPY_GameWorld.msProcessing:
|
GameWorld.DebugLog("¸Ã¸±±¾ÈÎÎñ·Ç½øÐÐÖУ¬ÎÞ·¨½øÈë!taskID=%s,missionState=%s" % (taskID, missionState))
|
return False
|
|
return True
|
|
## ¸±±¾Íæ¼Ò½øÈëµã
|
def OnGetFBEnterPos(curPlayer, mapID, lineID, ipyEnterPosInfo, tick):
|
return ipyEnterPosInfo
|
|
## ÊÇ·ñ¿ÉÒÔ½øÈë
|
def OnChangeMapAsk(ask, tick):
|
return IPY_GameWorld.cmeAccept
|
|
## Íæ¼Ò½øÈ븱±¾
|
def DoEnterFB(curPlayer, tick):
|
mapID = GameWorld.GetGameWorld().GetMapID()
|
mapID = FBCommon.GetRecordMapID(mapID)
|
gameFB = GameWorld.GetGameFB()
|
|
lineTimeCfg = FBCommon.GetFBLineStepTime(mapID)
|
|
# ½øÈëÏûºÄ´¦Àí
|
if not FBCommon.GetHadDelTicket(curPlayer):
|
FBCommon.SetHadDelTicket(curPlayer)
|
PlayerAssist.SetFBNoAssistPlayerID(curPlayer)
|
|
fbStep = gameFB.GetFBStep()
|
if fbStep == FB_Step_Open:
|
FBCommon.SetFBStep(FB_Step_Prepare, tick)
|
bossID = FBCommon.GetFBLineRefreshNPC(mapID)[1]
|
gameFB.SetGameFBDict(FBDict_FBBossID, bossID)
|
|
if fbStep <= FB_Step_Prepare:
|
notify_tick = lineTimeCfg[Def_PrepareTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttAddUpTime, 0, max(notify_tick, 0), True)
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True)
|
|
elif fbStep == FB_Step_Fight:
|
notify_tick = lineTimeCfg[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)
|
|
DoFBHelp(curPlayer, tick)
|
return
|
|
## ¸±±¾°ïÖúÐÅÏ¢
|
def DoFBHelp(curPlayer, tick):
|
playerID = curPlayer.GetPlayerID()
|
gameFB = GameWorld.GetGameFB()
|
npcID = gameFB.GetGameFBDictByKey(FBDict_FBBossID)
|
killCount = gameFB.GetGameFBDictByKey(FBDict_KillNPCCount % npcID)
|
#fbHelpDict = {FBCommon.Help_npcTotal:killCount}
|
fbHelpDict = {FBCommon.Help_npc:FBCommon.GetJsonNPCKillList({npcID:killCount})}
|
FBCommon.Notify_FBHelp(curPlayer, fbHelpDict)
|
GameWorld.DebugLog("DoFBHelp %s" % str(fbHelpDict), playerID)
|
return
|
|
## Íæ¼ÒÍ˳ö¸±±¾.
|
def DoExitFB(curPlayer, tick):
|
return
|
|
## Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
|
def DoPlayerLeaveFB(curPlayer, tick):
|
return
|
|
## ¹Ø±Õ¸±±¾
|
def OnCloseFB(tick):
|
return
|
|
## Íæ¼Ò¸±±¾¸´»î
|
def DoFBOnReborn(curPlayer, rebornType, tick):
|
return
|
|
## ¸±±¾¶¨Ê±Æ÷
|
def OnProcess(tick):
|
fbStep = GameWorld.GetGameFB().GetFBStep()
|
|
# ¸±±¾×¼±¸
|
if fbStep == FB_Step_Prepare:
|
__DoLogic_FB_Prepare(tick)
|
elif fbStep == FB_Step_Fight:
|
__ProcessFight(tick)
|
elif fbStep == FB_Step_Over:
|
__ProcessCloseFB(tick)
|
|
return
|
|
## ¸±±¾×¼±¸
|
def __DoLogic_FB_Prepare(tick):
|
#gameFB = GameWorld.GetGameFB()
|
mapID = GameWorld.GetMap().GetMapID()
|
fbCfg = FBCommon.GetFBLineStepTime(mapID)
|
# ¼ä¸ôδµ½
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_PrepareTime] * 1000:
|
return
|
|
gameFB = GameWorld.GetGameFB()
|
mapID = GameWorld.GetMap().GetMapID()
|
refreshMark, bossID = FBCommon.GetFBLineRefreshNPC(mapID)
|
gameFB.SetGameFBDict(FBDict_FBBossID, bossID)
|
|
NPCCustomRefresh.SetNPCRefresh(refreshMark, [bossID])
|
NPCCustomRefresh.ProcessAllNPCRefresh(tick) # Á¢¼´³ö·¢Ò»´Î±êʶµãË¢ÐÂ
|
|
FBCommon.SetFBStep(FB_Step_Fight, tick)
|
FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, fbCfg[Def_FightTime] * 1000)
|
return
|
|
## ¸±±¾Õ½¶·
|
def __ProcessFight(tick):
|
mapID = GameWorld.GetMap().GetMapID()
|
fbCfg = FBCommon.GetFBLineStepTime(mapID)
|
# ¼ä¸ôδµ½
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_FightTime] * 1000:
|
return
|
|
__DoKillDevilOver(False, tick)
|
return
|
|
## ¸±±¾¹Ø±Õ
|
def __ProcessCloseFB(tick):
|
mapID = GameWorld.GetMap().GetMapID()
|
fbCfg = FBCommon.GetFBLineStepTime(mapID)
|
# ¼ä¸ôδµ½
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_ExitTime] * 1000:
|
return
|
|
GameWorldProcess.CloseFB(tick)
|
FBCommon.SetFBStep(FB_Step_Close, tick)
|
return
|
|
## Íæ¼ÒɱËÀNPC
|
def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
|
npcID = curNPC.GetNPCID()
|
gameFB = GameWorld.GetGameFB()
|
fbBossID = gameFB.GetGameFBDictByKey(FBDict_FBBossID)
|
if npcID != fbBossID:
|
return
|
gameFB.SetGameFBDict(FBDict_KillNPCCount % npcID, gameFB.GetGameFBDictByKey(FBDict_KillNPCCount % npcID) + 1)
|
FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 0)
|
|
__DoKillDevilOver(True, tick)
|
return
|
|
def __DoKillDevilOver(isPass, tick):
|
# Õ½¶·³¬Ê±
|
gameFB = GameWorld.GetGameFB()
|
if gameFB.GetFBStep() == FB_Step_Over:
|
return
|
FBCommon.SetFBStep(FB_Step_Over, tick)
|
|
mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
|
noAssistPlayerID, assistMoneyType, assistPlayerMoneyDict = PlayerAssist.OnFBAssistOver(mapID)
|
exitTime = FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000
|
rewardInfo = FBCommon.GetFBLineReward(mapID, 0)
|
noAssistItemList, assistItemList = ([], []) if not rewardInfo else rewardInfo
|
|
playerManager = GameWorld.GetMapCopyPlayerManager()
|
playerCount = playerManager.GetPlayerCount()
|
for index in xrange(playerCount):
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
if not curPlayer:
|
continue
|
|
playerID = curPlayer.GetPlayerID()
|
overDict = {FBCommon.Over_dataMapID:mapID, FBCommon.Over_isPass: int(isPass)}
|
if isPass:
|
itemList = []
|
if playerID == noAssistPlayerID:
|
itemList = noAssistItemList
|
EventShell.EventRespons_FBEvent(curPlayer, "fb_pass_%s" % mapID)
|
|
elif playerID in assistPlayerMoneyDict:
|
addAssistMoney = assistPlayerMoneyDict[playerID]
|
itemList = assistItemList
|
overDict.update({FBCommon.Over_isAssist:1, FBCommon.Over_money:FBCommon.GetJsonMoneyList({assistMoneyType:addAssistMoney})})
|
overDict[FBCommon.Over_itemInfo] = FBCommon.GetJsonItemList(itemList)
|
|
if itemList:
|
ItemControler.GivePlayerItemOrMail(curPlayer, itemList)
|
|
GameWorld.DebugLog("overDict=%s" % overDict, playerID)
|
FBCommon.Notify_FB_Over(curPlayer, overDict)
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, exitTime, True)
|
|
return
|
|
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼ÓÉÍâ²ã¾ö¶¨
|
def CheckCanAttackTagObjInFB(attacker, defender):
|
return GameWorld.GetGameFB().GetFBStep() == FB_Step_Fight
|
|
|
|