Add spoiler json output option
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
*_Spoiler.txt
|
*_Spoiler.txt
|
||||||
|
*_Spoiler.json
|
||||||
|
*_Meta.json
|
||||||
*.pyc
|
*.pyc
|
||||||
*.sfc
|
*.sfc
|
||||||
*.wixobj
|
*.wixobj
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class ArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter):
|
|||||||
def start():
|
def start():
|
||||||
parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
|
parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument('--create_spoiler', help='Output a Spoiler File', action='store_true')
|
parser.add_argument('--create_spoiler', help='Output a Spoiler File', action='store_true')
|
||||||
|
parser.add_argument('--json_spoiler', help='Output a JSON Spoiler File', action='store_true')
|
||||||
parser.add_argument('--logic', default='noglitches', const='noglitches', nargs='?', choices=['noglitches', 'minorglitches', 'nologic'],
|
parser.add_argument('--logic', default='noglitches', const='noglitches', nargs='?', choices=['noglitches', 'minorglitches', 'nologic'],
|
||||||
help='''\
|
help='''\
|
||||||
Select Enforcement of Item Requirements. (default: %(default)s)
|
Select Enforcement of Item Requirements. (default: %(default)s)
|
||||||
|
|||||||
6
Main.py
6
Main.py
@@ -144,6 +144,12 @@ def main(args, seed=None):
|
|||||||
if args.create_spoiler and not args.jsonout:
|
if args.create_spoiler and not args.jsonout:
|
||||||
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
|
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
|
||||||
|
|
||||||
|
if args.json_spoiler:
|
||||||
|
with open(output_path('%s_Spoiler.json' % outfilebase), 'w') as outfile:
|
||||||
|
outfile.write(world.spoiler.to_json())
|
||||||
|
with open(output_path('%s_Meta.json' % outfilebase), 'w') as outfile:
|
||||||
|
outfile.write(json.dumps(world.spoiler.metadata))
|
||||||
|
|
||||||
if not args.skip_playthrough:
|
if not args.skip_playthrough:
|
||||||
logger.info('Calculating playthrough.')
|
logger.info('Calculating playthrough.')
|
||||||
create_playthrough(world)
|
create_playthrough(world)
|
||||||
|
|||||||
Reference in New Issue
Block a user