LttP: use local_early_items for Small Key HC in Standard Keyshuffle (#1799)

This commit is contained in:
Fabian Dill 2023-05-15 09:34:56 +02:00 committed by GitHub
parent 7674e62ba7
commit 98b0bf7456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 26 deletions

View File

@ -247,6 +247,13 @@ class ALTTPWorld(World):
player = self.player player = self.player
world = self.multiworld 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 # system for sharing ER layouts
self.er_seed = str(world.random.randint(0, 2 ** 64)) self.er_seed = str(world.random.randint(0, 2 ** 64))
@ -543,12 +550,8 @@ class ALTTPWorld(World):
@classmethod @classmethod
def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fill_locations): def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fill_locations):
trash_counts = {} trash_counts = {}
standard_keyshuffle_players = set()
for player in world.get_game_players("A Link to the Past"): 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 \ if not world.ganonstower_vanilla[player] or \
world.logic[player] in {'owglitches', 'hybridglitches', "nologic"}: world.logic[player] in {'owglitches', 'hybridglitches', "nologic"}:
pass pass
@ -558,27 +561,6 @@ class ALTTPWorld(World):
else: else:
trash_counts[player] = world.random.randint(0, world.crystals_needed_for_gt[player] * 2) 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: if trash_counts:
locations_mapping = {player: [] for player in trash_counts} locations_mapping = {player: [] for player in trash_counts}
for location in fill_locations: for location in fill_locations: