#!/usr/bin/python # -*- coding: GBK -*- # # @todo: # # @author: Alee # @date 2017-12-29 ÏÂÎç02:02:23 # @version 1.0 # # @note: ¹¹½¨¹¤¾ßÐèͬ²½´Ë±í # #--------------------------------------------------------------------- import CommFunc import logging # 1. ¹¹½¨±í class MapEventPoint(): def __init__(self): self.MapID = 0 self.NPCID = 0 self.LowLV = 0 self.HighestLV = 0 self.Defense = 0 def ReadFromList(self, curList): self.MapID = CommFunc.ToIntDef(curList[1]) self.NPCID = CommFunc.ToIntDef(curList[2]) self.LowLV = CommFunc.ToIntDef(curList[7]) self.HighestLV = CommFunc.ToIntDef(curList[8]) self.Defense = CommFunc.ToIntDef(curList[9]) return class NPCPoint(): def __init__(self): self.NPCID = 0 self.MapID = 0 self.Point = None return def ReadFromList(self, curList): self.NPCID = CommFunc.ToIntDef(curList[0]) self.MapID = CommFunc.ToIntDef(curList[1]) self.Point = eval(curList[2]) class MapEventPointMgr(): def __init__(self): self.__Table = [] self.__NPCPoint = {} def InitTable(self, tablePath): fileIO = open(tablePath, "r") lines = fileIO.readlines() linenum = 0 for line in lines: linenum += 1 # 1.×Ö¶ÎÀàÐÍ 2.×Ö¶ÎÃû 3.×ֶα¸×¢ if linenum <= 3: continue classObj = MapEventPoint() lineList = line.split('\t') classObj.ReadFromList(lineList) # Åųý·ÇÍÑ»ú¹ÒµØÍ¼ if classObj.MapID / 10000 != 1: continue self.__Table.append(classObj) def InitPointType(self, tablePath): fileIO = open(tablePath, "r") lines = fileIO.readlines() linenum = 0 for line in lines: linenum += 1 # 1.×Ö¶ÎÀàÐÍ 2.×Ö¶ÎÃû 3.×ֶα¸×¢ if linenum <= 3: continue classObj = NPCPoint() lineList = line.strip().split('\t') classObj.ReadFromList(lineList) self.__NPCPoint[classObj.NPCID] = classObj return def FindNPC(self, robot): lv = robot.GetPlayerInfo().GetPlayerLV() # ÒÔ·ÀÓùΪµÚÒ»Ìõ¼þ£¬È¡µ±Ç°µØÍ¼¹ÖÎïµÈ¼¶ÔÚÍæ¼ÒµÈ¼¶ÉÏÏÂ20¼¶µÄµØ·½ # ÒԵȼ¶HighestLVΪ±ê׼ȡ×î¸ß maxlv = 0 pointNPCID = 0 for point in self.__Table: if lv < point.LowLV: continue if point.MapID/10000 != 1: continue # È¡×î¸ßµÄ if maxlv < point.LowLV: maxlv = point.LowLV pointNPCID = point.NPCID npcPoint = self.__NPCPoint.get(pointNPCID, None) if not npcPoint: return tjgPoint = [npcPoint.MapID, npcPoint.Point, npcPoint.NPCID] logging.debug("¹Ò»úµã------%s"%str(tjgPoint)) robot.GetPlayerInfo().SetTJGPoint(tjgPoint) return __gMapEventPointReader = None def ReadMapEventPoint( PyBaseRoot): global __gMapEventPointReader if not __gMapEventPointReader: __gMapEventPointReader = MapEventPointMgr() __gMapEventPointReader.InitTable(PyBaseRoot + "Data\\MapEventPoint.txt") __gMapEventPointReader.InitPointType(PyBaseRoot + "Data\\MonsterRefreshPoint.txt") def GetMapEventPoint(): global __gMapEventPointReader return __gMapEventPointReader