From dfc56a32724bc2d799cd6696741eef0936bc782a Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Mon, 2 Aug 2021 19:33:14 -0700 Subject: [PATCH] Implement random progressive techs. --- playerSettings.yaml | 1 + worlds/factorio/Options.py | 9 ++++----- worlds/factorio/__init__.py | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/playerSettings.yaml b/playerSettings.yaml index 5ee5d206..bf6dc68e 100644 --- a/playerSettings.yaml +++ b/playerSettings.yaml @@ -106,6 +106,7 @@ Factorio: progressive: on: 1 off: 0 + random: 0 tech_tree_information: none: 0 advancement: 0 # show which items are a logical advancement diff --git a/worlds/factorio/Options.py b/worlds/factorio/Options.py index a83d6343..3d99664e 100644 --- a/worlds/factorio/Options.py +++ b/worlds/factorio/Options.py @@ -100,11 +100,13 @@ class RecipeTime(Choice): option_chaos = 5 -# TODO: implement random class Progressive(Choice): + displayname = "Progressive Technologies" option_off = 0 option_random = 1 option_on = 2 + alias_false = 0 + alias_true = 2 default = 2 def want_progressives(self, random): @@ -258,9 +260,6 @@ class FactorioWorldGen(OptionDict): class ImportedBlueprint(DefaultOnToggle): displayname = "Blueprints" -class ProgressiveToggle(DefaultOnToggle): - displayname = "Progressive Technologies" - factorio_options: typing.Dict[str, type(Option)] = { "max_science_pack": MaxSciencePack, "tech_tree_layout": TechTreeLayout, @@ -273,5 +272,5 @@ factorio_options: typing.Dict[str, type(Option)] = { "recipe_ingredients": RecipeIngredients, "imported_blueprints": ImportedBlueprint, "world_gen": FactorioWorldGen, - "progressive": ProgressiveToggle + "progressive": Progressive } diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index e177def6..59a9b678 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -28,14 +28,15 @@ class Factorio(World): data_version = 3 def generate_basic(self): + want_progressives = {} skip_silo = self.world.silo[self.player].value == Silo.option_spawn for tech_name in base_tech_table: if skip_silo and tech_name == "rocket-silo": continue - if self.world.progressive[self.player]: - item_name = tech_to_progressive_lookup.get(tech_name, tech_name) - else: - item_name = tech_name + progressive_item_name = tech_to_progressive_lookup.get(tech_name, tech_name) + want_progressive = want_progressives.setdefault(progressive_item_name, + self.world.progressive[self.player].want_progressives(self.world.random)) + item_name = progressive_item_name if want_progressive else tech_name tech_item = self.create_item(item_name) if tech_name in self.static_nodes: self.world.get_location(tech_name, self.player).place_locked_item(tech_item)