def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) # communicate via stdout. Sometimes the process seems to print more information, therefore # we add markers around our data so it's easier for the caller to get to the data. args = (location, world, Minimap.COLORS['island'], Minimap.COLORS['water']) data = [(x, y, r, g, b) for (x, y), (r, g, b) in iter_minimap_points(*args)] print('DATA', json.dumps(data), 'ENDDATA')
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) # communicate via stdout. Sometimes the process seems to print more information, therefore # we add markers around our data so it's easier for the caller to get to the data. args = (location, world, Minimap.COLORS['island'], Minimap.COLORS['water']) data = [(x, y, r, g, b) for (x, y), (r, g, b) in iter_minimap_points_colors(*args)] print('DATA', json.dumps(data), 'ENDDATA')
def act(self, player_name, player_color): self.end() map_file = generate_random_map(*self._get_map_parameters()) options = StartGameOptions.create_start_map(map_file) options.set_human_data(player_name, player_color) options.ai_players = self._aidata.get_ai_players() options.trader_enabled = self._game_settings.free_trader options.pirate_enabled = self._game_settings.pirates options.disasters_enabled = self._game_settings.disasters options.natural_resource_multiplier = self._game_settings.natural_resource_multiplier horizons.main.start_singleplayer(options)
def act(self, player_name, player_color): self.end() map_file = generate_random_map(*self._get_map_parameters()) options = StartGameOptions.create_start_map(map_file) options.set_human_data(player_name, player_color) options.ai_players = self._aidata.get_ai_players() options.trader_enabled = self._game_settings.free_trader options.pirate_enabled = self._game_settings.pirates options.disasters_enabled = self._game_settings.disasters options.natural_resource_multiplier = self._game_settings.natural_resource_multiplier horizons.main.start_singleplayer(options)
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.ext.dummy import Dummy from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) minimap = Minimap( location, session=None, view=None, world=world, targetrenderer=Dummy(), imagemanager=Dummy(), cam_border=False, use_rotation=False, preview=True) # communicate via stdout print minimap.dump_data()
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.ext.dummy import Dummy from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) minimap = Minimap( location, session=None, view=None, world=world, targetrenderer=Dummy(), imagemanager=Dummy(), cam_border=False, use_rotation=False, preview=True) # communicate via stdout print minimap.dump_data()
def _generate_random_map(cls, parameters): return generate_random_map(*parameters)
def _generate_random_map(cls, parameters): return generate_random_map( *parameters )