Skip to content

Commit

Permalink
Finally get to __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholassaylor committed Nov 30, 2024
1 parent a4db817 commit d886376
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions worlds/alttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,31 +485,31 @@ def collect_item(self, state: CollectionState, item: Item, remove=False):
def pre_fill(self):
from Fill import fill_restrictive, FillError
attempts = 5
multiworld = self.multiworld
world = self.multiworld
player = self.player
all_state = multiworld.get_all_state(use_cache=True)
all_state = world.get_all_state(use_cache=True)
crystals = [self.create_item(name) for name in
['Red Pendant', 'Blue Pendant', 'Green Pendant', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4',
'Crystal 7', 'Crystal 5', 'Crystal 6']]
crystal_locations = [multiworld.get_location('Turtle Rock - Prize', player),
multiworld.get_location('Eastern Palace - Prize', player),
multiworld.get_location('Desert Palace - Prize', player),
multiworld.get_location('Tower of Hera - Prize', player),
multiworld.get_location('Palace of Darkness - Prize', player),
multiworld.get_location('Thieves\' Town - Prize', player),
multiworld.get_location('Skull Woods - Prize', player),
multiworld.get_location('Swamp Palace - Prize', player),
multiworld.get_location('Ice Palace - Prize', player),
multiworld.get_location('Misery Mire - Prize', player)]
crystal_locations = [world.get_location('Turtle Rock - Prize', player),
world.get_location('Eastern Palace - Prize', player),
world.get_location('Desert Palace - Prize', player),
world.get_location('Tower of Hera - Prize', player),
world.get_location('Palace of Darkness - Prize', player),
world.get_location('Thieves\' Town - Prize', player),
world.get_location('Skull Woods - Prize', player),
world.get_location('Swamp Palace - Prize', player),
world.get_location('Ice Palace - Prize', player),
world.get_location('Misery Mire - Prize', player)]
placed_prizes = {loc.item.name for loc in crystal_locations if loc.item}
unplaced_prizes = [crystal for crystal in crystals if crystal.name not in placed_prizes]
empty_crystal_locations = [loc for loc in crystal_locations if not loc.item]
for attempt in range(attempts):
try:
prizepool = unplaced_prizes.copy()
prize_locs = empty_crystal_locations.copy()
multiworld.random.shuffle(prize_locs)
fill_restrictive(multiworld, all_state, prize_locs, prizepool, True, lock=True,
world.random.shuffle(prize_locs)
fill_restrictive(world, all_state, prize_locs, prizepool, True, lock=True,
name="LttP Dungeon Prizes")
except FillError as e:
lttp_logger.exception("Failed to place dungeon prizes (%s). Will retry %s more times", e,
Expand Down

0 comments on commit d886376

Please sign in to comment.