Skip to content

Commit

Permalink
Merge pull request #412 from gymnast86/main
Browse files Browse the repository at this point in the history
Fix some beatable only logic issues
  • Loading branch information
CovenEsme authored Jul 27, 2024
2 parents 0cfdeda + e0eab6f commit 0d536a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions logic/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,14 @@ def assign_gossip_stone_hints(
# Keep trying to place hints until all have been logically placed
# at least once
successfully_placed_hints = False
retry_count = 50
while not successfully_placed_hints:
retry_count -= 1
if retry_count < 0:
raise RuntimeError(
"Failed to properly place gossip stone hints. Try using a different seed for generation."
)

random.shuffle(hint_locations)
successfully_placed_hints = True
for stone in gossip_stone_locations:
Expand Down
21 changes: 16 additions & 5 deletions logic/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,19 @@ def assign_goal_locations(self) -> None:

# 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}"
)
possible_goal_locations = dungeon_goal_locations[dungeon.name]
# If a goal location becomes unreachable due to beatable only logic,
# then it's possible a dungeon may not be assigned a goal location.
# Dungeons without a goal location cannot be chosen as required dungeons
if possible_goal_locations:
dungeon.goal_location = random.choice(possible_goal_locations)
logging.getLogger("").debug(
f"{dungeon.goal_location} chosen as goal location for {dungeon}"
)
else:
logging.getLogger("").debug(
f"No goal location could be chosen for {dungeon}"
)

def assign_hint_regions_and_goal_locations(self):
self.assign_hint_regions()
Expand All @@ -449,7 +458,9 @@ def choose_required_dungeons(self) -> None:
if self.setting("dungeons_include_sky_keep") == "off":
sky_keep = self.get_dungeon("Sky Keep")
sky_keep.starting_entrance.disabled = True
dungeons.remove(sky_keep)
# Sky Keep may not be in the list already if it was never assigned a goal location
if sky_keep in dungeons:
dungeons.remove(sky_keep)

random.shuffle(dungeons)
item_pool = get_complete_item_pool(self.worlds)
Expand Down

0 comments on commit 0d536a1

Please sign in to comment.