From c71387ad005baea4a04dd47f8ac686de24d83204 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 6 Jun 2021 16:08:17 +0200 Subject: [PATCH] Factorio: fix single-player static node placement --- BaseClasses.py | 10 ++++++++-- worlds/factorio/__init__.py | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 33fdc3a86b6..7020b2e25bb 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -1193,6 +1193,14 @@ def can_reach(self, state: CollectionState) -> bool: return True return False + def place_locked_item(self, item: Item): + if self.item: + raise Exception(f"Location {self} already filled.") + self.item = item + self.event = item.advancement + self.item.world = self.parent_region.world + self.locked = True + def __repr__(self): return self.__str__() @@ -1497,8 +1505,6 @@ def bool_to_text(variable: Union[bool, str]) -> str: elif player in self.world.factorio_player_ids: for f_option in Options.factorio_options: - logging.info(f_option) - logging.info(getattr(self.world, f_option)) 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') diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index c58b07d726a..4bdfcbca028 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -12,10 +12,7 @@ def gen_factorio(world: MultiWorld, player: int): tech_id, player) tech_item.game = "Factorio" if tech_name in static_nodes: - loc = world.get_location(tech_name, player) - loc.item = tech_item - loc.locked = True - loc.event = tech_item.advancement + world.get_location(tech_name, player).place_locked_item(tech_item) else: world.itempool.append(tech_item) world.custom_data[player]["custom_technologies"] = custom_technologies = set_custom_technologies(world, player)