Factorio: fix selecting wrong goal requirements due to convoluted if tree.

This commit is contained in:
Fabian Dill 2021-12-04 10:54:11 +01:00
parent 84e76eadd9
commit feb2e0be03
1 changed files with 6 additions and 4 deletions

View File

@ -142,12 +142,14 @@ class Factorio(World):
Rules.add_rule(location, lambda state, Rules.add_rule(location, lambda state,
locations=locations: all(state.can_reach(loc) for loc in locations)) locations=locations: all(state.can_reach(loc) for loc in locations))
silo_recipe = None if self.world.silo[self.player].value == Silo.option_spawn \ silo_recipe = None
else self.custom_recipes["rocket-silo"] if "rocket-silo" in self.custom_recipes \ if self.world.silo[self.player] == Silo.option_spawn:
silo_recipe = self.custom_recipes["rocket-silo"] if "rocket-silo" in self.custom_recipes \
else next(iter(all_product_sources.get("rocket-silo"))) else next(iter(all_product_sources.get("rocket-silo")))
part_recipe = self.custom_recipes["rocket-part"] part_recipe = self.custom_recipes["rocket-part"]
satellite_recipe = None if self.world.goal[self.player].value != Goal.option_rocket \ satellite_recipe = None
else self.custom_recipes["satellite"] if "satellite" in self.custom_recipes \ if self.world.goal[self.player] == Goal.option_satellite:
satellite_recipe = self.custom_recipes["satellite"] if "satellite" in self.custom_recipes \
else next(iter(all_product_sources.get("satellite"))) else next(iter(all_product_sources.get("satellite")))
victory_tech_names = get_rocket_requirements(silo_recipe, part_recipe, satellite_recipe) 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) world.get_location("Rocket Launch", player).access_rule = lambda state: all(state.has(technology, player)