Skip to content

Pokémon R/B: Door Shuffle fixes #2314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion worlds/pokemon_rb/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def __init__(self, flag):
LocationData("Pewter Gym", "Defeat Brock", "Defeat Brock", event=True),
LocationData("Cerulean Gym", "Defeat Misty", "Defeat Misty", event=True),
LocationData("Vermilion Gym", "Defeat Lt. Surge", "Defeat Lt. Surge", event=True),
LocationData("Celadon Gym", "Defeat Erika", "Defeat Erika", event=True),
LocationData("Celadon Gym-C", "Defeat Erika", "Defeat Erika", event=True),
LocationData("Fuchsia Gym", "Defeat Koga", "Defeat Koga", event=True),
LocationData("Cinnabar Gym", "Defeat Blaine", "Defeat Blaine", event=True),
LocationData("Saffron Gym-C", "Defeat Sabrina", "Defeat Sabrina", event=True),
Expand Down
27 changes: 16 additions & 11 deletions worlds/pokemon_rb/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,9 @@ def pair(a, b):
unreachable_outdoor_entrances = [
"Route 4-C to Mt Moon B1F-NE",
"Fuchsia City-Good Rod House Backyard to Fuchsia Good Rod House",
"Cerulean City-Badge House Backyard to Cerulean Badge House"
"Cerulean City-Badge House Backyard to Cerulean Badge House",
# TODO: This doesn't need to be forced if fly location is Pokemon League?
"Route 23-N to Victory Road 2F-E"
]


Expand Down Expand Up @@ -2220,7 +2222,7 @@ def cerulean_city_problem():
"Cinnabar Gym - Blaine Prize", "Viridian Gym - Giovanni Prize"]:
badge_locs.append(multiworld.get_location(loc, player))
multiworld.random.shuffle(badges)
while badges[3].name == "Cascade Badge" and multiworld.badges_needed_for_hm_moves[player] == "on":
while badges[3].name == "Cascade Badge" and multiworld.badges_needed_for_hm_moves[player]:
multiworld.random.shuffle(badges)
for badge, loc in zip(badges, badge_locs):
loc.place_locked_item(badge)
Expand Down Expand Up @@ -2266,10 +2268,10 @@ def cerulean_city_problem():
]

def adds_reachable_entrances(entrances_copy, item):
state.collect(item, False)
state_copy = state.copy()
state_copy.collect(item, False)
ret = len([entrance for entrance in entrances_copy if entrance in reachable_entrances or
entrance.parent_region.can_reach(state)]) > len(reachable_entrances)
state.remove(item)
entrance.parent_region.can_reach(state_copy)]) > len(reachable_entrances)
return ret

def dead_end(entrances_copy, e):
Expand Down Expand Up @@ -2304,9 +2306,16 @@ def dead_end(entrances_copy, e):
starting_entrances = len(entrances)
dc_connected = []
event_locations = self.multiworld.get_filled_locations(player)
rock_tunnel_entrances = [entrance for entrance in entrances if "Rock Tunnel" in entrance.name]
entrances = [entrance for entrance in entrances if entrance not in rock_tunnel_entrances]
while entrances:
state.update_reachable_regions(player)
state.sweep_for_events(locations=event_locations)

if rock_tunnel_entrances and logic.rock_tunnel(state, player):
entrances += rock_tunnel_entrances
rock_tunnel_entrances = None

reachable_entrances = [entrance for entrance in entrances if entrance in reachable_entrances or
entrance.parent_region.can_reach(state)]
assert reachable_entrances, \
Expand All @@ -2328,12 +2337,8 @@ def dead_end(entrances_copy, e):
# entrances list is empty while it's being sorted, must pass a copy to iterate through
entrances_copy = entrances.copy()
if multiworld.door_shuffle[player] == "decoupled":
if len(reachable_entrances) <= 8 and not logic.rock_tunnel(state, player):
entrances.sort(key=lambda e: 1 if "Rock Tunnel" in e.name else 2 if e.connected_region is not
None else 3 if e not in reachable_entrances else 0)
else:
entrances.sort(key=lambda e: 1 if e.connected_region is not None else 2 if e not in
reachable_entrances else 0)
entrances.sort(key=lambda e: 1 if e.connected_region is not None else 2 if e not in
reachable_entrances else 0)
assert entrances[0].connected_region is None,\
"Ran out of valid reachable entrances in Pokemon Red and Blue door shuffle"
elif len(reachable_entrances) > (1 if multiworld.door_shuffle[player] == "insanity" else 8) and len(
Expand Down