#!/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 NPCCommon
|
import PyGameData
|
import PlayerAssist
|
import IpyGameDataPY
|
import ItemControler
|
import GameWorldProcess
|
import PlayerFairyDomain
|
import NPCCustomRefresh
|
import IPY_GameWorld
|
import ItemCommon
|
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
|
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'MapID':mapID, 'LineID':lineID})
|
if not ipyData:
|
return
|
fdeventID = ipyData.GetID()
|
if not PlayerFairyDomain.SetFairyDomainEventState(curPlayer, fdeventID, PlayerFairyDomain.FDEventState_Visiting):
|
GameWorld.DebugLog("ÉèÖÃʼþѰ·ÃÖÐʧ°Ü£¬¿ÉÄÜûÓиÃʼþ! fdeventID=%s" % fdeventID)
|
return
|
|
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)
|
|
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:
|
PyGameData.g_fbPickUpItemDict.pop(curPlayer.GetPlayerID(), 0)
|
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(tick)
|
return
|
|
## ¸±±¾¹Ø±Õ
|
def __ProcessCloseFB(tick):
|
mapID = GameWorld.GetMap().GetMapID()
|
fbCfg = FBCommon.GetFBLineStepTime(mapID)
|
closeTime = ChConfig.Def_FBPickupItemTime + fbCfg[Def_ExitTime] * 1000
|
# ¼ä¸ôδµ½
|
if tick - GameWorld.GetGameFB().GetFBStepTick() < closeTime:
|
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(tick, curNPC)
|
return
|
|
def __DoKillDevilOver(tick, curNPC=None):
|
# Õ½¶·³¬Ê±
|
gameFB = GameWorld.GetGameFB()
|
if gameFB.GetFBStep() == FB_Step_Over:
|
return
|
FBCommon.SetFBStep(FB_Step_Over, tick)
|
|
isPass = curNPC != None
|
lineID = 0
|
mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'MapID':mapID, 'LineID':lineID})
|
fdeventID = ipyData.GetID() if ipyData else 0
|
GameWorld.DebugLog("¸±±¾½áËã: isPass=%s" % (isPass))
|
|
noAssistPlayerID, assistMoneyType, assistPlayerMoneyDict = PlayerAssist.OnFBAssistOver(isPass, mapID)
|
exitTime = FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000
|
rewardInfo = FBCommon.GetFBLineReward(mapID, 0)
|
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 = {}
|
if isPass and noAssistPlayerID:
|
if playerID == noAssistPlayerID:
|
bossID = curNPC.GetNPCID()
|
dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY()
|
isOnlySelfSee = False
|
isDropDisperse = True
|
dropItemMapInfo = [dropPosX, dropPosY, isOnlySelfSee, isDropDisperse]
|
jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, mapID, {bossID:1}, dropItemMapInfo=dropItemMapInfo)
|
if not jsonItemList:
|
# ûÓеôÂäʱֱ½Ó֪ͨ½áË㣬·ÀÖ¹¿¨¸±±¾
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, exitTime, True)
|
FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
else:
|
PlayerFairyDomain.SetFairyDomainEventState(curPlayer, fdeventID, PlayerFairyDomain.FDEventState_Visited)
|
curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, ChConfig.Def_FBPickupItemTime, True)
|
continue
|
|
elif playerID in assistPlayerMoneyDict:
|
addAssistMoney = assistPlayerMoneyDict[playerID]
|
overDict.update({FBCommon.Over_isAssist:1, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(assistItemList),
|
FBCommon.Over_money:FBCommon.GetJsonMoneyList({assistMoneyType:addAssistMoney})})
|
ItemControler.GivePlayerItemOrMail(curPlayer, assistItemList)
|
|
else:
|
pass
|
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, exitTime, True)
|
FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
|
return
|
|
def OnPickUpItem(curPlayer, curItem, tick):
|
mapItemType = curItem.GetType()
|
if mapItemType == ChConfig.Def_ItemType_Money:
|
return
|
playerID = curPlayer.GetID()
|
isEquip = ItemCommon.CheckItemIsEquip(curItem)
|
jsonItem = ItemCommon.GetJsonItem(curItem)
|
if playerID in PyGameData.g_fbPickUpItemDict:
|
if isEquip:
|
PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
|
else:
|
isIn = False
|
for itemInfo in PyGameData.g_fbPickUpItemDict[playerID]:
|
if itemInfo["ItemID"] == jsonItem["ItemID"] and itemInfo.get("IsBind") == jsonItem.get("IsBind"):
|
itemInfo["Count"] = itemInfo.get("Count", 1) + jsonItem.get("Count", 1)
|
isIn = True
|
break
|
if not isIn:
|
PyGameData.g_fbPickUpItemDict[playerID].append(jsonItem)
|
else:
|
PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem]
|
|
playerItemCount = 0
|
mapItemManager = GameWorld.GetMapItemManager()
|
for index in xrange(mapItemManager.GetMapItemCount()):
|
mapItem = mapItemManager.GetMapItemByIndex(index)
|
if not mapItem or mapItem.IsEmpty():
|
continue
|
|
# »¹ÓÐÊôÓÚ×Ô¼ºµÄ¶«Î÷û¼ñ²»Í¨Öª½áÊø
|
if mapItem.GetOwnerID() == curPlayer.GetPlayerID():
|
playerItemCount += 1
|
|
isItemAllPickUp = (playerItemCount <= 1)
|
if not isItemAllPickUp:
|
return
|
|
isPass = 1
|
lineID = 0
|
mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
|
leaveTick = FBCommon.GetFBLineStepTime(mapID)[Def_ExitTime] * 1000
|
jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, [])
|
curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True)
|
overDict = {FBCommon.Over_itemInfo:jsonItemList}
|
FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
return
|
|
## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼ÓÉÍâ²ã¾ö¶¨
|
def CheckCanAttackTagObjInFB(attacker, defender):
|
return GameWorld.GetGameFB().GetFBStep() == FB_Step_Fight
|
|
## ¿É·ñɨµ´
|
def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
|
curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
|
if curState not in [PlayerFairyDomain.FDEventState_CanVisit, PlayerFairyDomain.FDEventState_Visiting]:
|
GameWorld.DebugLog("çÎç¿ÎÞ·¨É¨µ´! ²»´æÔÚ¸Ãʼþ»òÎÞ·¨½øÈ룡 mapID=%s,lineID=%s,curState=%s" % (mapID, lineID, curState))
|
return False
|
return True
|
|
## ɨµ´½á¹û
|
def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx):
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'MapID':mapID, 'LineID':lineID})
|
if ipyData:
|
fdeventID = ipyData.GetID()
|
PlayerFairyDomain.SetFairyDomainEventState(curPlayer, fdeventID, PlayerFairyDomain.FDEventState_Visited)
|
|
isPass = 1
|
_, bossID = FBCommon.GetFBLineRefreshNPC(ChConfig.Def_FBMapID_KillDevil)
|
jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, mapID, {bossID:1})
|
overDict = {FBCommon.Over_itemInfo:jsonItemList, FBCommon.Over_isSweep:1}
|
FBCommon.NotifyFBOver(curPlayer, mapID, lineID, isPass, overDict)
|
return
|