From affd7077172b79c7c0697d1b246f493af99dd6f7 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Sat, 20 Nov 2021 12:35:51 -0800 Subject: [PATCH] Add satellite recipe to needed_recipes if required. --- worlds/factorio/Technologies.py | 5 ++++- worlds/factorio/__init__.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/worlds/factorio/Technologies.py b/worlds/factorio/Technologies.py index 9e7f88fd..31b7ea12 100644 --- a/worlds/factorio/Technologies.py +++ b/worlds/factorio/Technologies.py @@ -300,13 +300,16 @@ for category_name, machine_name in machine_per_category.items(): required_technologies: Dict[str, FrozenSet[Technology]] = Utils.KeyedDefaultDict(lambda ingredient_name: frozenset( recursively_get_unlocking_technologies(ingredient_name, unlock_func=unlock))) -def get_rocket_requirements(silo_recipe: Recipe, part_recipe: Recipe) -> Set[str]: +def get_rocket_requirements(silo_recipe: Recipe, part_recipe: Recipe, satellite_recipe: Recipe) -> Set[str]: techs = set() if silo_recipe: for ingredient in silo_recipe.ingredients: techs |= recursively_get_unlocking_technologies(ingredient) for ingredient in part_recipe.ingredients: techs |= recursively_get_unlocking_technologies(ingredient) + if satellite_recipe: + for ingredient in satellite_recipe.ingredients: + techs |= recursively_get_unlocking_technologies(ingredient) return {tech.name for tech in techs} diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index fb40f722..7574396d 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -10,7 +10,7 @@ from .Technologies import base_tech_table, recipe_sources, base_technology_table get_science_pack_pools, Recipe, recipes, technology_table, tech_table, factorio_base_id, useless_technologies from .Shapes import get_shapes from .Mod import generate_mod -from .Options import factorio_options, Silo, TechTreeInformation +from .Options import factorio_options, MaxSciencePack, Silo, TechTreeInformation import logging @@ -142,11 +142,13 @@ class Factorio(World): locations=locations: all(state.can_reach(loc) for loc in locations)) silo_recipe = None if self.world.silo[self.player].value == Silo.option_spawn \ - else self.custom_recipes["rocket-silo"] \ - if "rocket-silo" in self.custom_recipes \ + else self.custom_recipes["rocket-silo"] if "rocket-silo" in self.custom_recipes \ else next(iter(all_product_sources.get("rocket-silo"))) part_recipe = self.custom_recipes["rocket-part"] - victory_tech_names = get_rocket_requirements(silo_recipe, part_recipe) + satellite_recipe = None if self.world.max_science_pack[self.player].value != MaxSciencePack.option_space_science_pack \ + else self.custom_recipes["satellite"] if "satellite" in self.custom_recipes \ + else next(iter(all_product_sources.get("satellite"))) + victory_tech_names = get_rocket_requirements(silo_recipe, part_recipe, satellite_recipe) world.get_location("Rocket Launch", player).access_rule = lambda state: all(state.has(technology, player) for technology in victory_tech_names) @@ -292,6 +294,8 @@ class Factorio(World): self.custom_recipes["rocket-silo"] = new_recipe needed_recipes = self.world.max_science_pack[self.player].get_allowed_packs() | {"rocket-silo", "rocket-part"} + if self.world.max_science_pack[self.player].value == MaxSciencePack.option_space_science_pack: + needed_recipes |= {"satellite"} for recipe in needed_recipes: recipe = self.custom_recipes.get(recipe, recipes[recipe])