#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_FairyTreasure # # @todo:çÎ翱¦²Ø # @author xdh # @date 2019-04-09 # @version 1.0 # ÏêϸÃèÊö: çÎ翱¦²Ø # #--------------------------------------------------------------------- #"""Version = 2019-04-09 11:00""" #--------------------------------------------------------------------- import FBCommon import GameWorld import IPY_GameWorld import NPCCustomRefresh import IpyGameDataPY import PlayerControl import PlayerFairyDomain import GameWorldProcess import ItemControler import NPCCommon import ChConfig import ChPlayer import EventReport import ChNPC import ItemCommon FBPlayerDict_CurStep = 'FBPlayerDict_CurStep' # µ±Ç°½×¶Î FBPlayerDict_StepState = 'FBPlayerDict_StepState' # ½×¶Î״̬ # ¸±±¾Í¨ÓÃÅäÖà ( Def_PrepareTime, # ×¼±¸Ê±¼ä£¬Ãë Def_FightTime, # Õ½¶·Ê±¼ä£¬Ãë Def_LeaveTime, # Í˳öʱ¼ä, Ãë Def_CollectTime, # ²É¼¯Ê±¼ä, Ãë Def_RefreshBossMark, # Ë¢¹Ö±êʶµã Def_RefreshBossMark1, # Ë¢¹Ö±êʶµã ) = range(6) #µ±Ç°¸±±¾µØÍ¼µÄ״̬ ( FB_Step_Open, # ¸±±¾¿ªÆô FB_Step_Prepare, # ¸±±¾µÈ´ý FB_Step_Fighting, # ¸±±¾½øÐÐÖÐ #FB_Step_Collect, # ¸±±¾²É¼¯ÖÐ #FB_Step_PickItem, # ʰȡÎïÆ·ÖÐ FB_Step_Over, # ¸±±¾½áÊø FB_Step_Close, # ¸±±¾¹Ø±Õ ) = range(5) def __GetFBTimeCfg(lineID=0): if not lineID: lineID = FBCommon.GetFBPropertyMark() return FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_FairyTreasure, lineID) ## ÊÇ·ñ¿É½øÈë # @param curPlayer # @param mapID µØÍ¼ID # @param lineId ·ÖÏßID # @param tick # @return ÊÇ·ñ¿É½øÈë def OnEnterFBEvent(curPlayer, mapID, lineId, tick): ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'MapID':mapID, 'LineID':lineId}) if not ipyData: return fdeventID = ipyData.GetID() if not PlayerFairyDomain.SetFairyDomainEventState(curPlayer, fdeventID, PlayerFairyDomain.FDEventState_Visiting): return return True ##¸±±¾Íæ¼Ò½øÈëµã # @param curPlayer Íæ¼ÒʵÀý # @param mapID µØÍ¼ID # @param lineId ·ÖÏßID # @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢ # @param tick ʱ¼ä´Á # @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡) def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick): return ipyEnterPosInfo ## ÊÇ·ñ¿ÉÒÔ½øÈë # @param ask ÇëÇóÐÅÏ¢ # @param tick # @return »Ø¸´ÊÇ·ñͨ¹ýÇëÇó def OnChangeMapAsk(ask, tick): return IPY_GameWorld.cmeAccept ## ½ø¸±±¾ # @param curPlayer # @param tick # @return None def DoEnterFB(curPlayer, tick): PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 3) mapID = GameWorld.GetMap().GetMapID() mapID = FBCommon.GetRecordMapID(mapID) gameFB = GameWorld.GetGameFB() lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqFBFuncLine) playerID = curPlayer.GetID() hadDelTicket = FBCommon.GetHadDelTicket(curPlayer) if not hadDelTicket: FBCommon.SetHadDelTicket(curPlayer) FBCommon.SetFBPropertyMark(lineID) boxIDList = FBCommon.GetFBLineRefreshNPC(mapID, lineID)[1:] npcCnt = len(boxIDList) NPCCustomRefresh.SetNPCRefresh(__GetFBTimeCfg()[Def_RefreshBossMark1], [[npcID,1] for npcID in boxIDList], npcCnt, npcCnt) if gameFB.GetGameFBDictByKey(FBPlayerDict_CurStep) == 0: FBCommon.SyncDynamicBarrierState(IpyGameDataPY.GetFuncEvalCfg('HazyTreasure'), 1, curPlayer) # ×¼±¸ÆÚ¼äÓж¯Ì¬Õϰ­µã if not hadDelTicket \ and IpyGameDataPY.GetIpyGameDataByCondition("NPCShow", {"MapID":mapID, "LineID":lineID}, isLogNone=False): GameWorld.DebugLog("¸Õ½øÈëʱ²»Ö±½Ó¿ªÊ¼£¬ÐèµÈǰ¶Ë֪ͨ¿ªÊ¼²Å¿ªÊ¼!", playerID) # µôÏßÖØÉÏÇ¿ÖÆ¿ªÊ¼ return fbStep = gameFB.GetFBStep() if fbStep < FB_Step_Prepare: FBCommon.SetFBStep(FB_Step_Prepare, tick) if fbStep <= FB_Step_Prepare: notify_tick = __GetFBTimeCfg(lineID)[Def_PrepareTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick()) curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True) elif fbStep == FB_Step_Fighting: notify_tick = __GetFBTimeCfg(lineID)[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick()) curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True) else: PlayerControl.PlayerLeaveFB(curPlayer) return DoFBHelp(curPlayer, tick) return ## ¿Í»§¶Ë·¢ËÍ¿ªÊ¼¸±±¾ def OnClientStartFB(curPlayer, tick): gameFB = GameWorld.GetGameFB() fbStep = gameFB.GetFBStep() if fbStep >= FB_Step_Prepare: GameWorld.ErrLog("ǰ¶ËÇëÇóÕýʽ¿ªÊ¼¸±±¾, µ«¸±±¾ÒѾ­¿ªÊ¼ÁË£¬²»¿ÉÖØ¸´¿ªÊ¼!", curPlayer.GetPlayerID()) return lineID = FBCommon.GetFBPropertyMark() GameWorld.DebugLog("ǰ¶Ë³¡¾°ÐãÒѲ¥·ÅÍê±Ï£¬ÇëÇóÕýʽ¿ªÊ¼¸±±¾!lineID=%s" % lineID, curPlayer.GetPlayerID()) FBCommon.SetFBStep(FB_Step_Prepare, tick) notify_tick = __GetFBTimeCfg(lineID)[Def_PrepareTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick()) curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, max(notify_tick, 0), True) DoFBHelp(curPlayer, tick) return ## ¸±±¾Ê±¼äµ½¹Ø±Õ # @param tick µ±Ç°Ê±¼ä # @return None # @remarks º¯ÊýÏêϸ˵Ã÷. def OnCloseFB(tick): return ## »ñµÃ¸±±¾°ïÖúÐÅÏ¢ # @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£© # @param tick µ±Ç°Ê±¼ä # @return None def DoFBHelp(curPlayer, tick): gameFB = GameWorld.GetGameFB() curStep = gameFB.GetGameFBDictByKey(FBPlayerDict_CurStep) + 1 helpDict = {FBCommon.Help_step:curStep, FBCommon.Help_npcTotal:gameFB.GetGameFBDictByKey(FBPlayerDict_StepState)} GameWorld.DebugLog("DoFBHelp %s" % str(helpDict)) FBCommon.Notify_FBHelp(curPlayer, helpDict) return ##Íæ¼ÒÍ˳ö¸±±¾. # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå # @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾. def DoExitFB(curPlayer, tick): PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default) # Íæ¼ÒÍ˳öĬÈϹرո±±¾ #GameWorldProcess.CloseFB(tick) return ##¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷ # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks ¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷ def OnProcess(tick): gameFB = GameWorld.GetGameFB() fbStep = gameFB.GetFBStep() # ¸±±¾×¼±¸ if fbStep == FB_Step_Prepare: __DoLogic_FB_Prepare(tick) # ¸±±¾½øÐÐÖÐ elif fbStep == FB_Step_Fighting: __DoLogic_FB_Fighting(tick) # # ¸±±¾Ê°È¡ÖÐ # elif fbStep == FB_Step_PickItem: # __DoLogic_FB_PickItem(tick) # ¸±±¾½áÊø elif fbStep == FB_Step_Over: __DoLogic_FB_Over(tick) return ##Õ½¶·×¼±¸Ê±¼ä # @param tick ʱÖÓ # @return ÎÞÒâÒå def __DoLogic_FB_Prepare(tick): gameFB = GameWorld.GetGameFB() mapID = GameWorld.GetMap().GetMapID() lineID = FBCommon.GetFBPropertyMark() trialCfg = __GetFBTimeCfg(lineID) if tick - gameFB.GetFBStepTick() < trialCfg[Def_PrepareTime] * 1000: return FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, trialCfg[Def_FightTime] * 1000) bossID = FBCommon.GetFBLineRefreshNPC(mapID, lineID)[0] NPCCustomRefresh.SetNPCRefresh(trialCfg[Def_RefreshBossMark], [bossID]) #תÈëÕ½¶· FBCommon.SetFBStep(FB_Step_Fighting, tick) return ##Õ½¶·Ê±¼ä # @param tick ʱÖÓ # @return ÎÞÒâÒå def __DoLogic_FB_Fighting(tick): gameFB = GameWorld.GetGameFB() #ÅжÏʱ¼ä½áÊø if tick - gameFB.GetFBStepTick() < __GetFBTimeCfg()[Def_FightTime] * 1000: return #ÓÎÏ·½áÊø FBCommon.SetFBStep(FB_Step_Over, tick) return ##¸±±¾¹Ø±ÕÖÐ # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks ¸±±¾¹Ø±ÕÖÐ def __DoLogic_FB_Over(tick): # ¼ä¸ôδµ½ if tick - GameWorld.GetGameFB().GetFBStepTick() < __GetFBTimeCfg()[Def_LeaveTime] * 1000: return #¸±±¾¹Ø±Õ GameWorldProcess.CloseFB(tick) FBCommon.SetFBStep(FB_Step_Close, tick) return ## ɱ¹Ö # @param curPlayer # @param curNPC ±»É±µÄ¹Ö # @param tick # @return None def DoFB_Player_KillNPC(curPlayer, curNPC, tick): mapID = GameWorld.GetMap().GetMapID() lineID = FBCommon.GetFBPropertyMark() bossID = FBCommon.GetFBLineRefreshNPC(mapID, lineID)[0] if bossID != curNPC.GetNPCID(): return #Ë¢±¦Ïä½øÈë²É¼¯½×¶Î GameWorld.GetGameFB().SetGameFBDict(FBPlayerDict_CurStep, 1) DoFBHelp(curPlayer, tick) FBCommon.SyncDynamicBarrierState(IpyGameDataPY.GetFuncEvalCfg('HazyTreasure'), 0, curPlayer) #ÌØÐ§NPCÏûʧ FBCommon.ClearFBNPCEx(FBCommon.GetFBLineRefreshNPC(mapID, lineID)[2:]) #FBCommon.SetFBStep(FB_Step_Collect, tick) #NPCCustomRefresh.SetNPCRefresh(__GetFBTimeCfg()[Def_RefreshBossMark], [boxID]) return ## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼­ÓÉÍâ²ã¾ö¶¨ # @param attacker ¹¥»÷·½ # @param defender ·ÀÊØ·½ # @return bool def CheckCanAttackTagObjInFB(attacker, defender): gameFB = GameWorld.GetGameFB() if gameFB.GetFBStep() != FB_Step_Fighting: return False return True ##ÊÇ·ñ¿ÉÒԲɼ¯ # @param curPlayer Íæ¼ÒʵÀý # @param curNPC NPCʵÀý # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks def OnCanCollect(curPlayer, curNPC, tick): gameFB = GameWorld.GetGameFB() curStep = gameFB.GetGameFBDictByKey(FBPlayerDict_CurStep) return curStep == 1 ##¸±±¾ÖÐ,²É¼¯ÎïÐèÒªLoadingʱ¼ä. # @param curPlayer Íæ¼ÒʵÀý # @param curNPC NPCʵÀý # @return ·µ»ØÖµ, Loadingʱ¼ä # @remarks ¸±±¾ÖÐ,²É¼¯ÎïÐèÒªLoadingʱ¼ä def GetFBPrepareTime(curPlayer, curNPC): return __GetFBTimeCfg()[Def_CollectTime] * 1000 ##Íæ¼ÒÊÕ¼¯³É¹¦(Ëþ, Æì) # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks def OnCollectOK(curPlayer, npcID, tick): playerID = curPlayer.GetID() tagObj = curPlayer.GetActionObj() if not tagObj: return if tagObj.GetGameObjType() != IPY_GameWorld.gotNPC: return curNPC = GameWorld.GetNPCManager().GetNPCByIndex(tagObj.GetIndex()) if not curNPC: return dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY() ChNPC.OnCollectEnd(curPlayer, curNPC) GameWorld.DebugLog(' ²É¼¯³É¹¦£¡', playerID) GameWorld.GetGameFB().SetGameFBDict(FBPlayerDict_StepState, 1) DoFBHelp(curPlayer, 0) #µôÂ䏸½±Àø DoFairyTreasureOver(curPlayer, tick, dropPosX, dropPosY) return def DoFairyTreasureOver(curPlayer, tick, dropPosX, dropPosY): #[[(4000,[141,1,1])],[(4000,[141,1,1])]] FBCommon.SetFBStep(FB_Step_Over, tick) lineID = FBCommon.GetFBPropertyMark() ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomain', {'MapID':ChConfig.Def_FBMapID_FairyTreasure, 'LineID':lineID}) fdeventID = ipyData.GetID() giveItemList = PlayerFairyDomain.GetFairyAppointAward(curPlayer, fdeventID) if not giveItemList: awardCfg = FBCommon.GetFBLineReward(ChConfig.Def_FBMapID_FairyTreasure, lineID) curAlchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) giveItemList = [] dropItemList = [] for awardRateList in awardCfg: newItemInfoList = [] for itemInfo in awardRateList: itemID = itemInfo[1][0] itemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not itemData: return if curAlchemyLV < ItemCommon.GetItemClassLV(itemData) - 1: #µ¤Â¯µÈ¼¶²»×ã continue newItemInfoList.append(itemInfo) if not newItemInfoList: continue randomitem = GameWorld.GetResultByWeightList(newItemInfoList) giveItemList.append(randomitem) for _ in xrange(randomitem[1]): dropItemList.append([randomitem[0],1,randomitem[2]]) if giveItemList: NPCCommon.DoVirtualItemDrop(curPlayer, dropItemList, dropPosX, dropPosY) ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList) leaveTick = __GetFBTimeCfg(lineID)[Def_LeaveTime] * 1000 curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, leaveTick, True) overDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)} FBCommon.NotifyFBOver(curPlayer, ChConfig.Def_FBMapID_FairyTreasure, lineID, 1, overDict) PlayerFairyDomain.SetFairyDomainEventState(curPlayer, fdeventID, PlayerFairyDomain.FDEventState_Visited) return ## ÊÇ·ñ¸±±¾¸´»î # @param None # @return ÊÇ·ñ¸±±¾¸´»î def OnPlayerReborn(): return True ## ¸±±¾ÐÐΪ # @param curPlayer Íæ¼Ò # @param actionType ÐÐΪÀàÐÍ # @param actionInfo ÐÐΪÐÅÏ¢ # @param tick µ±Ç°Ê±¼ä # @return None def DoFBAction(curPlayer, actionType, actionInfo, tick): return