#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_IceLode # # @todo:±ù¾§¿óÂö # @author xdh # @date 2017-9-14 # @version 1.0 # # ÏêϸÃèÊö: ±ù¾§¿óÂö # #------------------------------------------------------------------------------- #"""Version = 2017-09-14 15:30""" #------------------------------------------------------------------------------- import FBCommon import GameWorld import IPY_GameWorld import NPCCustomRefresh import GameWorldProcess import PlayerControl import ShareDefine import IpyGameDataPY import PyGameData import ChConfig import NPCCommon import ItemCommon import EventReport import random import math #---¸±±¾ÅäÖöÔÓ¦keyÖµ--- ( Def_PrepareTime, # ¸±±¾×¼±¸Ê±¼ä(Ãë) Def_FightTime, # ½øÐÐʱ¼ä(Ãë) Def_PickTime, # ʰȡʱ¼ä(Ãë)£¨°üº¬Í˳öʱ¼ä£© Def_LeaveTime, # Í˳öʱ¼ä(Ãë) ) = range(4) #---¸±±¾·ÖÏßÅäÖÃË÷ÒýÐÅÏ¢--- ( Def_RefreshMark, # Ë¢¹Ö±êʶµã DL_NPCID, # NPCID DL_TotalNPCCnt, # ÀÛ¼ÆË¢NPC×ܸöÊý DL_ScreenMaxNPC, # ͬʱ´æÔÚNPCÊý ) = range(4) #µ±Ç°¸±±¾µØÍ¼µÄ״̬ ( FB_Step_Open, # ¸±±¾¿ªÆô FB_Step_Prepare, # ¸±±¾µÈ´ý FB_Step_Fighting, # ¸±±¾½øÐÐÖÐ FB_Step_PickItem, # ʰȡÎïÆ·ÖÐ FB_Step_Over, # ¸±±¾½áÊø FB_Step_Close, # ¸±±¾¹Ø±Õ ) = range(6) FBPlayerDict_TotalPoint = 'FBPlayerDict_TotalPoint' # »ñµÃµÄ×ÜÅ­ÆøÖµ FBPlayerDict_CostTime = 'FBPlayerDict_CostTime' #ͨ¹ØÊ±¼ä FBPlayerDict_TotalExp = 'FBPlayerDict_TotalExp' # »ñµÃµÄ×ܾ­Ñé FBPlayerDict_TotalExpPoint = 'FBPlayerDict_TotalExpPoint' # »ñµÃµÄ×ܾ­Ñéµã ##---»ñµÃ¸±±¾·ÖÏßÅäÖÃ--- # @param None # @return ÅäÖÃÐÅÏ¢ def GetIceLodeNPCCfg(): return FBCommon.GetFBLineRefreshNPC(GameWorld.GetMap().GetMapID()) def GetPointByNPCID(npcid): '''ͨ¹ýNPCID»ñÈ¡¶ÔÓ¦µÄ»ý·Ö''' npcPointDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeNeedPoint', 2, {}) return npcPointDict.get(npcid, 0) ## OnDay´¦Àí # @param curPlayer # @return None def IceLodeOnDay(curPlayer): return ## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë # @param curPlayer Íæ¼ÒʵÀý # @param mapID µØÍ¼ID # @param lineID Ïß·id # @param tick ʱ¼ä´Á # @return ²¼¶ûÖµ def OnEnterFBEvent(curPlayer, mapID, lineID, tick): 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:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk) # @param tick:ʱ¼ä´Á # @return IPY_GameWorld.cme ö¾Ù def OnChangeMapAsk(ask, tick): return IPY_GameWorld.cmeAccept ## ½ø¸±±¾ # @param curPlayer # @param tick # @return None def DoEnterFB(curPlayer, tick): playerID = curPlayer.GetPlayerID() GameWorld.DebugLog("DoEnterFB...", playerID) mapID = GameWorld.GetGameWorld().GetMapID() gameFB = GameWorld.GetGameFB() hadDelTicket = FBCommon.GetHadDelTicket(curPlayer) if not hadDelTicket: PyGameData.g_fbPickUpItemDict.pop(playerID, 0) GameWorld.DebugLog("DoEnterFB ¿Û³ýÈ볡ȯ£¬ÖØÖÃÐÅÏ¢£¡") delResult = FBCommon.DelFBEnterTicket(curPlayer, mapID) isOK = delResult[0] #hasBind = delResult[1] if not isOK: PlayerControl.PlayerLeaveFB(curPlayer) return FBCommon.SetHadDelTicket(curPlayer) FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_IceLode) FBCommon.SetFBStep(FB_Step_Prepare, tick) EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start) fbStep = gameFB.GetFBStep() if fbStep <= FB_Step_Prepare: mapID = GameWorld.GetMap().GetMapID() notify_tick = FBCommon.GetFBLineStepTime(mapID)[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_Fighting: mapID = GameWorld.GetMap().GetMapID() notify_tick = FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick()) curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True) DoFBHelp(curPlayer, tick) return ##Íæ¼ÒÍ˳ö¸±±¾ # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ÎÞÒâÒå def DoExitFB(curPlayer, tick): return ##Íæ¼ÒÖ÷¶¯À뿪¸±±¾. # @param curPlayer Íæ¼ÒʵÀý # @param tick ʱ¼ä´Á # @return ·µ»ØÖµÎÞÒâÒå def DoPlayerLeaveFB(curPlayer, tick): 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: 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) else: PyGameData.g_fbPickUpItemDict[playerID] = [jsonItem] isItemAllPickUp = (GameWorld.GetMapItemManager().GetMapItemCount() <= 1) if isItemAllPickUp and GameWorld.GetGameFB().GetFBStep() == FB_Step_PickItem: __DoIceLodeOver(True) #GameWorld.Log('PyGameData.g_fbPickUpItemDict=%s'%PyGameData.g_fbPickUpItemDict) return ## »ñµÃ¸±±¾°ïÖúÐÅÏ¢ # @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£© # @param tick µ±Ç°Ê±¼ä # @return None def DoFBHelp(curPlayer, tick): gameFB = GameWorld.GetGameFB() # »ñµÃ¸±±¾ÐÅÏ¢ totalPoint = gameFB.GetGameFBDictByKey(FBPlayerDict_TotalPoint) #¸±±¾°ïÖú helpDict = {FBCommon.Help_score:totalPoint} GameWorld.DebugLog("DoFBHelp %s" % str(helpDict)) FBCommon.Notify_FBHelp(curPlayer, helpDict) return ##---¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷--- # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks ¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷ def OnProcess(tick): fbStep = GameWorld.GetGameFB().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() stepTimeCfg = FBCommon.GetFBLineStepTime(mapID) # ¼ä¸ôδµ½ if tick - GameWorld.GetGameFB().GetFBStepTick() < stepTimeCfg[Def_PrepareTime] * 1000: return # ÉèÖÿªÊ¼Ë¢¹Ö npcCfg = GetIceLodeNPCCfg() for npcInfo in npcCfg: npcid = npcInfo[DL_NPCID] maxCnt = npcInfo[DL_ScreenMaxNPC] totalMaxCnt = npcInfo[DL_TotalNPCCnt] NPCCustomRefresh.SetNPCRefresh(npcInfo[Def_RefreshMark], [npcid], maxCnt, totalMaxCnt) NPCCustomRefresh.ProcessAllNPCRefresh(tick) # Á¢¼´³ö·¢Ò»´Î±êʶµãˢР# ¸±±¾¿ªÊ¼ FBCommon.SetFBStep(FB_Step_Fighting, tick) FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttTowerTake, stepTimeCfg[Def_FightTime] * 1000) return ## ¸±±¾½øÐÐÖÐ # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå def __DoLogic_FB_Fighting(tick): # ¼ä¸ôδµ½ mapID = GameWorld.GetMap().GetMapID() if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_FightTime] * 1000: return __DoIceLodeOver(False) return ## ¸±±¾Ê°È¡ # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå def __DoLogic_FB_PickItem(tick): # ¼ä¸ôδµ½ mapID = GameWorld.GetMap().GetMapID() if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000: return #¸±±¾¹Ø±Õ GameWorldProcess.CloseFB(tick) FBCommon.SetFBStep(FB_Step_Close, tick) return ##¸±±¾¹Ø±ÕÖÐ # @param tick:ʱ¼ä´Á # @return ÎÞÒâÒå # @remarks ¸±±¾¹Ø±ÕÖÐ def __DoLogic_FB_Over(tick): # ¼ä¸ôδµ½ mapID = GameWorld.GetMap().GetMapID() if tick - GameWorld.GetGameFB().GetFBStepTick() < FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000: return #¸±±¾¹Ø±Õ GameWorldProcess.CloseFB(tick) FBCommon.SetFBStep(FB_Step_Close, tick) return ## »ñµÃ¾­Ñé # @param curPlayer µ±Ç°Íæ¼Ò # @param addExp »ñµÃµÄ¾­Ñé # @param expViewType ¾­ÑéÀàÐÍ # @return True or False def OnGetExp(curPlayer, addExp, expViewType): if expViewType != ShareDefine.Def_ViewExpType_KillNPC: return playerID = curPlayer.GetID() gameFB = GameWorld.GetGameFB() exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp) expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint) totalExp = expPoint * ChConfig.Def_PerPointValue + exp updTotalExp = totalExp + addExp updExp = updTotalExp % ChConfig.Def_PerPointValue updExpPoint = updTotalExp / ChConfig.Def_PerPointValue gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExp, updExp) gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_TotalExpPoint, updExpPoint) GameWorld.DebugLog("OnGetExp() totalExp=%s,addExp=%s,updTotalExp=%s" % (totalExp, addExp, updTotalExp), playerID) 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 ±»É±µÄ¹Ö # @param tick µ±Ç°Ê±¼ä # @return None def DoFB_Player_KillNPC(curPlayer, curNPC, tick): gameFB = GameWorld.GetGameFB() npcid = curNPC.GetNPCID() addPoint = GetPointByNPCID(npcid) if not addPoint: return totalPoint = gameFB.GetGameFBDictByKey(FBPlayerDict_TotalPoint) maxPoint = IpyGameDataPY.GetFuncCfg('IceLodeNeedPoint') updPoint = min(totalPoint + addPoint, maxPoint) gameFB.SetGameFBDict(FBPlayerDict_TotalPoint, updPoint) if updPoint >= maxPoint: costTime = tick - GameWorld.GetGameFB().GetFBStepTick() gameFB.SetGameFBDict(FBPlayerDict_CostTime, costTime) FBCommon.SetFBStep(FB_Step_PickItem, tick) mapID = GameWorld.GetMap().GetMapID() curPlayer.Sync_TimeTick(ChConfig.tttPickupItem, 0, FBCommon.GetFBLineStepTime(mapID)[Def_PickTime] * 1000, True) FBCommon.ClearFBNPC() npcCfg = GetIceLodeNPCCfg() for npcInfo in npcCfg: NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick) #__DoIceLodeOver(True) DoFBHelp(curPlayer, tick) return ## ÊÇ·ñ¸±±¾¸´»î # @param None # @return ÊÇ·ñ¸±±¾¸´»î def OnPlayerReborn(): return True ## ¸±±¾½áÊø´¦Àí def __DoIceLodeOver(isPass): gameFB = GameWorld.GetGameFB() if gameFB.GetFBStep() == FB_Step_Over: return tick = GameWorld.GetGameWorld().GetTick() curPlayer = None playerManager = GameWorld.GetMapCopyPlayerManager() if playerManager.GetPlayerCount() > 0: curPlayer = playerManager.GetPlayerByIndex(0) if not curPlayer: GameWorldProcess.CloseFB(tick) return playerID = curPlayer.GetPlayerID() mapID = ChConfig.Def_FBMapID_IceLode hasPass = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, 0, False, [mapID]) if isPass and not hasPass: GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, 0, 1, False, [mapID]) FBCommon.Sync_FBPlayerFBInfoData(curPlayer, mapID) # ͬ²½ÐÅÏ¢ # ¼Ç¼×îºóÒ»´ÎÊÖ´ò»ñµÃµÄ×ܾ­Ñé exp = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExp) expPoint = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_TotalExpPoint) totalExp = expPoint * ChConfig.Def_PerPointValue + exp costTime = gameFB.GetGameFBDictByKey(FBPlayerDict_CostTime) if not costTime: costTime = tick - GameWorld.GetGameFB().GetFBStepTick() jsonItemList = PyGameData.g_fbPickUpItemDict.get(playerID, []) # ֪ͨ½á¹û __SendIceLodeOverInfo(curPlayer, {FBCommon.Over_isPass:int(isPass),FBCommon.Over_exp:totalExp, FBCommon.Over_costTime:costTime, FBCommon.Over_itemInfo:jsonItemList}) # ½øÈëÀ뿪½×¶Î FBCommon.SetFBStep(FB_Step_Over, tick) FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttLeaveMap, FBCommon.GetFBLineStepTime(mapID)[Def_LeaveTime] * 1000) # Çå¹Ö£¬¹Ø±ÕË¢¹Ö FBCommon.ClearFBNPC() npcCfg = GetIceLodeNPCCfg() for npcInfo in npcCfg: NPCCustomRefresh.CloseNPCRefresh(npcInfo[Def_RefreshMark], tick) return ## ·¢ËÍÌôÕ½½á¹ûÐÅÏ¢£¬É¨µ´½á¹ûͨÓà def __SendIceLodeOverInfo(curPlayer, overDict): overDict[FBCommon.Over_dataMapID] = ChConfig.Def_FBMapID_IceLode GameWorld.DebugLog("__SendIceLodeOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID()) FBCommon.Notify_FB_Over(curPlayer, overDict) return ## ¸±±¾ÐÐΪ # @param curPlayer Íæ¼Ò # @param actionType ÐÐΪÀàÐÍ # @param actionInfo ÐÐΪÐÅÏ¢ # @param tick µ±Ç°Ê±¼ä # @return None def DoFBAction(curPlayer, actionType, actionInfo, tick): return ## ¿É·ñɨµ´ def OnPlayerFBSweepAsk(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx): playerID = curPlayer.GetPlayerID() star = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, 0, False, [mapID]) # ÊÇ·ñ¹ý¹Ø¹ý, ɨµ´ÐǼ¶ÏÞÖÆÔÝʱ¿Í»§¶ËÏÞÖÆ£¬ÕâÀïÖ»ÅжÏÊÇ·ñ¹ý¹Ø if star <= 0: GameWorld.DebugLog("IceLode µ±Ç°ËùÊôÏß·δ¹ý¹Ø¹ý£¬²»¿Éɨµ´£¡lineID=%s,star=%s" % (0, star), playerID) return False return True ## ɨµ´½á¹û def OnPlayerFBSweepResult(curPlayer, mapID, lineID, sweepCnt, isFinish, dataEx): npcCountDict = {} iceLodeSweepDict = IpyGameDataPY.GetFuncEvalCfg('IceLodeSweep') for npcID, count in iceLodeSweepDict.items(): npcCountDict[npcID] = count * sweepCnt exp_rate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Sweep) jsonItemList, totalExp, totalMoney = NPCCommon.GiveKillNPCDropPrize(curPlayer, mapID, npcCountDict, exp_rate) GameWorld.DebugLog("ɨµ´½±Àø: ´ÎÊý=%s,totalExp=%s,totalMoney=%s,jsonItemList=%s" % (sweepCnt, totalExp, totalMoney, jsonItemList)) overDict = {FBCommon.Over_isPass:1, FBCommon.Over_exp:totalExp, FBCommon.Over_isSweep:1, FBCommon.Over_itemInfo:jsonItemList} __SendIceLodeOverInfo(curPlayer, overDict) for _ in xrange(sweepCnt): EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_IceLode, 0, ChConfig.CME_Log_Start) return True