Exemple #1
0
def get_kernel(
    world_map_source_path: typing.Optional[str] = None,
    tile_maps_folder_path: typing.Optional[str] = None,
    game_config_folder: typing.Optional[str] = None,
    server_db_path: str = "server.db",
) -> Kernel:
    world_map_source_raw = None

    if world_map_source_path:
        server_logger.info('Read world map source file "{}"'.format(world_map_source_path))
        with open(world_map_source_path, "r") as f:
            world_map_source_raw = f.read()

    if tile_maps_folder_path:
        server_logger.info('Start kernel with tile maps folder "{}"'.format(tile_maps_folder_path))

    loop = asyncio.get_event_loop()
    kernel = Kernel(
        world_map_source_raw,
        loop=loop,
        tile_maps_folder=tile_maps_folder_path,
        game_config_folder=game_config_folder,
        server_db_path=server_db_path,
    )

    kernel.init_server_db_session()
    return kernel
Exemple #2
0
def worldmapc_kernel(worldmapsourcec_txt, tmp_path, loop) -> Kernel:
    server_db_path = tmp_path / "server.db"
    kernel = Kernel(
        worldmapsourcec_txt,
        tile_maps_folder="tests/src/worldmapc_zones",
        game_config_folder="tests/src/game1",
        server_db_path=server_db_path,
        loop=loop,
    )
    kernel.init_server_db_session()
    return kernel
Exemple #3
0
def run(args: argparse.Namespace) -> None:
    os.makedirs(args.export_folder, exist_ok=True)

    with open(args.source, "r") as f:
        raw_world = f.read()

    kernel = Kernel(raw_world)
    world_map_source = WorldMapSource(kernel, raw_world)
    generator = FromWorldMapGenerator(
        kernel,
        default_map_width=args.map_widths,
        default_map_height=args.map_heights,
        filler_factory=SimpleFillerFactory(),
        world_map_source=world_map_source,
    )

    tile_maps = generator.generate()
    for tile_map in tile_maps:
        tile_map_str = "::GEO\n"

        for row in tile_map.source.geography.rows:
            for world_map_tile_type in row:
                char = tile_map.source.legend.get_str_with_type(
                    world_map_tile_type)
                tile_map_str += char

            tile_map_str += "\n"

        tile_map_file_path = os.path.join(
            args.export_folder, "{}-{}.txt".format(tile_map.row_i,
                                                   tile_map.col_i))
        with open(tile_map_file_path, "w+") as f:
            f.write(tile_map_str)
Exemple #4
0
def run(args: argparse.Namespace) -> None:
    def exit_(*args, **kwargs):
        raise urwid.ExitMainLoop()

    image_widget = ImageWidget(args.image, callback=exit_)
    client = HttpClient(server_address="http://127.0.0.1")

    loop = asyncio.get_event_loop()
    kernel = Kernel(loop=loop)
    controller = Controller(client=client, kernel=kernel, root_menu_mode="exit_only")
    controller.view.main_content_container.original_widget = image_widget

    controller.main()
Exemple #5
0
def run(args: argparse.Namespace) -> None:
    # Configure logging
    if args.debug:
        configure_logging(logging.DEBUG)
    else:
        configure_logging(logging.INFO)

    client = HttpClient(server_address=args.server_address)

    loop = asyncio.get_event_loop()
    kernel = Kernel(loop=loop)
    controller = Controller(client=client,
                            kernel=kernel,
                            disable_ws=args.disable_ws)

    gui_logger.info("Start gui")
    controller.main()
Exemple #6
0
def worldmapb2_kernel(worldmapsourceb2_txt, loop) -> Kernel:
    return Kernel(worldmapsourceb2_txt, loop=loop)
Exemple #7
0
def worldmapa_kernel(worldmapsourcea_txt, loop) -> Kernel:
    return Kernel(worldmapsourcea_txt, loop=loop)