diff --git a/gui/tracker.py b/gui/tracker.py index dc007d42..a022b129 100644 --- a/gui/tracker.py +++ b/gui/tracker.py @@ -1581,7 +1581,7 @@ def update_areas_locations(self) -> None: for area_button in self.ui.tracker_tab.findChildren(TrackerArea): area_button.locations.clear() - self.world.assign_all_areas_hint_regions() + self.world.assign_hint_regions_and_goal_locations() all_locations = self.world.get_all_item_locations() if self.world.setting("gossip_stone_hints") == "on": all_locations.extend(self.world.get_gossip_stones()) diff --git a/logic/area.py b/logic/area.py index b13732c6..fe60781a 100644 --- a/logic/area.py +++ b/logic/area.py @@ -250,13 +250,3 @@ def assign_hint_regions_and_dungeon_locations(starting_area: Area): logging.getLogger("").debug( f"{[l.name for l in locations]} have been assigned to dungeon {region}" ) - - # Also assign goal locations - goal_locations = [loc for loc in locations if loc.is_goal_location] - random.shuffle(goal_locations) - for goal_location in goal_locations: - if not dungeon.goal_location: - dungeon.goal_location = goal_location - else: - if random.randint(0, 1): - dungeon.goal_location = goal_location diff --git a/logic/world.py b/logic/world.py index 82d36127..8f3211e5 100644 --- a/logic/world.py +++ b/logic/world.py @@ -391,10 +391,10 @@ def place_vanilla_items(self) -> None: location.has_known_vanilla_item = True def perform_post_entrance_shuffle_tasks(self) -> None: - self.assign_all_areas_hint_regions() + self.assign_hint_regions_and_goal_locations() self.choose_required_dungeons() - def assign_all_areas_hint_regions(self): + def assign_hint_regions(self) -> None: for area in self.areas.values(): # Assign hint regions to all areas which don't # have them at this point. This will also finalize @@ -413,6 +413,28 @@ def assign_all_areas_hint_regions(self): ): dungeon.starting_entrance = exit_ + def assign_goal_locations(self) -> None: + # Collect all the possible goal locations for each dungeon + dungeon_goal_locations = {d: [] for d in self.dungeons} + for area in self.areas.values(): + for loc_access in area.locations: + loc = loc_access.location + if loc.is_goal_location: + for region in area.hint_regions: + if region in dungeon_goal_locations: + dungeon_goal_locations[region].append(loc) + + # Set a single goal location for each dungeon + for dungeon in self.dungeons.values(): + dungeon.goal_location = random.choice(dungeon_goal_locations[dungeon.name]) + logging.getLogger("").debug( + f"{dungeon.goal_location} chosen as goal location for {dungeon}" + ) + + def assign_hint_regions_and_goal_locations(self): + self.assign_hint_regions() + self.assign_goal_locations() + def choose_required_dungeons(self) -> None: num_required_dungeons = self.setting("required_dungeons").value_as_number() num_chosen_dungeons = 0