remove jsonout
This commit is contained in:
parent
de9ae7d111
commit
9c9b5c5191
|
@ -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)
|
||||||
|
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()]):
|
||||||
|
input('Could not find link sprite sheet at given location. \nPress Enter to exit.')
|
||||||
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 not args.jsonout:
|
|
||||||
input('Could not find link sprite sheet at given location. \nPress Enter to exit.')
|
|
||||||
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]
|
||||||
|
|
101
Main.py
101
Main.py
|
@ -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,15 +162,14 @@ 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:
|
||||||
patch_race_rom(rom)
|
patch_race_rom(rom)
|
||||||
|
@ -182,49 +180,46 @@ 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:
|
mcsb_name = ''
|
||||||
jsonout[f'patch_t{team}_p{player}'] = rom.patches
|
if all([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
||||||
else:
|
world.bigkeyshuffle[player]]):
|
||||||
mcsb_name = ''
|
mcsb_name = '-keysanity'
|
||||||
if all([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
elif [world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
||||||
world.bigkeyshuffle[player]]):
|
world.bigkeyshuffle[player]].count(True) == 1:
|
||||||
mcsb_name = '-keysanity'
|
mcsb_name = '-mapshuffle' if world.mapshuffle[player] else '-compassshuffle' if world.compassshuffle[
|
||||||
elif [world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
player] else '-keyshuffle' if world.keyshuffle[player] else '-bigkeyshuffle'
|
||||||
world.bigkeyshuffle[player]].count(True) == 1:
|
elif any([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
||||||
mcsb_name = '-mapshuffle' if world.mapshuffle[player] else '-compassshuffle' if world.compassshuffle[
|
world.bigkeyshuffle[player]]):
|
||||||
player] else '-keyshuffle' if world.keyshuffle[player] else '-bigkeyshuffle'
|
mcsb_name = '-%s%s%s%sshuffle' % (
|
||||||
elif any([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player],
|
'M' if world.mapshuffle[player] else '', 'C' if world.compassshuffle[player] else '',
|
||||||
world.bigkeyshuffle[player]]):
|
'S' if world.keyshuffle[player] else '', 'B' if world.bigkeyshuffle[player] else '')
|
||||||
mcsb_name = '-%s%s%s%sshuffle' % (
|
|
||||||
'M' if world.mapshuffle[player] else '', 'C' if world.compassshuffle[player] else '',
|
|
||||||
'S' if world.keyshuffle[player] else '', 'B' if world.bigkeyshuffle[player] else '')
|
|
||||||
|
|
||||||
outfilepname = f'_T{team + 1}' if world.teams > 1 else ''
|
outfilepname = f'_T{team + 1}' if world.teams > 1 else ''
|
||||||
if world.players > 1:
|
if world.players > 1:
|
||||||
outfilepname += f'_P{player}'
|
outfilepname += f'_P{player}'
|
||||||
if world.players > 1 or world.teams > 1:
|
if world.players > 1 or world.teams > 1:
|
||||||
outfilepname += f"_{world.player_names[player][team].replace(' ', '_')}" if world.player_names[player][
|
outfilepname += f"_{world.player_names[player][team].replace(' ', '_')}" if world.player_names[player][
|
||||||
team] != 'Player%d' % player else ''
|
team] != 'Player%d' % player else ''
|
||||||
outfilesuffix = ('_%s_%s-%s-%s-%s%s_%s-%s%s%s%s%s' % (world.logic[player], world.difficulty[player],
|
outfilesuffix = ('_%s_%s-%s-%s-%s%s_%s-%s%s%s%s%s' % (world.logic[player], world.difficulty[player],
|
||||||
world.difficulty_adjustments[player],
|
world.difficulty_adjustments[player],
|
||||||
world.mode[player], world.goal[player],
|
world.mode[player], world.goal[player],
|
||||||
"" if world.timer[player] in [False,
|
"" if world.timer[player] in [False,
|
||||||
'display'] else "-" +
|
'display'] else "-" +
|
||||||
world.timer[
|
world.timer[
|
||||||
player],
|
player],
|
||||||
world.shuffle[player], world.algorithm,
|
world.shuffle[player], world.algorithm,
|
||||||
mcsb_name,
|
mcsb_name,
|
||||||
"-retro" if world.retro[player] else "",
|
"-retro" if world.retro[player] else "",
|
||||||
"-prog_" + world.progressive[player] if
|
"-prog_" + world.progressive[player] if
|
||||||
world.progressive[player] in ['off',
|
world.progressive[player] in ['off',
|
||||||
'random'] else "",
|
'random'] else "",
|
||||||
"-nohints" if not world.hints[
|
"-nohints" if not world.hints[
|
||||||
player] else "")) if not args.outputname else ''
|
player] else "")) if not args.outputname else ''
|
||||||
rompath = output_path(f'{outfilebase}{outfilepname}{outfilesuffix}.sfc')
|
rompath = output_path(f'{outfilebase}{outfilepname}{outfilesuffix}.sfc')
|
||||||
rom.write_to_file(rompath)
|
rom.write_to_file(rompath)
|
||||||
if args.create_diff:
|
if args.create_diff:
|
||||||
import Patch
|
import Patch
|
||||||
Patch.create_patch_file(rompath)
|
Patch.create_patch_file(rompath)
|
||||||
return (player, team, list(rom.name))
|
return (player, team, list(rom.name))
|
||||||
|
|
||||||
if not args.suppress_rom:
|
if not args.suppress_rom:
|
||||||
|
@ -266,19 +261,15 @@ 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)
|
with open(output_path('%s_multidata' % outfilebase), 'wb') as f:
|
||||||
else:
|
f.write(multidata)
|
||||||
with open(output_path('%s_multidata' % outfilebase), 'wb') as f:
|
|
||||||
f.write(multidata)
|
|
||||||
|
|
||||||
if not args.skip_playthrough:
|
if not args.skip_playthrough:
|
||||||
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.')
|
||||||
|
|
Loading…
Reference in New Issue