Skip to content

Commit

Permalink
Support exporting spoiler log in full rando CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
mike8699 committed Oct 20, 2023
1 parent a817fc9 commit 6ffd0ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ph_rando/ui/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
from pathlib import Path
import random
Expand All @@ -8,6 +9,7 @@
from ph_rando.common import click_setting_options
from ph_rando.patcher._patcher import Patcher
from ph_rando.shuffler._shuffler import Shuffler
from ph_rando.shuffler._spoiler_log import generate_spoiler_log


@click.command()
Expand All @@ -25,6 +27,12 @@
required=True,
help='Path to save randomized ROM to.',
)
@click.option(
'--spoiler-log',
required=False,
type=click.Path(exists=False, path_type=Path),
help='File path to save spoiler log to.',
)
@click.option('-s', '--seed', type=str, required=False, help='Seed for the randomizer.')
@click.option(
'-l',
Expand All @@ -39,6 +47,7 @@
def randomizer_cli(
input_rom_path: Path,
output_rom_path: Path,
spoiler_log: Path | None,
seed: str | None,
log_level: str,
**settings: bool | str | list[str],
Expand All @@ -52,6 +61,10 @@ def randomizer_cli(
# Run the shuffler
shuffled_aux_data = Shuffler(seed, settings).generate()

if spoiler_log:
sl = generate_spoiler_log(shuffled_aux_data).dict()
Path(spoiler_log).write_text(json.dumps(sl, indent=2))

patcher = Patcher(rom=input_rom_path, aux_data=shuffled_aux_data, settings=settings)

patched_rom = patcher.generate()
Expand Down

0 comments on commit 6ffd0ed

Please sign in to comment.