def precompute(self): minX = minY = 1000000 maxX = maxY = 0 for objID in client.db.keys(): if objID < OID_FREESTART: continue obj = client.get(objID, noUpdate = 1) if not (hasattr(obj, "type") and hasattr(obj, "x") and hasattr(obj, "y")): continue if obj.type in (T_SYSTEM,T_WORMHOLE): ownerID = OID_NONE if hasattr(obj, 'planets'): for planetID in obj.planets: planet = client.get(planetID, noUpdate = 1) owner = getattr(planet, 'owner', OID_NONE) if int(owner) != 0: ownerID = owner break color = res.getPlayerColor(ownerID) minX = min(minX, obj.x) minY = min(minY, obj.y) maxX = max(maxX, obj.x) maxY = max(maxY, obj.y) self._map.append((obj.oid, obj.x, obj.y, color)) self._minX = minX self._minY = minY zoomFactor = 0.05 #percent self._shiftX = int(self._width * zoomFactor) self._shiftY = int(self._height * zoomFactor) self._scaleX = float(self._width - 2 * self._shiftX) / float(maxX - minX) self._scaleY = float(self._height - 2 * self._shiftX) / float(maxY - minY) self._repaintMap = True
def precompute(self): galaxy_id = client.getPlayer().galaxy galaxy = client.get(galaxy_id, noUpdate=1) minX, maxX = galaxy.x - galaxy.radius, galaxy.x + galaxy.radius minY, maxY = galaxy.y - galaxy.radius, galaxy.y + galaxy.radius for objID in client.db.keys(): if objID < Const.OID_FREESTART: continue obj = client.get(objID, noUpdate=1) if not (hasattr(obj, "type")): continue if obj.type in (Const.T_SYSTEM, Const.T_WORMHOLE): ownerID = Const.OID_NONE if hasattr(obj, 'planets'): for planetID in obj.planets: planet = client.get(planetID, noUpdate=1) owner = getattr(planet, 'owner', Const.OID_NONE) if int(owner) != 0: ownerID = owner break color = res.getPlayerColor(ownerID) self._map.append((obj.oid, obj.x, obj.y, color)) self._minX = minX self._minY = minY zoomFactor = 0.05 #percent self._shiftX = int(self._width * zoomFactor) self._shiftY = int(self._height * zoomFactor) if ((maxX - minX) == 0): self._scaleX = 1 else: self._scaleX = float(self._width - 2 * self._shiftX) / float(maxX - minX) if ((maxY - minY) == 0): self._scaleY = 1 else: self._scaleY = float(self._height - 2 * self._shiftX) / float(maxY - minY) self._repaintMap = True
def precompute(self): system = client.get(self.systemID, noUpdate=1) self.unknown_mines = 0 self.my_mines = 0 if hasattr(system, 'hasmines'): if getattr(system, 'minefield', []): if len(system.minefield) > 0: self.my_mines = 1 if system.hasmines == 2: self.unknown_mines = 1 elif system.hasmines > 0: self.unknown_mines = 1 self.computeBuoy() self._starImg = None if hasattr(system, 'starClass'): self._starImg = res.getBigStarImg(system.starClass[1]) self._planetImgs = [] if hasattr(system, 'planets'): for planetID in system.planets: planet = client.get(planetID, noUpdate=1) if not planet: continue # image plType = getattr(planet, 'plType', 'X') img = res.getPlanetImg(plType, planet.oid + system.oid) #if plType != 'G': # ratio = planet.plDiameter / 19000.0 #else: # ratio = planet.plDiameter / 180000.0 #img2 = pygame.transform.scale(img, (int(ratio * img.get_width()), int(ratio * img.get_height()))) name = getattr(planet, 'name', res.getUnknownName()).split(' ')[-1] #rel = Const.REL_UNDEF if hasattr(planet, 'owner'): ownerID = planet.owner else: ownerID = Const.OID_NONE self._planetImgs.append( (planetID, img, name, res.getPlayerColor(ownerID)))
def precompute(self): galaxy_id = client.getPlayer().galaxy galaxy = client.get(galaxy_id, noUpdate = 1) minX, maxX = galaxy.x - galaxy.radius, galaxy.x + galaxy.radius minY, maxY = galaxy.y - galaxy.radius, galaxy.y + galaxy.radius for objID in client.db.keys(): if objID < Const.OID_FREESTART: continue obj = client.get(objID, noUpdate = 1) if not (hasattr(obj, "type")): continue if obj.type in (Const.T_SYSTEM,Const.T_WORMHOLE): ownerID = Const.OID_NONE if hasattr(obj, 'planets'): for planetID in obj.planets: planet = client.get(planetID, noUpdate = 1) owner = getattr(planet, 'owner', Const.OID_NONE) if int(owner) != 0: ownerID = owner break color = res.getPlayerColor(ownerID) self._map.append((obj.oid, obj.x, obj.y, color)) self._minX = minX self._minY = minY zoomFactor = 0.05 #percent self._shiftX = int(self._width * zoomFactor) self._shiftY = int(self._height * zoomFactor) if ((maxX - minX) == 0) : self._scaleX = 1 else : self._scaleX = float(self._width - 2 * self._shiftX) / float(maxX - minX) if ((maxY - minY) == 0) : self._scaleY = 1 else : self._scaleY = float(self._height - 2 * self._shiftX) / float(maxY - minY) self._repaintMap = True
def precompute(self): system = client.get(self.systemID, noUpdate=1) self.unknown_mines = 0 self.my_mines = 0 if hasattr(system, "hasmines"): if hasattr(system, "minefield"): if len(system.minefield) > 0: self.my_mines = 1 if system.hasmines == 2: self.unknown_mines = 1 elif system.hasmines > 0: self.unknown_mines = 1 self.computeBuoy() self._starImg = None if hasattr(system, "starClass"): self._starImg = res.getBigStarImg(system.starClass[1]) self._planetImgs = [] if hasattr(system, "planets"): for planetID in system.planets: planet = client.get(planetID, noUpdate=1) if not planet: continue # image plType = getattr(planet, "plType", "X") img = res.getPlanetImg(plType, planet.oid + system.oid) # if plType != 'G': # ratio = planet.plDiameter / 19000.0 # else: # ratio = planet.plDiameter / 180000.0 # img2 = pygame.transform.scale(img, (int(ratio * img.get_width()), int(ratio * img.get_height()))) name = getattr(planet, "name", res.getUnknownName()).split(" ")[-1] # rel = REL_UNDEF if hasattr(planet, "owner"): ownerID = planet.owner else: ownerID = OID_NONE self._planetImgs.append((planetID, img, name, res.getPlayerColor(ownerID)))
def precompute(self): minX = minY = 1000000 maxX = maxY = 0 for objID in client.db.keys(): if objID < OID_FREESTART: continue obj = client.get(objID, noUpdate=1) if not (hasattr(obj, "type") and hasattr(obj, "x") and hasattr(obj, "y")): continue if obj.type in (T_SYSTEM, T_WORMHOLE): ownerID = OID_NONE if hasattr(obj, 'planets'): for planetID in obj.planets: planet = client.get(planetID, noUpdate=1) owner = getattr(planet, 'owner', OID_NONE) if int(owner) != 0: ownerID = owner break color = res.getPlayerColor(ownerID) minX = min(minX, obj.x) minY = min(minY, obj.y) maxX = max(maxX, obj.x) maxY = max(maxY, obj.y) self._map.append((obj.oid, obj.x, obj.y, color)) self._minX = minX self._minY = minY zoomFactor = 0.05 #percent self._shiftX = int(self._width * zoomFactor) self._shiftY = int(self._height * zoomFactor) self._scaleX = float(self._width - 2 * self._shiftX) / float(maxX - minX) self._scaleY = float(self._height - 2 * self._shiftX) / float(maxY - minY) self._repaintMap = True