コード例 #1
0
def apply_layout(
    description: LayoutDescription,
    players_config: PlayersConfiguration,
    cosmetic_patches: CosmeticPatches,
    backup_files_path: Optional[Path],
    progress_update: ProgressUpdateCallable,
    game_root: Path,
):
    """
    Applies the modifications listed in the given LayoutDescription to the game in game_root.
    :param description:
    :param players_config:
    :param cosmetic_patches:
    :param game_root:
    :param backup_files_path: Path to use as pak backup, to remove/add menu mod.
    :param progress_update:
    :return:
    """
    description.save_to_file(
        game_root.joinpath("files",
                           f"randovania.{description.file_extension()}"))

    apply_patcher_file(
        game_root, backup_files_path,
        patcher_file.create_patcher_file(description, players_config,
                                         cosmetic_patches),
        description.all_patches[players_config.player_index].game_specific,
        progress_update)
コード例 #2
0
def export_layout(
    layout: LayoutDescription,
    options: Options,
):
    """
    Creates a seed log file for the given layout and saves it to the configured path
    :param layout:
    :param options:
    :return:
    """

    output_json = options.output_directory.joinpath("{}.json".format(
        _output_name_for(layout)))

    if debug.debug_level() > 0:
        patcher = options.output_directory.joinpath("{}-patcher.json".format(
            _output_name_for(layout)))
        with patcher.open("w") as out_file:
            json.dump(patcher_file.create_patcher_file(
                layout, options.cosmetic_patches),
                      out_file,
                      indent=4,
                      separators=(',', ': '))

    # Save the layout to a file
    layout.save_to_file(output_json)
コード例 #3
0
def persist_layout(data_dir: Path, description: LayoutDescription):
    history_dir = data_dir.joinpath("game_history")
    history_dir.mkdir(parents=True, exist_ok=True)

    date_format = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
    file_path = history_dir.joinpath(
        f"{date_format}-{description.shareable_word_hash}.{description.file_extension()}")
    description.save_to_file(file_path)
コード例 #4
0
def persist_layout(history_dir: Path, description: LayoutDescription):
    history_dir.mkdir(parents=True, exist_ok=True)

    games = "-".join(sorted(game.short_name for game in description.all_games))

    date_format = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
    file_path = history_dir.joinpath(
        f"{date_format}_{games}_{description.shareable_word_hash}.{description.file_extension()}")
    description.save_to_file(file_path)
コード例 #5
0
def export_layout(
    layout: LayoutDescription,
    options: Options,
):
    """
    Creates a seed log file for the given layout and saves it to the configured path
    :param layout:
    :param options:
    :return:
    """

    output_json = options.output_directory.joinpath("{}.json".format(
        _output_name_for(layout)))

    # Save the layout to a file
    layout.save_to_file(output_json)
コード例 #6
0
def apply_layout(description: LayoutDescription,
                 cosmetic_patches: CosmeticPatches, backup_files_path: Path,
                 progress_update: ProgressUpdateCallable, game_root: Path):
    """
    Applies the modifications listed in the given LayoutDescription to the game in game_root.
    :param cosmetic_patches:
    :param description:
    :param game_root:
    :param backup_files_path: Path to use as pak backup, to remove/add menu mod.
    :param progress_update:
    :return:
    """

    patcher_configuration = description.permalink.patcher_configuration
    args = _base_args(
        game_root, hud_memo_popup_removal=cosmetic_patches.disable_hud_popup)

    status_update = status_update_lib.create_progress_update_from_successive_messages(
        progress_update, 400 if patcher_configuration.menu_mod else 100)

    _ensure_no_menu_mod(game_root, backup_files_path, status_update)
    _create_pak_backups(game_root, backup_files_path, status_update)

    indices = _calculate_indices(description)

    args += [
        "-s",
        str(description.permalink.seed_number),
        "-p",
        ",".join(str(index) for index in indices),
    ]
    layout_configuration = description.permalink.layout_configuration
    if not is_vanilla_starting_location(layout_configuration):
        args.append("-i")
    if layout_configuration.elevators == LayoutRandomizedFlag.RANDOMIZED:
        args.append("-v")
    if cosmetic_patches.speed_up_credits:
        args.append("-c")
    if description.permalink.patcher_configuration.warp_to_start:
        args.append("-t")

    description.save_to_file(game_root.joinpath("files", "randovania.json"))
    _run_with_args(args, "Randomized!", status_update)

    if patcher_configuration.menu_mod:
        _add_menu_mod_to_files(game_root, status_update)
コード例 #7
0
def apply_layout(
    description: LayoutDescription,
    players_config: PlayersConfiguration,
    cosmetic_patches: CosmeticPatches,
    backup_files_path: Optional[Path],
    progress_update: ProgressUpdateCallable,
    game_root: Path,
):
    """
    Applies the modifications listed in the given LayoutDescription to the game in game_root.
    :param description:
    :param players_config:
    :param cosmetic_patches:
    :param game_root:
    :param backup_files_path: Path to use as pak backup, to remove/add menu mod.
    :param progress_update:
    :return:
    """

    patcher_configuration = description.permalink.get_preset(
        players_config.player_index).patcher_configuration

    status_update = status_update_lib.create_progress_update_from_successive_messages(
        progress_update, 400 if patcher_configuration.menu_mod else 100)

    _ensure_no_menu_mod(game_root, backup_files_path, status_update)
    if backup_files_path is not None:
        _create_pak_backups(game_root, backup_files_path, status_update)
    description.save_to_file(
        game_root.joinpath("files",
                           f"randovania.{description.file_extension()}"))

    _modern_api(game_root, status_update, description, players_config,
                cosmetic_patches)
    dol_patcher.apply_patches(
        game_root, description.all_patches[players_config.player_index],
        cosmetic_patches)

    if patcher_configuration.menu_mod:
        _add_menu_mod_to_files(game_root, status_update)