diff --git a/CLI.py b/CLI.py index 4cd17834..e0039b65 100644 --- a/CLI.py +++ b/CLI.py @@ -34,7 +34,9 @@ def parse_cli(argv, no_defaults=False): parser.add_argument('--settingsfile', help="input json file of settings", type=str) parser.add_argument('--multi', default=defval(settings["multi"]), type=lambda value: min(max(int(value), 1), 255)) parser.add_argument('--customizer', help='input yaml file for customizations', type=str) - parser.add_argument('--print_custom_yaml', help='print example yaml for current settings', + parser.add_argument('--print_template_yaml', help='print example yaml for current settings', + default=False, action="store_true") + parser.add_argument('--print_custom_yaml', help='print example plando yaml for current settings and placements', default=False, action="store_true") parser.add_argument('--mystery', dest="mystery", default=False, action="store_true") @@ -94,6 +96,7 @@ def parse_cli(argv, no_defaults=False): parser.add_argument('--teams', default=defval(1), type=lambda value: max(int(value), 1)) parser.add_argument('--settingsfile', dest="filename", help="input json file of settings", type=str) parser.add_argument('--customizer', dest="customizer", help='input yaml file for customizations', type=str) + parser.add_argument('--print_template_yaml', dest="print_template_yaml", default=False, action="store_true") parser.add_argument('--print_custom_yaml', dest="print_custom_yaml", default=False, action="store_true") if player_num: diff --git a/Gui.py b/Gui.py index 4aecfa03..0dcdaa75 100755 --- a/Gui.py +++ b/Gui.py @@ -45,8 +45,8 @@ def save_settings(gui, args, filename): os.makedirs(settings_path) output_args = {} settings = ["create_rom", "suppress_rom", "bps", "create_spoiler", "suppress_spoiler", - "calc_playthrough", "skip_playthrough", "print_custom_yaml", "settingsonload", - "rom", "enemizercli", "outputpath"] + "calc_playthrough", "skip_playthrough", "print_template_yaml", "print_custom_yaml", + "settingsonload", "rom", "enemizercli", "outputpath"] if filename == "settings.json": for s in settings: output_args[s] = args[s] diff --git a/Main.py b/Main.py index bda0e6c9..afcb1568 100644 --- a/Main.py +++ b/Main.py @@ -183,8 +183,6 @@ def main(args, seed=None, fish=None): for player, name in enumerate(team, 1): world.player_names[player].append(name) logger.info('') - world.settings = CustomSettings() - world.settings.create_from_world(world, args) outfilebase = f'OR_{args.outputname if args.outputname else world.seed}' @@ -210,6 +208,12 @@ def main(args, seed=None, fish=None): if item: world.push_precollected(item) + world.settings = CustomSettings() + world.settings.create_from_world(world, args) + + if args.print_template_yaml: + world.settings.record_item_pool(world, True) + world.settings.write_to_file(output_path(f'{outfilebase}_template.yaml')) if args.create_spoiler and not args.jsonout: logger.info(world.fish.translate("cli", "cli", "create.meta")) world.spoiler.meta_to_file(output_path(f'{outfilebase}_Spoiler.txt')) @@ -227,9 +231,6 @@ def main(args, seed=None, fish=None): adjust_locations(world, player) place_bosses(world, player) - if args.print_custom_yaml: - world.settings.record_info(world) - if any(world.potshuffle.values()): logger.info(world.fish.translate("cli", "cli", "shuffling.pots")) for player in range(1, world.players + 1): @@ -247,8 +248,6 @@ def main(args, seed=None, fish=None): update_world_regions(world, player) mark_light_dark_world_regions(world, player) create_dynamic_exits(world, player) - if args.print_custom_yaml: - world.settings.record_overworld(world) init_districts(world) @@ -262,8 +261,6 @@ def main(args, seed=None, fish=None): for player in range(1, world.players + 1): link_doors_prep(world, player) - if args.print_custom_yaml: - world.settings.record_entrances(world) create_item_pool_config(world) logger.info(world.fish.translate("cli", "cli", "shuffling.dungeons")) @@ -271,8 +268,6 @@ def main(args, seed=None, fish=None): for player in range(1, world.players + 1): link_doors(world, player) mark_light_dark_world_regions(world, player) - if args.print_custom_yaml: - world.settings.record_doors(world) logger.info(world.fish.translate("cli", "cli", "generating.itempool")) @@ -300,8 +295,6 @@ def main(args, seed=None, fish=None): lock_shop_locations(world, player) massage_item_pool(world) - if args.print_custom_yaml: - world.settings.record_item_pool(world) logger.info(world.fish.translate("cli", "cli", "placing.dungeon.prizes")) fill_prizes(world) @@ -351,6 +344,11 @@ def main(args, seed=None, fish=None): ensure_good_pots(world, True) if args.print_custom_yaml: + world.settings.record_info(world) + world.settings.record_overworld(world) + world.settings.record_entrances(world) + world.settings.record_doors(world) + world.settings.record_item_pool(world) world.settings.record_item_placements(world) world.settings.write_to_file(output_path(f'{outfilebase}_custom.yaml')) diff --git a/docs/Customizer.md b/docs/Customizer.md index 872003c5..3f3b31e9 100644 --- a/docs/Customizer.md +++ b/docs/Customizer.md @@ -6,11 +6,13 @@ This can also be used to roll a mystery or mutli-mystery seed via the GUI. [Exam The cli includes a couple arguments to help: +`--print_template_yaml` will create a yaml file based on the settings used. This does not contain any seed specific information. + `--print_custom_yaml` will create a yaml file based on the seed rolled. Treat it like a spoiler. `--customizer` takes a file as an argument. -Present on the GUI as `Print Customizer File` and `Customizer File` on the Generation Setup tab. +Present on the GUI as `Print Customizer Template`, `Print Customizer File`, and `Customizer File` on the Generation Setup tab. ### meta @@ -44,7 +46,7 @@ Start inventory is not supported here. It has a separate section. ###### Not Yet Implemented -Rom/Adjust flags like sprite, quickswap are not outputing with the print_custom_yaml settings +Rom/Adjust flags like sprite, quickswap are not outputing with the print_template_yaml or print_custom_yaml settings ### item_pool diff --git a/resources/app/gui/lang/en.json b/resources/app/gui/lang/en.json index 0ae493d2..5d082636 100644 --- a/resources/app/gui/lang/en.json +++ b/resources/app/gui/lang/en.json @@ -234,6 +234,7 @@ "randomizer.generation.createspoiler": "Create Spoiler Log", "randomizer.generation.createrom": "Create Patched ROM", "randomizer.generation.calcplaythrough": "Calculate Playthrough", + "randomizer.generation.print_template_yaml": "Print Customizer Template", "randomizer.generation.print_custom_yaml": "Print Customizer File", "randomizer.generation.settingsonload": "Settings On Load", diff --git a/resources/app/gui/randomize/generation/checkboxes.json b/resources/app/gui/randomize/generation/checkboxes.json index 6e377027..658ea7f0 100644 --- a/resources/app/gui/randomize/generation/checkboxes.json +++ b/resources/app/gui/randomize/generation/checkboxes.json @@ -4,6 +4,7 @@ "bps": { "type": "checkbox" }, "createspoiler": { "type": "checkbox" }, "calcplaythrough": { "type": "checkbox" }, + "print_template_yaml":{ "type": "checkbox" }, "print_custom_yaml": { "type": "checkbox" } } } diff --git a/source/classes/CustomSettings.py b/source/classes/CustomSettings.py index a3402318..ba9c9422 100644 --- a/source/classes/CustomSettings.py +++ b/source/classes/CustomSettings.py @@ -262,10 +262,11 @@ class CustomSettings(object): self.world_rep['meta'] = meta_dict meta_dict['players'] = world.players meta_dict['algorithm'] = world.algorithm - meta_dict['seed'] = world.seed meta_dict['race'] = settings.race meta_dict['user_notes'] = settings.notes self.world_rep['settings'] = settings_dict + if world.precollected_items: + self.world_rep['start_inventory'] = start_inv = {} for p in self.player_range: settings_dict[p] = {} settings_dict[p]['ow_shuffle'] = world.owShuffle[p] @@ -323,6 +324,10 @@ class CustomSettings(object): settings_dict[p]['triforce_goal'] = world.treasure_hunt_count[p] settings_dict[p]['triforce_pool'] = world.treasure_hunt_total[p] settings_dict[p]['beemizer'] = world.beemizer[p] + if world.precollected_items: + start_inv[p] = [] + for item in world.precollected_items: + start_inv[item.player].append(item.name) # rom adjust stuff # settings_dict[p]['sprite'] = world.sprite[p] @@ -335,34 +340,42 @@ class CustomSettings(object): # settings_dict[p]['ow_palettes'] = world.ow_palettes[p] # settings_dict[p]['uw_palettes'] = world.uw_palettes[p] # settings_dict[p]['shuffle_sfx'] = world.shuffle_sfx[p] + # settings_dict[p]['shuffle_songinstruments'] = world.shuffle_songinstruments[p] # more settings? def record_info(self, world): + self.world_rep['meta']['seed'] = world.seed self.world_rep['bosses'] = bosses = {} - self.world_rep['start_inventory'] = start_inv = {} + self.world_rep['medallions'] = medallions = {} for p in self.player_range: bosses[p] = {} - start_inv[p] = [] + medallions[p] = {} for dungeon in world.dungeons: for level, boss in dungeon.bosses.items(): location = dungeon.name if level is None else f'{dungeon.name} ({level})' if boss and 'Agahnim' not in boss.name: bosses[dungeon.player][location] = boss.name - for item in world.precollected_items: - start_inv[item.player].append(item.name) - - def record_item_pool(self, world): - self.world_rep['item_pool'] = item_pool = {} - self.world_rep['medallions'] = medallions = {} - for p in self.player_range: - item_pool[p] = defaultdict(int) - medallions[p] = {} - for item in world.itempool: - item_pool[item.player][item.name] += 1 for p, req_medals in world.required_medallions.items(): medallions[p]['Misery Mire'] = req_medals[0] medallions[p]['Turtle Rock'] = req_medals[1] + def record_item_pool(self, world, use_custom_pool=False): + if not use_custom_pool or world.custom: + self.world_rep['item_pool'] = item_pool = {} + for p in self.player_range: + if not use_custom_pool or p in world.customitemarray: + item_pool[p] = defaultdict(int) + if use_custom_pool and world.custom: + import source.classes.constants as CONST + for p in world.customitemarray: + for i, c in world.customitemarray[p].items(): + if c > 0: + item = CONST.CUSTOMITEMLABELS[CONST.CUSTOMITEMS.index(i)] + item_pool[p][item] += c + else: + for item in world.itempool: + item_pool[item.player][item.name] += 1 + def record_item_placements(self, world): self.world_rep['placements'] = placements = {} for p in self.player_range: diff --git a/source/classes/constants.py b/source/classes/constants.py index c8e15532..6bf5f55e 100644 --- a/source/classes/constants.py +++ b/source/classes/constants.py @@ -147,6 +147,7 @@ SETTINGSTOPROCESS = { "createspoiler": "create_spoiler", "createrom": "create_rom", "calcplaythrough": "calc_playthrough", + "print_template_yaml": "print_template_yaml", "print_custom_yaml": "print_custom_yaml", "settingsonload": "settingsonload" }