Skip to content

Commit

Permalink
LttP: use local_early_items for Small Key HC in Standard Keyshuffle (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored May 15, 2023
1 parent 7674e62 commit 98b0bf7
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions worlds/alttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ def generate_early(self):
player = self.player
world = self.multiworld

if world.mode[player] == 'standard' \
and world.smallkey_shuffle[player] \
and world.smallkey_shuffle[player] != smallkey_shuffle.option_universal \
and world.smallkey_shuffle[player] != smallkey_shuffle.option_own_dungeons \
and world.smallkey_shuffle[player] != smallkey_shuffle.option_start_with:
self.multiworld.local_early_items[self.player]["Small Key (Hyrule Castle)"] = 1

# system for sharing ER layouts
self.er_seed = str(world.random.randint(0, 2 ** 64))

Expand Down Expand Up @@ -543,12 +550,8 @@ def create_item(self, name: str) -> Item:
@classmethod
def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fill_locations):
trash_counts = {}
standard_keyshuffle_players = set()

for player in world.get_game_players("A Link to the Past"):
if world.mode[player] == 'standard' and world.smallkey_shuffle[player] \
and world.smallkey_shuffle[player] != smallkey_shuffle.option_universal and \
world.smallkey_shuffle[player] != smallkey_shuffle.option_own_dungeons:
standard_keyshuffle_players.add(player)
if not world.ganonstower_vanilla[player] or \
world.logic[player] in {'owglitches', 'hybridglitches', "nologic"}:
pass
Expand All @@ -558,27 +561,6 @@ def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fi
else:
trash_counts[player] = world.random.randint(0, world.crystals_needed_for_gt[player] * 2)

# Make sure the escape small key is placed first in standard with key shuffle to prevent running out of spots
# TODO: this might be worthwhile to introduce as generic option for various games and then optimize it
if standard_keyshuffle_players:
viable = {}
for location in world.get_locations():
if location.player in standard_keyshuffle_players \
and location.item is None \
and location.can_reach(world.state):
viable.setdefault(location.player, []).append(location)

for player in standard_keyshuffle_players:
loc = world.random.choice(viable[player])
key = world.create_item("Small Key (Hyrule Castle)", player)
loc.place_locked_item(key)
fill_locations.remove(loc)
world.random.shuffle(fill_locations)
# TODO: investigate not creating the key in the first place
progitempool[:] = [item for item in progitempool if
item.player not in standard_keyshuffle_players or
item.name != "Small Key (Hyrule Castle)"]

if trash_counts:
locations_mapping = {player: [] for player in trash_counts}
for location in fill_locations:
Expand Down

0 comments on commit 98b0bf7

Please sign in to comment.