From d2add54cd6b87027ad8c3f06147eae4fe222c032 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 2 Aug 2021 04:57:57 +0200 Subject: [PATCH] Factorio: implement decent option display names for Spoiler --- BaseClasses.py | 7 ++++--- Generate.py | 4 +++- worlds/factorio/Options.py | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 9496785e..4321909d 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -1104,7 +1104,7 @@ class Item(): return self.world.get_name_string_for_object(self) if self.world else f'{self.name} (Player {self.player})' -class Spoiler(object): +class Spoiler(): world: MultiWorld def __init__(self, world): @@ -1295,9 +1295,10 @@ class Spoiler(object): outfile.write('Accessibility: %s\n' % self.metadata['accessibility'][player]) options = self.world.worlds[player].options if options: - for f_option in options: + for f_option, option in options.items(): res = getattr(self.world, f_option)[player] - outfile.write(f'{f_option+":":33}{bool_to_text(res) if type(res) == Options.Toggle else res.get_option_name()}\n') + displayname = getattr(option, "displayname", f_option) + outfile.write(f'{displayname+":":33}{bool_to_text(res) if type(res) == Options.Toggle else res.get_option_name()}\n') if player in self.world.get_game_players("A Link to the Past"): for team in range(self.world.teams): diff --git a/Generate.py b/Generate.py index c509b076..797cb3ef 100644 --- a/Generate.py +++ b/Generate.py @@ -754,5 +754,7 @@ def roll_alttp_settings(ret: argparse.Namespace, weights, plando_options): if __name__ == '__main__': import atexit - atexit.register(input, "Press enter to close.") + confirmation = atexit.register(input, "Press enter to close.") main() + # in case of error-free exit should not need confirmation + atexit.unregister(confirmation) \ No newline at end of file diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index c407743e..a83d6343 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -11,6 +11,7 @@ LuaBool = Or(bool, And(int, lambda n: n in (0, 1))) class MaxSciencePack(Choice): """Maximum level of science pack required to complete the game.""" + displayname = "Maximum Required Science Pack" option_automation_science_pack = 0 option_logistic_science_pack = 1 option_military_science_pack = 2 @@ -34,6 +35,7 @@ class MaxSciencePack(Choice): class TechCost(Choice): """How expensive are the technologies.""" + displayname = "Technology Cost Scale" option_very_easy = 0 option_easy = 1 option_kind = 2 @@ -46,6 +48,7 @@ class TechCost(Choice): class Silo(Choice): """Ingredients to craft rocket silo or auto-place if set to spawn.""" + displayname = "Rocket Silo" option_vanilla = 0 option_randomize_recipe = 1 option_spawn = 2 @@ -54,6 +57,7 @@ class Silo(Choice): class FreeSamples(Choice): """Get free items with your technologies.""" + displayname = "Free Samples" option_none = 0 option_single_craft = 1 option_half_stack = 2 @@ -63,6 +67,7 @@ class FreeSamples(Choice): class TechTreeLayout(Choice): """Selects how the tech tree nodes are interwoven.""" + displayname = "Technology Tree Layout" option_single = 0 option_small_diamonds = 1 option_medium_diamonds = 2 @@ -78,6 +83,7 @@ class TechTreeLayout(Choice): class TechTreeInformation(Choice): """How much information should be displayed in the tech tree.""" + displayname = "Technology Tree Information" option_none = 0 option_advancement = 1 option_full = 2 @@ -86,6 +92,7 @@ class TechTreeInformation(Choice): class RecipeTime(Choice): """randomize the time it takes for any recipe to craft, this includes smelting, chemical lab, hand crafting etc.""" + displayname = "Recipe Time" option_vanilla = 0 option_fast = 1 option_normal = 2 @@ -106,15 +113,18 @@ class Progressive(Choice): class RecipeIngredients(Choice): """Select if rocket, or rocket + science pack ingredients should be random.""" + displayname = "Random Recipe Ingredients Level" option_rocket = 0 option_science_pack = 1 class FactorioStartItems(OptionDict): + displayname = "Starting Items" default = {"burner-mining-drill": 19, "stone-furnace": 19} class FactorioWorldGen(OptionDict): + displayname = "World Generation" # FIXME: do we want default be a rando-optimized default or in-game DS? value: typing.Dict[str, typing.Dict[str, typing.Any]] default = { @@ -245,6 +255,11 @@ class FactorioWorldGen(OptionDict): else: raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}") +class ImportedBlueprint(DefaultOnToggle): + displayname = "Blueprints" + +class ProgressiveToggle(DefaultOnToggle): + displayname = "Progressive Technologies" factorio_options: typing.Dict[str, type(Option)] = { "max_science_pack": MaxSciencePack, @@ -256,7 +271,7 @@ factorio_options: typing.Dict[str, type(Option)] = { "starting_items": FactorioStartItems, "recipe_time": RecipeTime, "recipe_ingredients": RecipeIngredients, - "imported_blueprints": DefaultOnToggle, + "imported_blueprints": ImportedBlueprint, "world_gen": FactorioWorldGen, - "progressive": DefaultOnToggle + "progressive": ProgressiveToggle }