remove jsonout

This commit is contained in:
Fabian Dill 2020-06-09 21:52:46 +02:00
parent de9ae7d111
commit 9c9b5c5191
2 changed files with 54 additions and 69 deletions

View File

@ -280,10 +280,6 @@ def parse_arguments(argv, no_defaults=False):
''') ''')
parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true') parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true')
parser.add_argument('--gui', help='Launch the GUI', action='store_true') parser.add_argument('--gui', help='Launch the GUI', action='store_true')
parser.add_argument('--jsonout', action='store_true', help='''\
Output .json patch to stdout instead of a patched rom. Used
for VT site integration, do not use otherwise.
''')
parser.add_argument('--skip_progression_balancing', action='store_true', default=defval(False), parser.add_argument('--skip_progression_balancing', action='store_true', default=defval(False),
help="Skip Multiworld Progression balancing.") help="Skip Multiworld Progression balancing.")
parser.add_argument('--skip_playthrough', action='store_true', default=defval(False)) parser.add_argument('--skip_playthrough', action='store_true', default=defval(False))
@ -302,8 +298,7 @@ def parse_arguments(argv, no_defaults=False):
parser.add_argument('--race', default=defval(False), action='store_true') parser.add_argument('--race', default=defval(False), action='store_true')
parser.add_argument('--outputname') parser.add_argument('--outputname')
parser.add_argument('--create_diff', default=defval(False), action='store_true', help='''\ parser.add_argument('--create_diff', default=defval(False), action='store_true', help='''\
create a binary patch file from which the randomized rom can be recreated using MultiClient. create a binary patch file from which the randomized rom can be recreated using MultiClient.''')
Does not work with jsonout.''')
parser.add_argument('--disable_glitch_boots', default=defval(False), action='store_true', help='''\ parser.add_argument('--disable_glitch_boots', default=defval(False), action='store_true', help='''\
turns off starting with Pegasus Boots in glitched modes.''') turns off starting with Pegasus Boots in glitched modes.''')
@ -357,15 +352,14 @@ def start():
sys.exit(0) sys.exit(0)
# ToDo: Validate files further than mere existance # ToDo: Validate files further than mere existance
if not args.jsonout and not os.path.isfile(args.rom): if not os.path.isfile(args.rom):
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom) input(
'Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
sys.exit(1) sys.exit(1)
if any([sprite is not None and not os.path.isfile(sprite) and not get_sprite_from_name(sprite) for sprite in args.sprite.values()]): if any([sprite is not None and not os.path.isfile(sprite) and not get_sprite_from_name(sprite) for sprite in
if not args.jsonout: args.sprite.values()]):
input('Could not find link sprite sheet at given location. \nPress Enter to exit.') input('Could not find link sprite sheet at given location. \nPress Enter to exit.')
sys.exit(1) sys.exit(1)
else:
raise IOError('Cannot find sprite file at %s' % args.sprite)
# set up logger # set up logger
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel] loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]

17
Main.py
View File

@ -155,7 +155,6 @@ def main(args, seed=None):
outfilebase = 'ER_%s' % (args.outputname if args.outputname else world.seed) outfilebase = 'ER_%s' % (args.outputname if args.outputname else world.seed)
rom_names = [] rom_names = []
jsonout = {}
def _gen_rom(team: int, player: int): def _gen_rom(team: int, player: int):
sprite_random_on_hit = type(args.sprite[player]) is str and args.sprite[player].lower() == 'randomonhit' sprite_random_on_hit = type(args.sprite[player]) is str and args.sprite[player].lower() == 'randomonhit'
@ -163,14 +162,13 @@ def main(args, seed=None):
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default' or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
or args.shufflepots[player] or sprite_random_on_hit) or args.shufflepots[player] or sprite_random_on_hit)
rom = JsonRom() if args.jsonout or use_enemizer else LocalRom(args.rom) rom = LocalRom(args.rom)
patch_rom(world, rom, player, team, use_enemizer) patch_rom(world, rom, player, team, use_enemizer)
if use_enemizer and (args.enemizercli or not args.jsonout): if use_enemizer:
patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player], patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player],
sprite_random_on_hit) sprite_random_on_hit)
if not args.jsonout:
rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000) rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000)
if args.race: if args.race:
@ -182,9 +180,6 @@ def main(args, seed=None):
args.fastmenu[player], args.disablemusic[player], args.sprite[player], args.fastmenu[player], args.disablemusic[player], args.sprite[player],
args.ow_palettes[player], args.uw_palettes[player]) args.ow_palettes[player], args.uw_palettes[player])
if args.jsonout:
jsonout[f'patch_t{team}_p{player}'] = rom.patches
else:
mcsb_name = '' mcsb_name = ''
if all([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player], if all([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
world.bigkeyshuffle[player]]): world.bigkeyshuffle[player]]):
@ -266,9 +261,7 @@ def main(args, seed=None):
"server_options": get_options()["server_options"], "server_options": get_options()["server_options"],
"er_hint_data": er_hint_data, "er_hint_data": er_hint_data,
}).encode("utf-8"), 9) }).encode("utf-8"), 9)
if args.jsonout:
jsonout["multidata"] = list(multidata)
else:
with open(output_path('%s_multidata' % outfilebase), 'wb') as f: with open(output_path('%s_multidata' % outfilebase), 'wb') as f:
f.write(multidata) f.write(multidata)
@ -276,9 +269,7 @@ def main(args, seed=None):
logger.info('Calculating playthrough.') logger.info('Calculating playthrough.')
create_playthrough(world) create_playthrough(world)
if args.jsonout: if args.create_spoiler:
print(json.dumps({**jsonout, 'spoiler': world.spoiler.to_json()}))
elif args.create_spoiler:
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
logger.info('Done. Enjoy.') logger.info('Done. Enjoy.')