Skip to content

Commit

Permalink
Core: Add spoiler-only output mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Zannick committed Oct 15, 2024
1 parent 618564c commit c7a577e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def mystery_argparse():
parser.add_argument("--skip_output", action="store_true",
help="Skips generation assertion and output stages and skips multidata and spoiler output. "
"Intended for debugging and testing purposes.")
parser.add_argument("--spoiler_only", action="store_true",
help="Skips generation assertion and multidata, outputting only a spoiler log. "
"Intended for debugging and testing purposes.")
args = parser.parse_args()
if not os.path.isabs(args.weights_file_path):
args.weights_file_path = os.path.join(args.player_files_path, args.weights_file_path)
Expand Down Expand Up @@ -106,6 +109,11 @@ def main(args=None) -> Tuple[argparse.Namespace, int]:
raise Exception("Cannot mix --sameoptions with --meta")
else:
meta_weights = None

if not args.skip_output and args.spoiler == 0 and args.spoiler_only:
logging.info(f"Inferring --spoiler_only and --spoiler=0 to mean --skip_output")
args.skip_output = True

player_id = 1
player_files = {}
for file in os.scandir(args.player_files_path):
Expand Down Expand Up @@ -155,6 +163,7 @@ def main(args=None) -> Tuple[argparse.Namespace, int]:
erargs.outputpath = args.outputpath
erargs.skip_prog_balancing = args.skip_prog_balancing
erargs.skip_output = args.skip_output
erargs.spoiler_only = args.spoiler_only
erargs.name = {}
erargs.csv_output = args.csv_output

Expand Down
11 changes: 10 additions & 1 deletion Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
del item_digits, location_digits, item_count, location_count

# This assertion method should not be necessary to run if we are not outputting any multidata.
if not args.skip_output:
if not args.skip_output and not args.spoiler_only:
AutoWorld.call_stage(multiworld, "assert_generate")

AutoWorld.call_all(multiworld, "generate_early")
Expand Down Expand Up @@ -230,6 +230,15 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
logger.info(f'Beginning output...')
outfilebase = 'AP_' + multiworld.seed_name

if args.spoiler_only:
if args.spoiler > 1:
logger.info('Calculating playthrough.')
multiworld.spoiler.create_playthrough(create_paths=args.spoiler > 2)

multiworld.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
logger.info('Done. Skipped multidata modification. Total time: %s', time.perf_counter() - start)
return multiworld

output = tempfile.TemporaryDirectory()
with output as temp_dir:
output_players = [player for player in multiworld.player_ids if AutoWorld.World.generate_output.__code__
Expand Down
1 change: 1 addition & 0 deletions WebHostLib/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def task():
{"bosses", "items", "connections", "texts"}))
erargs.skip_prog_balancing = False
erargs.skip_output = False
erargs.spoiler_only = False
erargs.csv_output = False

name_counter = Counter()
Expand Down

0 comments on commit c7a577e

Please sign in to comment.