diff --git a/.gitignore b/.gitignore index af03169dd8..c4ce894b5e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,8 @@ build bundle/components.wxs dist README.html +.vs/ +*multidata +*multisave +EnemizerCLI/ +.mypy_cache/ \ No newline at end of file diff --git a/AdjusterMain.py b/AdjusterMain.py index 346e9301c0..634661428b 100644 --- a/AdjusterMain.py +++ b/AdjusterMain.py @@ -21,7 +21,7 @@ def adjust(args): outfilebase = os.path.basename(args.rom)[:-4] + '_adjusted' - if os.stat(args.rom).st_size == 2097152 and os.path.splitext(args.rom)[-1].lower() == '.sfc': + if os.stat(args.rom).st_size in (0x200000, 0x400000) and os.path.splitext(args.rom)[-1].lower() == '.sfc': rom = LocalRom(args.rom, False) else: raise RuntimeError('Provided Rom is not a valid Link to the Past Randomizer Rom. Please provide one for adjusting.') diff --git a/BaseClasses.py b/BaseClasses.py index 2395d32e4e..ca6044c148 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -3,15 +3,19 @@ from enum import Enum, unique import logging import json from collections import OrderedDict +from _vendor.collections_extended import bag from Utils import int16_as_bytes class World(object): - def __init__(self, shuffle, logic, mode, difficulty, timer, progressive, goal, algorithm, place_dungeon_items, check_beatable_only, shuffle_ganon, quickswap, fastmenu, disable_music, keysanity, retro, custom, customitemarray, boss_shuffle, hints): + def __init__(self, players, shuffle, logic, mode, swords, difficulty, difficulty_adjustments, timer, progressive, goal, algorithm, place_dungeon_items, accessibility, shuffle_ganon, quickswap, fastmenu, disable_music, keysanity, retro, custom, customitemarray, boss_shuffle, hints): + self.players = players self.shuffle = shuffle self.logic = logic self.mode = mode + self.swords = swords self.difficulty = difficulty + self.difficulty_adjustments = difficulty_adjustments self.timer = timer self.progressive = progressive self.goal = goal @@ -21,8 +25,9 @@ class World(object): self.shops = [] self.itempool = [] self.seed = None + self.precollected_items = [] self.state = CollectionState(self) - self.required_medallions = ['Ether', 'Quake'] + self.required_medallions = dict([(player, ['Ether', 'Quake']) for player in range(1, players + 1)]) self._cached_entrances = None self._cached_locations = None self._entrance_cache = {} @@ -32,10 +37,10 @@ class World(object): self.required_locations = [] self.place_dungeon_items = place_dungeon_items # configurable in future self.shuffle_bonk_prizes = False - self.swamp_patch_required = False - self.powder_patch_required = False - self.ganon_at_pyramid = True - self.ganonstower_vanilla = True + self.swamp_patch_required = {player: False for player in range(1, players + 1)} + self.powder_patch_required = {player: False for player in range(1, players + 1)} + self.ganon_at_pyramid = {player: True for player in range(1, players + 1)} + self.ganonstower_vanilla = {player: True for player in range(1, players + 1)} self.sewer_light_cone = mode == 'standard' self.light_world_light_cone = False self.dark_world_light_cone = False @@ -45,9 +50,9 @@ class World(object): self.rupoor_cost = 10 self.aga_randomness = True self.lock_aga_door_in_escape = False - self.fix_trock_doors = self.shuffle != 'vanilla' + self.fix_trock_doors = self.shuffle != 'vanilla' or self.mode == 'inverted' self.save_and_quit_from_boss = True - self.check_beatable_only = check_beatable_only + self.accessibility = accessibility self.fix_skullwoods_exit = self.shuffle not in ['vanilla', 'simple', 'restricted', 'dungeonssimple'] self.fix_palaceofdarkness_exit = self.shuffle not in ['vanilla', 'simple', 'restricted', 'dungeonssimple'] self.fix_trock_exit = self.shuffle not in ['vanilla', 'simple', 'restricted', 'dungeonssimple'] @@ -69,6 +74,8 @@ class World(object): self.fix_fake_world = True self.boss_shuffle = boss_shuffle self.hints = hints + self.crystals_needed_for_ganon = 7 + self.crystals_needed_for_gt = 7 self.dynamic_regions = [] self.dynamic_locations = [] self.spoiler = Spoiler(self) @@ -78,52 +85,52 @@ class World(object): for region in self.regions: region.world = self - def get_region(self, regionname): + def get_region(self, regionname, player): if isinstance(regionname, Region): return regionname try: - return self._region_cache[regionname] + return self._region_cache[(regionname, player)] except KeyError: for region in self.regions: - if region.name == regionname: - self._region_cache[regionname] = region + if region.name == regionname and region.player == player: + self._region_cache[(regionname, player)] = region return region - raise RuntimeError('No such region %s' % regionname) + raise RuntimeError('No such region %s for player %d' % (regionname, player)) - def get_entrance(self, entrance): + def get_entrance(self, entrance, player): if isinstance(entrance, Entrance): return entrance try: - return self._entrance_cache[entrance] + return self._entrance_cache[(entrance, player)] except KeyError: for region in self.regions: for exit in region.exits: - if exit.name == entrance: - self._entrance_cache[entrance] = exit + if exit.name == entrance and exit.player == player: + self._entrance_cache[(entrance, player)] = exit return exit - raise RuntimeError('No such entrance %s' % entrance) + raise RuntimeError('No such entrance %s for player %d' % (entrance, player)) - def get_location(self, location): + def get_location(self, location, player): if isinstance(location, Location): return location try: - return self._location_cache[location] + return self._location_cache[(location, player)] except KeyError: for region in self.regions: for r_location in region.locations: - if r_location.name == location: - self._location_cache[location] = r_location + if r_location.name == location and r_location.player == player: + self._location_cache[(location, player)] = r_location return r_location - raise RuntimeError('No such location %s' % location) + raise RuntimeError('No such location %s for player %d' % (location, player)) - def get_dungeon(self, dungeonname): + def get_dungeon(self, dungeonname, player): if isinstance(dungeonname, Dungeon): return dungeonname for dungeon in self.dungeons: - if dungeon.name == dungeonname: + if dungeon.name == dungeonname and dungeon.player == player: return dungeon - raise RuntimeError('No such dungeon %s' % dungeonname) + raise RuntimeError('No such dungeon %s for player %d' % (dungeonname, player)) def get_all_state(self, keys=False): ret = CollectionState(self) @@ -131,59 +138,72 @@ class World(object): def soft_collect(item): if item.name.startswith('Progressive '): if 'Sword' in item.name: - if ret.has('Golden Sword'): + if ret.has('Golden Sword', item.player): pass - elif ret.has('Tempered Sword') and self.difficulty_requirements.progressive_sword_limit >= 4: - ret.prog_items.append('Golden Sword') - elif ret.has('Master Sword') and self.difficulty_requirements.progressive_sword_limit >= 3: - ret.prog_items.append('Tempered Sword') - elif ret.has('Fighter Sword') and self.difficulty_requirements.progressive_sword_limit >= 2: - ret.prog_items.append('Master Sword') + elif ret.has('Tempered Sword', item.player) and self.difficulty_requirements.progressive_sword_limit >= 4: + ret.prog_items.add(('Golden Sword', item.player)) + elif ret.has('Master Sword', item.player) and self.difficulty_requirements.progressive_sword_limit >= 3: + ret.prog_items.add(('Tempered Sword', item.player)) + elif ret.has('Fighter Sword', item.player) and self.difficulty_requirements.progressive_sword_limit >= 2: + ret.prog_items.add(('Master Sword', item.player)) elif self.difficulty_requirements.progressive_sword_limit >= 1: - ret.prog_items.append('Fighter Sword') + ret.prog_items.add(('Fighter Sword', item.player)) elif 'Glove' in item.name: - if ret.has('Titans Mitts'): + if ret.has('Titans Mitts', item.player): pass - elif ret.has('Power Glove'): - ret.prog_items.append('Titans Mitts') + elif ret.has('Power Glove', item.player): + ret.prog_items.add(('Titans Mitts', item.player)) else: - ret.prog_items.append('Power Glove') + ret.prog_items.add(('Power Glove', item.player)) elif 'Shield' in item.name: - if ret.has('Mirror Shield'): + if ret.has('Mirror Shield', item.player): pass - elif ret.has('Red Shield') and self.difficulty_requirements.progressive_shield_limit >= 3: - ret.prog_items.append('Mirror Shield') - elif ret.has('Blue Shield') and self.difficulty_requirements.progressive_shield_limit >= 2: - ret.prog_items.append('Red Shield') + elif ret.has('Red Shield', item.player) and self.difficulty_requirements.progressive_shield_limit >= 3: + ret.prog_items.add(('Mirror Shield', item.player)) + elif ret.has('Blue Shield', item.player) and self.difficulty_requirements.progressive_shield_limit >= 2: + ret.prog_items.add(('Red Shield', item.player)) elif self.difficulty_requirements.progressive_shield_limit >= 1: - ret.prog_items.append('Blue Shield') + ret.prog_items.add(('Blue Shield', item.player)) + elif 'Bow' in item.name: + if ret.has('Silver Arrows', item.player): + pass + elif ret.has('Bow', item.player) and self.difficulty_requirements.progressive_bow_limit >= 2: + ret.prog_items.add(('Silver Arrows', item.player)) + elif self.difficulty_requirements.progressive_bow_limit >= 1: + ret.prog_items.add(('Bow', item.player)) elif item.name.startswith('Bottle'): - if ret.bottle_count() < self.difficulty_requirements.progressive_bottle_limit: - ret.prog_items.append(item.name) + if ret.bottle_count(item.player) < self.difficulty_requirements.progressive_bottle_limit: + ret.prog_items.add((item.name, item.player)) elif item.advancement or item.key: - ret.prog_items.append(item.name) + ret.prog_items.add((item.name, item.player)) for item in self.itempool: soft_collect(item) + if keys: - from Items import ItemFactory - for item in ItemFactory(['Small Key (Escape)', 'Big Key (Eastern Palace)', 'Big Key (Desert Palace)', 'Small Key (Desert Palace)', 'Big Key (Tower of Hera)', 'Small Key (Tower of Hera)', 'Small Key (Agahnims Tower)', 'Small Key (Agahnims Tower)', - 'Big Key (Palace of Darkness)'] + ['Small Key (Palace of Darkness)'] * 6 + ['Big Key (Thieves Town)', 'Small Key (Thieves Town)', 'Big Key (Skull Woods)'] + ['Small Key (Skull Woods)'] * 3 + ['Big Key (Swamp Palace)', - 'Small Key (Swamp Palace)', 'Big Key (Ice Palace)'] + ['Small Key (Ice Palace)'] * 2 + ['Big Key (Misery Mire)', 'Big Key (Turtle Rock)', 'Big Key (Ganons Tower)'] + ['Small Key (Misery Mire)'] * 3 + ['Small Key (Turtle Rock)'] * 4 + ['Small Key (Ganons Tower)'] * 4): - soft_collect(item) + for p in range(1, self.players + 1): + from Items import ItemFactory + for item in ItemFactory(['Small Key (Escape)', 'Big Key (Eastern Palace)', 'Big Key (Desert Palace)', 'Small Key (Desert Palace)', 'Big Key (Tower of Hera)', 'Small Key (Tower of Hera)', 'Small Key (Agahnims Tower)', 'Small Key (Agahnims Tower)', + 'Big Key (Palace of Darkness)'] + ['Small Key (Palace of Darkness)'] * 6 + ['Big Key (Thieves Town)', 'Small Key (Thieves Town)', 'Big Key (Skull Woods)'] + ['Small Key (Skull Woods)'] * 3 + ['Big Key (Swamp Palace)', + 'Small Key (Swamp Palace)', 'Big Key (Ice Palace)'] + ['Small Key (Ice Palace)'] * 2 + ['Big Key (Misery Mire)', 'Big Key (Turtle Rock)', 'Big Key (Ganons Tower)'] + ['Small Key (Misery Mire)'] * 3 + ['Small Key (Turtle Rock)'] * 4 + ['Small Key (Ganons Tower)'] * 4, + p): + soft_collect(item) ret.sweep_for_events() - ret.clear_cached_unreachable() return ret def get_items(self): return [loc.item for loc in self.get_filled_locations()] + self.itempool - def find_items(self, item): - return [location for location in self.get_locations() if location.item is not None and location.item.name == item] + def find_items(self, item, player): + return [location for location in self.get_locations() if location.item is not None and location.item.name == item and location.item.player == player] + + def push_precollected(self, item): + self.precollected_items.append(item) + self.state.collect(item, True) def push_item(self, location, item, collect=True): if not isinstance(location, Location): - location = self.get_location(location) + raise RuntimeError('Cannot assign item %s to location %s (player %d).' % (item, location, item.player)) if location.can_fill(self.state, item, False): location.item = item @@ -215,25 +235,24 @@ class World(object): def clear_location_cache(self): self._cached_locations = None - def get_unfilled_locations(self): - return [location for location in self.get_locations() if location.item is None] + def get_unfilled_locations(self, player=None): + return [location for location in self.get_locations() if (player is None or location.player == player) and location.item is None] - def get_filled_locations(self): - return [location for location in self.get_locations() if location.item is not None] + def get_filled_locations(self, player=None): + return [location for location in self.get_locations() if (player is None or location.player == player) and location.item is not None] - def get_reachable_locations(self, state=None): + def get_reachable_locations(self, state=None, player=None): if state is None: state = self.state - return [location for location in self.get_locations() if state.can_reach(location)] + return [location for location in self.get_locations() if (player is None or location.player == player) and location.can_reach(state)] - def get_placeable_locations(self, state=None): + def get_placeable_locations(self, state=None, player=None): if state is None: state = self.state - return [location for location in self.get_locations() if location.item is None and state.can_reach(location)] + return [location for location in self.get_locations() if (player is None or location.player == player) and location.item is None and location.can_reach(state)] def unlocks_new_location(self, item): temp_state = self.state.copy() - temp_state.clear_cached_unreachable() temp_state.collect(item, True) for location in self.get_unfilled_locations(): @@ -242,13 +261,11 @@ class World(object): return False - def has_beaten_game(self, state): - if state.has('Triforce'): - return True - if self.goal in ['triforcehunt']: - if state.item_count('Triforce Piece') + state.item_count('Power Star') > self.treasure_hunt_count: - return True - return False + def has_beaten_game(self, state, player=None): + if player: + return state.has('Triforce', player) + else: + return all((self.has_beaten_game(state, p) for p in range(1, self.players + 1))) def can_beat_game(self, starting_state=None): if starting_state: @@ -261,262 +278,225 @@ class World(object): prog_locations = [location for location in self.get_locations() if location.item is not None and (location.item.advancement or location.event) and location not in state.locations_checked] - treasure_pieces_collected = state.item_count('Triforce Piece') + state.item_count('Power Star') while prog_locations: sphere = [] # build up spheres of collection radius. Everything in each sphere is independent from each other in dependencies and only depends on lower spheres for location in prog_locations: - if state.can_reach(location): - if location.item.name == 'Triforce': - return True - elif location.item.name in ['Triforce Piece', 'Power Star']: - treasure_pieces_collected += 1 - if self.goal in ['triforcehunt'] and treasure_pieces_collected >= self.treasure_hunt_count: - return True + if location.can_reach(state): sphere.append(location) if not sphere: - # ran out of places and did not find triforce yet, quit + # ran out of places and did not finish yet, quit return False for location in sphere: prog_locations.remove(location) state.collect(location.item, True, location) + if self.has_beaten_game(state): + return True + return False - @property - def option_identifier(self): - id_value = 0 - id_value_max = 1 - - def markbool(value): - nonlocal id_value, id_value_max - id_value += id_value_max * bool(value) - id_value_max *= 2 - def marksequence(options, value): - nonlocal id_value, id_value_max - id_value += id_value_max * options.index(value) - id_value_max *= len(options) - markbool(self.logic == 'noglitches') - marksequence(['standard', 'open', 'swordless'], self.mode) - markbool(self.place_dungeon_items) - marksequence(['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'], self.goal) - marksequence(['vanilla', 'simple', 'restricted', 'full', 'crossed', 'insanity', 'restricted_legacy', 'full_legacy', 'madness_legacy', 'insanity_legacy', 'dungeonsfull', 'dungeonssimple'], self.shuffle) - marksequence(['easy', 'normal', 'hard', 'expert', 'insane'], self.difficulty) - marksequence(['none', 'display', 'timed', 'timed-ohko', 'timed-countdown', 'ohko'], self.timer) - marksequence(['on', 'off', 'random'], self.progressive) - marksequence(['freshness', 'flood', 'vt21', 'vt22', 'vt25', 'vt26', 'balanced'], self.algorithm) - markbool(self.check_beatable_only) - markbool(self.shuffle_ganon) - markbool(self.keysanity) - markbool(self.retro) - assert id_value_max <= 0xFFFFFFFF - return id_value - - class CollectionState(object): def __init__(self, parent): - self.prog_items = [] + self.prog_items = bag() self.world = parent - self.region_cache = {} - self.location_cache = {} - self.entrance_cache = {} - self.recursion_count = 0 + self.reachable_regions = {player: set() for player in range(1, parent.players + 1)} self.events = [] self.path = {} self.locations_checked = set() + self.stale = {player: True for player in range(1, parent.players + 1)} + for item in parent.precollected_items: + self.collect(item, True) - - def clear_cached_unreachable(self): - # we only need to invalidate results which were False, places we could reach before we can still reach after adding more items - self.region_cache = {k: v for k, v in self.region_cache.items() if v} - self.location_cache = {k: v for k, v in self.location_cache.items() if v} - self.entrance_cache = {k: v for k, v in self.entrance_cache.items() if v} + def update_reachable_regions(self, player): + player_regions = [region for region in self.world.regions if region.player == player] + self.stale[player] = False + rrp = self.reachable_regions[player] + new_regions = True + reachable_regions_count = len(rrp) + while new_regions: + possible = [region for region in player_regions if region not in rrp] + for candidate in possible: + if candidate.can_reach_private(self): + rrp.add(candidate) + new_regions = len(rrp) > reachable_regions_count + reachable_regions_count = len(rrp) def copy(self): ret = CollectionState(self.world) - ret.prog_items = copy.copy(self.prog_items) - ret.region_cache = copy.copy(self.region_cache) - ret.location_cache = copy.copy(self.location_cache) - ret.entrance_cache = copy.copy(self.entrance_cache) + ret.prog_items = self.prog_items.copy() + ret.reachable_regions = {player: copy.copy(self.reachable_regions[player]) for player in range(1, self.world.players + 1)} ret.events = copy.copy(self.events) ret.path = copy.copy(self.path) ret.locations_checked = copy.copy(self.locations_checked) return ret - def can_reach(self, spot, resolution_hint=None): + def can_reach(self, spot, resolution_hint=None, player=None): try: spot_type = spot.spot_type - if spot_type == 'Location': - correct_cache = self.location_cache - elif spot_type == 'Region': - correct_cache = self.region_cache - elif spot_type == 'Entrance': - correct_cache = self.entrance_cache - else: - raise AttributeError except AttributeError: # try to resolve a name if resolution_hint == 'Location': - spot = self.world.get_location(spot) - correct_cache = self.location_cache + spot = self.world.get_location(spot, player) elif resolution_hint == 'Entrance': - spot = self.world.get_entrance(spot) - correct_cache = self.entrance_cache + spot = self.world.get_entrance(spot, player) else: # default to Region - spot = self.world.get_region(spot) - correct_cache = self.region_cache + spot = self.world.get_region(spot, player) + + return spot.can_reach(self) - if spot.recursion_count > 0: - return False - - if spot not in correct_cache: - # for the purpose of evaluating results, recursion is resolved by always denying recursive access (as that ia what we are trying to figure out right now in the first place - spot.recursion_count += 1 - self.recursion_count += 1 - can_reach = spot.can_reach(self) - spot.recursion_count -= 1 - self.recursion_count -= 1 - - # we only store qualified false results (i.e. ones not inside a hypothetical) - if not can_reach: - if self.recursion_count == 0: - correct_cache[spot] = can_reach - else: - correct_cache[spot] = can_reach - return can_reach - return correct_cache[spot] - - def sweep_for_events(self, key_only=False): + def sweep_for_events(self, key_only=False, locations=None): # this may need improvement new_locations = True checked_locations = 0 while new_locations: - reachable_events = [location for location in self.world.get_filled_locations() if location.event and (not key_only or location.item.key) and self.can_reach(location)] + if locations is None: + locations = self.world.get_filled_locations() + reachable_events = [location for location in locations if location.event and (not key_only or location.item.key) and location.can_reach(self)] for event in reachable_events: - if event.name not in self.events: - self.events.append(event.name) + if (event.name, event.player) not in self.events: + self.events.append((event.name, event.player)) self.collect(event.item, True, event) new_locations = len(reachable_events) > checked_locations checked_locations = len(reachable_events) - def has(self, item, count=1): + def has(self, item, player, count=1): if count == 1: - return item in self.prog_items - return self.item_count(item) >= count + return (item, player) in self.prog_items + return self.prog_items.count((item, player)) >= count - def has_key(self, item, count=1): + def has_key(self, item, player, count=1): if self.world.retro: - return self.can_buy_unlimited('Small Key (Universal)') + return self.can_buy_unlimited('Small Key (Universal)', player) if count == 1: - return item in self.prog_items - return self.item_count(item) >= count + return (item, player) in self.prog_items + return self.prog_items.count((item, player)) >= count - def can_buy_unlimited(self, item): + def can_buy_unlimited(self, item, player): for shop in self.world.shops: - if shop.has_unlimited(item) and shop.region.can_reach(self): + if shop.region.player == player and shop.has_unlimited(item) and shop.region.can_reach(self): return True return False - def item_count(self, item): - return len([pritem for pritem in self.prog_items if pritem == item]) + def item_count(self, item, player): + return self.prog_items.count((item, player)) - def can_lift_rocks(self): - return self.has('Power Glove') or self.has('Titans Mitts') + def has_crystals(self, count, player): + crystals = ['Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'] + return len([crystal for crystal in crystals if self.has(crystal, player)]) >= count - def has_bottle(self): - return self.bottle_count() > 0 + def can_lift_rocks(self, player): + return self.has('Power Glove', player) or self.has('Titans Mitts', player) - def bottle_count(self): - return len([pritem for pritem in self.prog_items if pritem.startswith('Bottle')]) + def has_bottle(self, player): + return self.bottle_count(player) > 0 - def has_hearts(self, count): + def bottle_count(self, player): + return len([item for (item, itemplayer) in self.prog_items if item.startswith('Bottle') and itemplayer == player]) + + def has_hearts(self, player, count): # Warning: This only considers items that are marked as advancement items - return self.heart_count() >= count + return self.heart_count(player) >= count - def heart_count(self): + def heart_count(self, player): # Warning: This only considers items that are marked as advancement items + diff = self.world.difficulty_requirements return ( - self.item_count('Boss Heart Container') - + self.item_count('Sanctuary Heart Container') - + self.item_count('Piece of Heart') // 4 + min(self.item_count('Boss Heart Container', player), diff.boss_heart_container_limit) + + self.item_count('Sanctuary Heart Container', player) + + min(self.item_count('Piece of Heart', player), diff.heart_piece_limit) // 4 + 3 # starting hearts ) - def can_lift_heavy_rocks(self): - return self.has('Titans Mitts') + def can_lift_heavy_rocks(self, player): + return self.has('Titans Mitts', player) - def can_extend_magic(self, smallmagic=16, fullrefill=False): #This reflects the total magic Link has, not the total extra he has. + def can_extend_magic(self, player, smallmagic=16, fullrefill=False): #This reflects the total magic Link has, not the total extra he has. basemagic = 8 - if self.has('Quarter Magic'): + if self.has('Quarter Magic', player): basemagic = 32 - elif self.has('Half Magic'): + elif self.has('Half Magic', player): basemagic = 16 - if self.can_buy_unlimited('Green Potion') or self.can_buy_unlimited('Blue Potion'): - if self.world.difficulty == 'hard' and not fullrefill: - basemagic = basemagic + int(basemagic * 0.5 * self.bottle_count()) - elif self.world.difficulty == 'expert' and not fullrefill: - basemagic = basemagic + int(basemagic * 0.25 * self.bottle_count()) - elif self.world.difficulty == 'insane' and not fullrefill: - basemagic = basemagic + if self.can_buy_unlimited('Green Potion', player) or self.can_buy_unlimited('Blue Potion', player): + if self.world.difficulty_adjustments == 'hard' and not fullrefill: + basemagic = basemagic + int(basemagic * 0.5 * self.bottle_count(player)) + elif self.world.difficulty_adjustments == 'expert' and not fullrefill: + basemagic = basemagic + int(basemagic * 0.25 * self.bottle_count(player)) else: - basemagic = basemagic + basemagic * self.bottle_count() + basemagic = basemagic + basemagic * self.bottle_count(player) return basemagic >= smallmagic - def can_kill_most_things(self, enemies=5): - return (self.has_blunt_weapon() - or self.has('Cane of Somaria') - or (self.has('Cane of Byrna') and (enemies < 6 or self.can_extend_magic())) - or self.can_shoot_arrows() - or self.has('Fire Rod') + def can_kill_most_things(self, player, enemies=5): + return (self.has_blunt_weapon(player) + or self.has('Cane of Somaria', player) + or (self.has('Cane of Byrna', player) and (enemies < 6 or self.can_extend_magic(player))) + or self.can_shoot_arrows(player) + or self.has('Fire Rod', player) ) - def can_shoot_arrows(self): + def can_shoot_arrows(self, player): if self.world.retro: #TODO: need to decide how we want to handle wooden arrows longer-term (a can-buy-a check, or via dynamic shop location) #FIXME: Should do something about hard+ ganon only silvers. For the moment, i believe they effective grant wooden, so we are safe - return self.has('Bow') and (self.has('Silver Arrows') or self.can_buy_unlimited('Single Arrow')) - return self.has('Bow') + return self.has('Bow', player) and (self.has('Silver Arrows', player) or self.can_buy_unlimited('Single Arrow', player)) + return self.has('Bow', player) - def can_get_good_bee(self): - cave = self.world.get_region('Good Bee Cave') + def can_get_good_bee(self, player): + cave = self.world.get_region('Good Bee Cave', player) return ( - self.has_bottle() and - self.has('Bug Catching Net') and - (self.has_Boots() or (self.has_sword() and self.has('Quake'))) and + self.has_bottle(player) and + self.has('Bug Catching Net', player) and + (self.has_Boots(player) or (self.has_sword(player) and self.has('Quake', player))) and cave.can_reach(self) and - (cave.is_light_world or self.has_Pearl()) + self.is_not_bunny(cave, player) ) - def has_sword(self): - return self.has('Fighter Sword') or self.has('Master Sword') or self.has('Tempered Sword') or self.has('Golden Sword') + def has_sword(self, player): + return self.has('Fighter Sword', player) or self.has('Master Sword', player) or self.has('Tempered Sword', player) or self.has('Golden Sword', player) - def has_beam_sword(self): - return self.has('Master Sword') or self.has('Tempered Sword') or self.has('Golden Sword') + def has_beam_sword(self, player): + return self.has('Master Sword', player) or self.has('Tempered Sword', player) or self.has('Golden Sword', player) - def has_blunt_weapon(self): - return self.has_sword() or self.has('Hammer') + def has_blunt_weapon(self, player): + return self.has_sword(player) or self.has('Hammer', player) - def has_Mirror(self): - return self.has('Magic Mirror') + def has_Mirror(self, player): + return self.has('Magic Mirror', player) - def has_Boots(self): - return self.has('Pegasus Boots') + def has_Boots(self, player): + return self.has('Pegasus Boots', player) - def has_Pearl(self): - return self.has('Moon Pearl') + def has_Pearl(self, player): + return self.has('Moon Pearl', player) - def has_fire_source(self): - return self.has('Fire Rod') or self.has('Lamp') + def has_fire_source(self, player): + return self.has('Fire Rod', player) or self.has('Lamp', player) - def has_misery_mire_medallion(self): - return self.has(self.world.required_medallions[0]) + def can_flute(self, player): + lw = self.world.get_region('Light World', player) + return self.has('Ocarina', player) and lw.can_reach(self) and self.is_not_bunny(lw, player) - def has_turtle_rock_medallion(self): - return self.has(self.world.required_medallions[1]) + def can_melt_things(self, player): + return self.has('Fire Rod', player) or (self.has('Bombos', player) and self.has_sword(player)) + + def can_avoid_lasers(self, player): + return self.has('Mirror Shield', player) or self.has('Cane of Byrna', player) or self.has('Cape', player) + + def is_not_bunny(self, region, player): + if self.has_Pearl(player): + return True + + return region.is_light_world if self.world.mode != 'inverted' else region.is_dark_world + + def has_misery_mire_medallion(self, player): + return self.has(self.world.required_medallions[player][0], player) + + def has_turtle_rock_medallion(self, player): + return self.has(self.world.required_medallions[player][1], player) def collect(self, item, event=False, location=None): if location: @@ -524,95 +504,118 @@ class CollectionState(object): changed = False if item.name.startswith('Progressive '): if 'Sword' in item.name: - if self.has('Golden Sword'): + if self.has('Golden Sword', item.player): pass - elif self.has('Tempered Sword') and self.world.difficulty_requirements.progressive_sword_limit >= 4: - self.prog_items.append('Golden Sword') + elif self.has('Tempered Sword', item.player) and self.world.difficulty_requirements.progressive_sword_limit >= 4: + self.prog_items.add(('Golden Sword', item.player)) changed = True - elif self.has('Master Sword') and self.world.difficulty_requirements.progressive_sword_limit >= 3: - self.prog_items.append('Tempered Sword') + elif self.has('Master Sword', item.player) and self.world.difficulty_requirements.progressive_sword_limit >= 3: + self.prog_items.add(('Tempered Sword', item.player)) changed = True - elif self.has('Fighter Sword') and self.world.difficulty_requirements.progressive_sword_limit >= 2: - self.prog_items.append('Master Sword') + elif self.has('Fighter Sword', item.player) and self.world.difficulty_requirements.progressive_sword_limit >= 2: + self.prog_items.add(('Master Sword', item.player)) changed = True elif self.world.difficulty_requirements.progressive_sword_limit >= 1: - self.prog_items.append('Fighter Sword') + self.prog_items.add(('Fighter Sword', item.player)) changed = True elif 'Glove' in item.name: - if self.has('Titans Mitts'): + if self.has('Titans Mitts', item.player): pass - elif self.has('Power Glove'): - self.prog_items.append('Titans Mitts') + elif self.has('Power Glove', item.player): + self.prog_items.add(('Titans Mitts', item.player)) changed = True else: - self.prog_items.append('Power Glove') + self.prog_items.add(('Power Glove', item.player)) changed = True elif 'Shield' in item.name: - if self.has('Mirror Shield'): + if self.has('Mirror Shield', item.player): pass - elif self.has('Red Shield') and self.world.difficulty_requirements.progressive_shield_limit >= 3: - self.prog_items.append('Mirror Shield') + elif self.has('Red Shield', item.player) and self.world.difficulty_requirements.progressive_shield_limit >= 3: + self.prog_items.add(('Mirror Shield', item.player)) changed = True - elif self.has('Blue Shield') and self.world.difficulty_requirements.progressive_shield_limit >= 2: - self.prog_items.append('Red Shield') + elif self.has('Blue Shield', item.player) and self.world.difficulty_requirements.progressive_shield_limit >= 2: + self.prog_items.add(('Red Shield', item.player)) changed = True elif self.world.difficulty_requirements.progressive_shield_limit >= 1: - self.prog_items.append('Blue Shield') + self.prog_items.add(('Blue Shield', item.player)) + changed = True + elif 'Bow' in item.name: + if self.has('Silver Arrows', item.player): + pass + elif self.has('Bow', item.player): + self.prog_items.add(('Silver Arrows', item.player)) + changed = True + else: + self.prog_items.add(('Bow', item.player)) changed = True elif item.name.startswith('Bottle'): - if self.bottle_count() < self.world.difficulty_requirements.progressive_bottle_limit: - self.prog_items.append(item.name) + if self.bottle_count(item.player) < self.world.difficulty_requirements.progressive_bottle_limit: + self.prog_items.add((item.name, item.player)) changed = True elif event or item.advancement: - self.prog_items.append(item.name) + self.prog_items.add((item.name, item.player)) changed = True + + self.stale[item.player] = True if changed: - self.clear_cached_unreachable() if not event: self.sweep_for_events() - self.clear_cached_unreachable() def remove(self, item): if item.advancement: to_remove = item.name if to_remove.startswith('Progressive '): if 'Sword' in to_remove: - if self.has('Golden Sword'): + if self.has('Golden Sword', item.player): to_remove = 'Golden Sword' - elif self.has('Tempered Sword'): + elif self.has('Tempered Sword', item.player): to_remove = 'Tempered Sword' - elif self.has('Master Sword'): + elif self.has('Master Sword', item.player): to_remove = 'Master Sword' - elif self.has('Fighter Sword'): + elif self.has('Fighter Sword', item.player): to_remove = 'Fighter Sword' else: to_remove = None elif 'Glove' in item.name: - if self.has('Titans Mitts'): + if self.has('Titans Mitts', item.player): to_remove = 'Titans Mitts' - elif self.has('Power Glove'): + elif self.has('Power Glove', item.player): to_remove = 'Power Glove' else: to_remove = None + elif 'Shield' in item.name: + if self.has('Mirror Shield', item.player): + to_remove = 'Mirror Shield' + elif self.has('Red Shield', item.player): + to_remove = 'Red Shield' + elif self.has('Blue Shield', item.player): + to_remove = 'Blue Shield' + else: + to_remove = 'None' + elif 'Bow' in item.name: + if self.has('Silver Arrows', item.player): + to_remove = 'Silver Arrows' + elif self.has('Bow', item.player): + to_remove = 'Bow' + else: + to_remove = None if to_remove is not None: try: - self.prog_items.remove(to_remove) + self.prog_items.remove((to_remove, item.player)) except ValueError: return # invalidate caches, nothing can be trusted anymore now - self.region_cache = {} - self.location_cache = {} - self.entrance_cache = {} - self.recursion_count = 0 + self.reachable_regions[item.player] = set() + self.stale[item.player] = True def __getattr__(self, item): if item.startswith('can_reach_'): return self.can_reach(item[10]) - elif item.startswith('has_'): - return self.has(item[4]) + #elif item.startswith('has_'): + # return self.has(item[4]) raise RuntimeError('Cannot parse %s.' % item) @@ -631,7 +634,7 @@ class RegionType(Enum): class Region(object): - def __init__(self, name, type, hint): + def __init__(self, name, type, hint, player): self.name = name self.type = type self.entrances = [] @@ -645,10 +648,16 @@ class Region(object): self.spot_type = 'Region' self.hint_text = hint self.recursion_count = 0 + self.player = player def can_reach(self, state): + if state.stale[self.player]: + state.update_reachable_regions(self.player) + return self in state.reachable_regions[self.player] + + def can_reach_private(self, state): for entrance in self.entrances: - if state.can_reach(entrance): + if entrance.can_reach(state): if not self in state.path: state.path[self] = (self.name, state.path.get(entrance, None)) return True @@ -658,7 +667,7 @@ class Region(object): is_dungeon_item = item.key or item.map or item.compass sewer_hack = self.world.mode == 'standard' and item.name == 'Small Key (Escape)' if sewer_hack or (is_dungeon_item and not self.world.keysanity): - return self.dungeon and self.dungeon.is_dungeon_item(item) + return self.dungeon and self.dungeon.is_dungeon_item(item) and item.player == self.player return True @@ -666,12 +675,15 @@ class Region(object): return str(self.__unicode__()) def __unicode__(self): - return '%s' % self.name + if self.world and self.world.players == 1: + return self.name + else: + return '%s (Player %d)' % (self.name, self.player) class Entrance(object): - def __init__(self, name='', parent=None): + def __init__(self, player, name='', parent=None): self.name = name self.parent_region = parent self.connected_region = None @@ -681,9 +693,10 @@ class Entrance(object): self.recursion_count = 0 self.vanilla = None self.access_rule = lambda state: True + self.player = player def can_reach(self, state): - if self.access_rule(state) and state.can_reach(self.parent_region): + if self.parent_region.can_reach(state) and self.access_rule(state): if not self in state.path: state.path[self] = (self.name, state.path.get(self.parent_region, (self.parent_region.name, None))) return True @@ -701,18 +714,23 @@ class Entrance(object): return str(self.__unicode__()) def __unicode__(self): - return '%s' % self.name + if self.parent_region and self.parent_region.world and self.parent_region.world.players == 1: + return self.name + else: + return '%s (Player %d)' % (self.name, self.player) class Dungeon(object): - def __init__(self, name, regions, big_key, small_keys, dungeon_items): + def __init__(self, name, regions, big_key, small_keys, dungeon_items, player): self.name = name self.regions = regions self.big_key = big_key self.small_keys = small_keys self.dungeon_items = dungeon_items self.bosses = dict() + self.player = player + self.world = None @property def boss(self): @@ -731,25 +749,29 @@ class Dungeon(object): return self.dungeon_items + self.keys def is_dungeon_item(self, item): - return item.name in [dungeon_item.name for dungeon_item in self.all_items] + return item.player == self.player and item.name in [dungeon_item.name for dungeon_item in self.all_items] def __str__(self): return str(self.__unicode__()) def __unicode__(self): - return '%s' % self.name + if self.world and self.world.players==1: + return self.name + else: + return '%s (Player %d)' % (self.name, self.player) class Boss(object): - def __init__(self, name, enemizer_name, defeat_rule): + def __init__(self, name, enemizer_name, defeat_rule, player): self.name = name self.enemizer_name = enemizer_name self.defeat_rule = defeat_rule + self.player = player def can_defeat(self, state): - return self.defeat_rule(state) + return self.defeat_rule(state, self.player) class Location(object): - def __init__(self, name='', address=None, crystal=False, hint_text=None, parent=None): + def __init__(self, player, name='', address=None, crystal=False, hint_text=None, parent=None): self.name = name self.parent_region = parent self.item = None @@ -760,15 +782,17 @@ class Location(object): self.recursion_count = 0 self.staleness_count = 0 self.event = False + self.locked = True self.always_allow = lambda item, state: False self.access_rule = lambda state: True self.item_rule = lambda item: True + self.player = player def can_fill(self, state, item, check_access=True): return self.always_allow(state, item) or (self.parent_region.can_fill(item) and self.item_rule(item) and (not check_access or self.can_reach(state))) def can_reach(self, state): - if self.access_rule(state) and state.can_reach(self.parent_region): + if self.parent_region.can_reach(state) and self.access_rule(state): return True return False @@ -776,12 +800,15 @@ class Location(object): return str(self.__unicode__()) def __unicode__(self): - return '%s' % self.name + if self.parent_region and self.parent_region.world and self.parent_region.world.players == 1: + return self.name + else: + return '%s (Player %d)' % (self.name, self.player) class Item(object): - def __init__(self, name='', advancement=False, priority=False, type=None, code=None, pedestal_hint=None, pedestal_credit=None, sickkid_credit=None, zora_credit=None, witch_credit=None, fluteboy_credit=None, hint_text=None): + def __init__(self, name='', advancement=False, priority=False, type=None, code=None, pedestal_hint=None, pedestal_credit=None, sickkid_credit=None, zora_credit=None, witch_credit=None, fluteboy_credit=None, hint_text=None, player=None): self.name = name self.advancement = advancement self.priority = priority @@ -795,6 +822,7 @@ class Item(object): self.hint_text = hint_text self.code = code self.location = None + self.player = player @property def key(self): @@ -816,7 +844,10 @@ class Item(object): return str(self.__unicode__()) def __unicode__(self): - return '%s' % self.name + if self.location and self.location.parent_region and self.location.parent_region.world and self.location.parent_region.world.players == 1: + return self.name + else: + return '%s (Player %d)' % (self.name, self.player) # have 6 address that need to be filled @@ -898,11 +929,21 @@ class Spoiler(object): self.shops = [] self.bosses = OrderedDict() - def set_entrance(self, entrance, exit, direction): - self.entrances[(entrance, direction)] = OrderedDict([('entrance', entrance), ('exit', exit), ('direction', direction)]) + def set_entrance(self, entrance, exit, direction, player): + if self.world.players == 1: + self.entrances[(entrance, direction, player)] = OrderedDict([('entrance', entrance), ('exit', exit), ('direction', direction)]) + else: + self.entrances[(entrance, direction, player)] = OrderedDict([('player', player), ('entrance', entrance), ('exit', exit), ('direction', direction)]) def parse_data(self): - self.medallions = OrderedDict([('Misery Mire', self.world.required_medallions[0]), ('Turtle Rock', self.world.required_medallions[1])]) + self.medallions = OrderedDict() + if self.world.players == 1: + self.medallions['Misery Mire'] = self.world.required_medallions[1][0] + self.medallions['Turtle Rock'] = self.world.required_medallions[1][1] + else: + for player in range(1, self.world.players + 1): + self.medallions['Misery Mire (Player %d)' % player] = self.world.required_medallions[player][0] + self.medallions['Turtle Rock (Player %d)' % player] = self.world.required_medallions[player][1] self.locations = OrderedDict() listed_locations = set() @@ -921,7 +962,7 @@ class Spoiler(object): for dungeon in self.world.dungeons: dungeon_locations = [loc for loc in self.world.get_locations() if loc not in listed_locations and loc.parent_region and loc.parent_region.dungeon == dungeon] - self.locations[dungeon.name] = OrderedDict([(str(location), str(location.item) if location.item is not None else 'Nothing') for location in dungeon_locations]) + self.locations[str(dungeon)] = OrderedDict([(str(location), str(location.item) if location.item is not None else 'Nothing') for location in dungeon_locations]) listed_locations.update(dungeon_locations) other_locations = [loc for loc in self.world.get_locations() if loc not in listed_locations] @@ -929,10 +970,11 @@ class Spoiler(object): self.locations['Other Locations'] = OrderedDict([(str(location), str(location.item) if location.item is not None else 'Nothing') for location in other_locations]) listed_locations.update(other_locations) + self.shops = [] for shop in self.world.shops: if not shop.active: continue - shopdata = {'location': shop.region.name, + shopdata = {'location': str(shop.region), 'type': 'Take Any' if shop.type == ShopType.TakeAny else 'Shop' } for index, item in enumerate(shop.inventory): @@ -941,41 +983,47 @@ class Spoiler(object): shopdata['item_{}'.format(index)] = "{} — {}".format(item['item'], item['price']) if item['price'] else item['item'] self.shops.append(shopdata) - self.bosses["Eastern Palace"] = self.world.get_dungeon("Eastern Palace").boss.name - self.bosses["Desert Palace"] = self.world.get_dungeon("Desert Palace").boss.name - self.bosses["Tower Of Hera"] = self.world.get_dungeon("Tower of Hera").boss.name - self.bosses["Hyrule Castle"] = "Agahnim" - self.bosses["Palace Of Darkness"] = self.world.get_dungeon("Palace of Darkness").boss.name - self.bosses["Swamp Palace"] = self.world.get_dungeon("Swamp Palace").boss.name - self.bosses["Skull Woods"] = self.world.get_dungeon("Skull Woods").boss.name - self.bosses["Thieves Town"] = self.world.get_dungeon("Thieves Town").boss.name - self.bosses["Ice Palace"] = self.world.get_dungeon("Ice Palace").boss.name - self.bosses["Misery Mire"] = self.world.get_dungeon("Misery Mire").boss.name - self.bosses["Turtle Rock"] = self.world.get_dungeon("Turtle Rock").boss.name - self.bosses["Ganons Tower Basement"] = self.world.get_dungeon('Ganons Tower').bosses['bottom'].name - self.bosses["Ganons Tower Middle"] = self.world.get_dungeon('Ganons Tower').bosses['middle'].name - self.bosses["Ganons Tower Top"] = self.world.get_dungeon('Ganons Tower').bosses['top'].name - self.bosses["Ganons Tower"] = "Agahnim 2" - self.bosses["Ganon"] = "Ganon" + for player in range(1, self.world.players + 1): + self.bosses[str(player)] = OrderedDict() + self.bosses[str(player)]["Eastern Palace"] = self.world.get_dungeon("Eastern Palace", player).boss.name + self.bosses[str(player)]["Desert Palace"] = self.world.get_dungeon("Desert Palace", player).boss.name + self.bosses[str(player)]["Tower Of Hera"] = self.world.get_dungeon("Tower of Hera", player).boss.name + self.bosses[str(player)]["Hyrule Castle"] = "Agahnim" + self.bosses[str(player)]["Palace Of Darkness"] = self.world.get_dungeon("Palace of Darkness", player).boss.name + self.bosses[str(player)]["Swamp Palace"] = self.world.get_dungeon("Swamp Palace", player).boss.name + self.bosses[str(player)]["Skull Woods"] = self.world.get_dungeon("Skull Woods", player).boss.name + self.bosses[str(player)]["Thieves Town"] = self.world.get_dungeon("Thieves Town", player).boss.name + self.bosses[str(player)]["Ice Palace"] = self.world.get_dungeon("Ice Palace", player).boss.name + self.bosses[str(player)]["Misery Mire"] = self.world.get_dungeon("Misery Mire", player).boss.name + self.bosses[str(player)]["Turtle Rock"] = self.world.get_dungeon("Turtle Rock", player).boss.name + if self.world.mode != 'inverted': + self.bosses[str(player)]["Ganons Tower Basement"] = self.world.get_dungeon('Ganons Tower', player).bosses['bottom'].name + self.bosses[str(player)]["Ganons Tower Middle"] = self.world.get_dungeon('Ganons Tower', player).bosses['middle'].name + self.bosses[str(player)]["Ganons Tower Top"] = self.world.get_dungeon('Ganons Tower', player).bosses['top'].name + else: + self.bosses[str(player)]["Ganons Tower Basement"] = self.world.get_dungeon('Inverted Ganons Tower', player).bosses['bottom'].name + self.bosses[str(player)]["Ganons Tower Middle"] = self.world.get_dungeon('Inverted Ganons Tower', player).bosses['middle'].name + self.bosses[str(player)]["Ganons Tower Top"] = self.world.get_dungeon('Inverted Ganons Tower', player).bosses['top'].name + self.bosses[str(player)]["Ganons Tower"] = "Agahnim 2" + self.bosses[str(player)]["Ganon"] = "Ganon" + + if self.world.players == 1: + self.bosses = self.bosses["1"] from Main import __version__ as ERVersion self.metadata = {'version': ERVersion, - 'seed': self.world.seed, 'logic': self.world.logic, 'mode': self.world.mode, + 'weapons': self.world.swords, 'goal': self.world.goal, 'shuffle': self.world.shuffle, - 'algorithm': self.world.algorithm, - 'difficulty': self.world.difficulty, - 'timer': self.world.timer, - 'progressive': self.world.progressive, - 'completeable': not self.world.check_beatable_only, - 'dungeonitems': self.world.place_dungeon_items, - 'quickswap': self.world.quickswap, - 'fastmenu': self.world.fastmenu, - 'disable_music': self.world.disable_music, - 'keysanity': self.world.keysanity} + 'item_pool': self.world.difficulty, + 'item_functionality': self.world.difficulty_adjustments, + 'accessibility': self.world.accessibility, + 'hints': self.world.hints, + 'keysanity': self.world.keysanity, + } def to_json(self): self.parse_data() @@ -996,23 +1044,31 @@ class Spoiler(object): def to_file(self, filename): self.parse_data() with open(filename, 'w') as outfile: - outfile.write('ALttP Entrance Randomizer Version %s - Seed: %s\n\n' % (self.metadata['version'], self.metadata['seed'])) + outfile.write('ALttP Entrance Randomizer Version %s - Seed: %s\n\n' % (self.metadata['version'], self.world.seed)) outfile.write('Logic: %s\n' % self.metadata['logic']) outfile.write('Mode: %s\n' % self.metadata['mode']) outfile.write('Goal: %s\n' % self.metadata['goal']) + outfile.write('Difficulty: %s\n' % self.metadata['item_pool']) + outfile.write('Item Functionality: %s\n' % self.metadata['item_functionality']) outfile.write('Entrance Shuffle: %s\n' % self.metadata['shuffle']) - outfile.write('Filling Algorithm: %s\n' % self.metadata['algorithm']) - outfile.write('All Locations Accessible: %s\n' % ('Yes' if self.metadata['completeable'] else 'No, some locations may be unreachable')) - outfile.write('Maps and Compasses in Dungeons: %s\n' % ('Yes' if self.metadata['dungeonitems'] else 'No')) - outfile.write('L\\R Quickswap enabled: %s\n' % ('Yes' if self.metadata['quickswap'] else 'No')) - outfile.write('Menu speed: %s\n' % self.metadata['fastmenu']) - outfile.write('Keysanity enabled: %s' % ('Yes' if self.metadata['keysanity'] else 'No')) + outfile.write('Filling Algorithm: %s\n' % self.world.algorithm) + outfile.write('Accessibility: %s\n' % self.metadata['accessibility']) + outfile.write('Maps and Compasses in Dungeons: %s\n' % ('Yes' if self.world.place_dungeon_items else 'No')) + outfile.write('L\\R Quickswap enabled: %s\n' % ('Yes' if self.world.quickswap else 'No')) + outfile.write('Menu speed: %s\n' % self.world.fastmenu) + outfile.write('Keysanity enabled: %s\n' % ('Yes' if self.metadata['keysanity'] else 'No')) + outfile.write('Players: %d' % self.world.players) if self.entrances: outfile.write('\n\nEntrances:\n\n') - outfile.write('\n'.join(['%s %s %s' % (entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances.values()])) - outfile.write('\n\nMedallions') - outfile.write('\n\nMisery Mire Medallion: %s' % self.medallions['Misery Mire']) - outfile.write('\nTurtle Rock Medallion: %s' % self.medallions['Turtle Rock']) + outfile.write('\n'.join(['%s%s %s %s' % ('Player {0}: '.format(entry['player']) if self.world.players >1 else '', entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances.values()])) + outfile.write('\n\nMedallions\n') + if self.world.players == 1: + outfile.write('\nMisery Mire Medallion: %s' % (self.medallions['Misery Mire'])) + outfile.write('\nTurtle Rock Medallion: %s' % (self.medallions['Turtle Rock'])) + else: + for player in range(1, self.world.players + 1): + outfile.write('\nMisery Mire Medallion (Player %d): %s' % (player, self.medallions['Misery Mire (Player %d)' % player])) + outfile.write('\nTurtle Rock Medallion (Player %d): %s' % (player, self.medallions['Turtle Rock (Player %d)' % player])) outfile.write('\n\nLocations:\n\n') outfile.write('\n'.join(['%s: %s' % (location, item) for grouping in self.locations.values() for (location, item) in grouping.items()])) outfile.write('\n\nShops:\n\n') diff --git a/Bosses.py b/Bosses.py index 20c7aabfba..2713c92c6b 100644 --- a/Bosses.py +++ b/Bosses.py @@ -4,101 +4,101 @@ import random from BaseClasses import Boss from Fill import FillError -def BossFactory(boss): +def BossFactory(boss, player): if boss is None: return None if boss in boss_table: enemizer_name, defeat_rule = boss_table[boss] - return Boss(boss, enemizer_name, defeat_rule) + return Boss(boss, enemizer_name, defeat_rule, player) logging.getLogger('').error('Unknown Boss: %s', boss) return None -def ArmosKnightsDefeatRule(state): +def ArmosKnightsDefeatRule(state, player): # Magic amounts are probably a bit overkill return ( - state.has_blunt_weapon() or - (state.has('Cane of Somaria') and state.can_extend_magic(10)) or - (state.has('Cane of Byrna') and state.can_extend_magic(16)) or - (state.has('Ice Rod') and state.can_extend_magic(32)) or - (state.has('Fire Rod') and state.can_extend_magic(32)) or - state.has('Blue Boomerang') or - state.has('Red Boomerang')) + state.has_blunt_weapon(player) or + (state.has('Cane of Somaria', player) and state.can_extend_magic(player, 10)) or + (state.has('Cane of Byrna', player) and state.can_extend_magic(player, 16)) or + (state.has('Ice Rod', player) and state.can_extend_magic(player, 32)) or + (state.has('Fire Rod', player) and state.can_extend_magic(player, 32)) or + state.has('Blue Boomerang', player) or + state.has('Red Boomerang', player)) -def LanmolasDefeatRule(state): +def LanmolasDefeatRule(state, player): # TODO: Allow the canes here? return ( - state.has_blunt_weapon() or - state.has('Fire Rod') or - state.has('Ice Rod') or - state.can_shoot_arrows()) + state.has_blunt_weapon(player) or + state.has('Fire Rod', player) or + state.has('Ice Rod', player) or + state.can_shoot_arrows(player)) -def MoldormDefeatRule(state): - return state.has_blunt_weapon() +def MoldormDefeatRule(state, player): + return state.has_blunt_weapon(player) -def HelmasaurKingDefeatRule(state): - return state.has_blunt_weapon() or state.can_shoot_arrows() +def HelmasaurKingDefeatRule(state, player): + return state.has_blunt_weapon(player) or state.can_shoot_arrows(player) -def ArrghusDefeatRule(state): - if not state.has('Hookshot'): +def ArrghusDefeatRule(state, player): + if not state.has('Hookshot', player): return False # TODO: ideally we would have a check for bow and silvers, which combined with the # hookshot is enough. This is not coded yet because the silvers that only work in pyramid feature # makes this complicated - if state.has_blunt_weapon(): + if state.has_blunt_weapon(player): return True - return ((state.has('Fire Rod') and (state.can_shoot_arrows() or state.can_extend_magic(12))) or #assuming mostly gitting two puff with one shot - (state.has('Ice Rod') and (state.can_shoot_arrows() or state.can_extend_magic(16)))) + return ((state.has('Fire Rod', player) and (state.can_shoot_arrows(player) or state.can_extend_magic(player, 12))) or #assuming mostly gitting two puff with one shot + (state.has('Ice Rod', player) and (state.can_shoot_arrows(player) or state.can_extend_magic(player, 16)))) -def MothulaDefeatRule(state): +def MothulaDefeatRule(state, player): return ( - state.has_blunt_weapon() or - (state.has('Fire Rod') and state.can_extend_magic(10)) or + state.has_blunt_weapon(player) or + (state.has('Fire Rod', player) and state.can_extend_magic(player, 10)) or # TODO: Not sure how much (if any) extend magic is needed for these two, since they only apply # to non-vanilla locations, so are harder to test, so sticking with what VT has for now: - (state.has('Cane of Somaria') and state.can_extend_magic(16)) or - (state.has('Cane of Byrna') and state.can_extend_magic(16)) or - state.can_get_good_bee() + (state.has('Cane of Somaria', player) and state.can_extend_magic(player, 16)) or + (state.has('Cane of Byrna', player) and state.can_extend_magic(player, 16)) or + state.can_get_good_bee(player) ) -def BlindDefeatRule(state): - return state.has_blunt_weapon() or state.has('Cane of Somaria') or state.has('Cane of Byrna') +def BlindDefeatRule(state, player): + return state.has_blunt_weapon(player) or state.has('Cane of Somaria', player) or state.has('Cane of Byrna', player) -def KholdstareDefeatRule(state): +def KholdstareDefeatRule(state, player): return ( ( - state.has('Fire Rod') or + state.has('Fire Rod', player) or ( - state.has('Bombos') and - # FIXME: the following only actually works for the vanilla location for swordless mode - (state.has_sword() or state.world.mode == 'swordless') + state.has('Bombos', player) and + # FIXME: the following only actually works for the vanilla location for swordless + (state.has_sword(player) or state.world.swords == 'swordless') ) ) and ( - state.has_blunt_weapon() or - (state.has('Fire Rod') and state.can_extend_magic(20)) or - # FIXME: this actually only works for the vanilla location for swordless mode + state.has_blunt_weapon(player) or + (state.has('Fire Rod', player) and state.can_extend_magic(player, 20)) or + # FIXME: this actually only works for the vanilla location for swordless ( - state.has('Fire Rod') and - state.has('Bombos') and - state.world.mode == 'swordless' and - state.can_extend_magic(16) + state.has('Fire Rod', player) and + state.has('Bombos', player) and + state.world.swords == 'swordless' and + state.can_extend_magic(player, 16) ) ) ) -def VitreousDefeatRule(state): - return state.can_shoot_arrows() or state.has_blunt_weapon() +def VitreousDefeatRule(state, player): + return state.can_shoot_arrows(player) or state.has_blunt_weapon(player) -def TrinexxDefeatRule(state): - if not (state.has('Fire Rod') and state.has('Ice Rod')): +def TrinexxDefeatRule(state, player): + if not (state.has('Fire Rod', player) and state.has('Ice Rod', player)): return False - return state.has('Hammer') or state.has_beam_sword() or (state.has_sword() and state.can_extend_magic(32)) + return state.has('Hammer', player) or state.has_beam_sword(player) or (state.has_sword(player) and state.can_extend_magic(player, 32)) -def AgahnimDefeatRule(state): - return state.has_sword() or state.has('Hammer') or state.has('Bug Catching Net') +def AgahnimDefeatRule(state, player): + return state.has_sword(player) or state.has('Hammer', player) or state.has('Bug Catching Net', player) boss_table = { 'Armos Knights': ('Armos', ArmosKnightsDefeatRule), @@ -116,14 +116,14 @@ boss_table = { } def can_place_boss(world, boss, dungeon_name, level=None): - if world.mode in ['swordless'] and boss == 'Kholdstare' and dungeon_name != 'Ice Palace': + if world.swords in ['swordless'] and boss == 'Kholdstare' and dungeon_name != 'Ice Palace': return False - if dungeon_name == 'Ganons Tower' and level == 'top': + if dungeon_name in ['Ganons Tower', 'Inverted Ganons Tower'] and level == 'top': if boss in ["Armos Knights", "Arrghus", "Blind", "Trinexx", "Lanmolas"]: return False - if dungeon_name == 'Ganons Tower' and level == 'middle': + if dungeon_name in ['Ganons Tower', 'Inverted Ganons Tower'] and level == 'middle': if boss in ["Blind"]: return False @@ -137,32 +137,50 @@ def can_place_boss(world, boss, dungeon_name, level=None): return False return True -def place_bosses(world): +def place_bosses(world, player): if world.boss_shuffle == 'none': return # Most to least restrictive order - boss_locations = [ - ['Ganons Tower', 'top'], - ['Tower of Hera', None], - ['Skull Woods', None], - ['Ganons Tower', 'middle'], - ['Eastern Palace', None], - ['Desert Palace', None], - ['Palace of Darkness', None], - ['Swamp Palace', None], - ['Thieves Town', None], - ['Ice Palace', None], - ['Misery Mire', None], - ['Turtle Rock', None], - ['Ganons Tower', 'bottom'], - ] + if world.mode != 'inverted': + boss_locations = [ + ['Ganons Tower', 'top'], + ['Tower of Hera', None], + ['Skull Woods', None], + ['Ganons Tower', 'middle'], + ['Eastern Palace', None], + ['Desert Palace', None], + ['Palace of Darkness', None], + ['Swamp Palace', None], + ['Thieves Town', None], + ['Ice Palace', None], + ['Misery Mire', None], + ['Turtle Rock', None], + ['Ganons Tower', 'bottom'], + ] + else: + boss_locations = [ + ['Inverted Ganons Tower', 'top'], + ['Tower of Hera', None], + ['Skull Woods', None], + ['Inverted Ganons Tower', 'middle'], + ['Eastern Palace', None], + ['Desert Palace', None], + ['Palace of Darkness', None], + ['Swamp Palace', None], + ['Thieves Town', None], + ['Ice Palace', None], + ['Misery Mire', None], + ['Turtle Rock', None], + ['Inverted Ganons Tower', 'bottom'], + ] + all_bosses = sorted(boss_table.keys()) #s orted to be deterministic on older pythons placeable_bosses = [boss for boss in all_bosses if boss not in ['Agahnim', 'Agahnim2', 'Ganon']] if world.boss_shuffle in ["basic", "normal"]: # temporary hack for swordless kholdstare: - if world.mode == 'swordless': - world.get_dungeon('Ice Palace').boss = BossFactory('Kholdstare') + if world.swords == 'swordless': + world.get_dungeon('Ice Palace', player).boss = BossFactory('Kholdstare', player) logging.getLogger('').debug('Placing boss Kholdstare at Ice Palace') boss_locations.remove(['Ice Palace', None]) placeable_bosses.remove('Kholdstare') @@ -183,7 +201,7 @@ def place_bosses(world): bosses.remove(boss) logging.getLogger('').debug('Placing boss %s at %s', boss, loc_text) - world.get_dungeon(loc).bosses[level] = BossFactory(boss) + world.get_dungeon(loc, player).bosses[level] = BossFactory(boss, player) elif world.boss_shuffle == "chaos": #all bosses chosen at random for [loc, level] in boss_locations: loc_text = loc + (' ('+level+')' if level else '') @@ -193,4 +211,4 @@ def place_bosses(world): raise FillError('Could not place boss for location %s' % loc_text) logging.getLogger('').debug('Placing boss %s at %s', boss, loc_text) - world.get_dungeon(loc).bosses[level] = BossFactory(boss) + world.get_dungeon(loc, player).bosses[level] = BossFactory(boss, player) diff --git a/Dungeons.py b/Dungeons.py index 1ef2c17db9..3e412f70d5 100644 --- a/Dungeons.py +++ b/Dungeons.py @@ -6,44 +6,53 @@ from Fill import fill_restrictive from Items import ItemFactory -def create_dungeons(world): +def create_dungeons(world, player): def make_dungeon(name, default_boss, dungeon_regions, big_key, small_keys, dungeon_items): - dungeon = Dungeon(name, dungeon_regions, big_key, [] if world.retro else small_keys, dungeon_items) - dungeon.boss = BossFactory(default_boss) + dungeon = Dungeon(name, dungeon_regions, big_key, [] if world.retro else small_keys, dungeon_items, player) + dungeon.boss = BossFactory(default_boss, player) for region in dungeon.regions: - world.get_region(region).dungeon = dungeon + world.get_region(region, player).dungeon = dungeon + dungeon.world = world return dungeon - ES = make_dungeon('Hyrule Castle', None, ['Hyrule Castle', 'Sewers', 'Sewer Drop', 'Sewers (Dark)', 'Sanctuary'], None, [ItemFactory('Small Key (Escape)')], [ItemFactory('Map (Escape)')]) - EP = make_dungeon('Eastern Palace', 'Armos Knights', ['Eastern Palace'], ItemFactory('Big Key (Eastern Palace)'), [], ItemFactory(['Map (Eastern Palace)', 'Compass (Eastern Palace)'])) - DP = make_dungeon('Desert Palace', 'Lanmolas', ['Desert Palace North', 'Desert Palace Main (Inner)', 'Desert Palace Main (Outer)', 'Desert Palace East'], ItemFactory('Big Key (Desert Palace)'), [ItemFactory('Small Key (Desert Palace)')], ItemFactory(['Map (Desert Palace)', 'Compass (Desert Palace)'])) - ToH = make_dungeon('Tower of Hera', 'Moldorm', ['Tower of Hera (Bottom)', 'Tower of Hera (Basement)', 'Tower of Hera (Top)'], ItemFactory('Big Key (Tower of Hera)'), [ItemFactory('Small Key (Tower of Hera)')], ItemFactory(['Map (Tower of Hera)', 'Compass (Tower of Hera)'])) - AT = make_dungeon('Agahnims Tower', 'Agahnim', ['Agahnims Tower', 'Agahnim 1'], None, ItemFactory(['Small Key (Agahnims Tower)'] * 2), []) - PoD = make_dungeon('Palace of Darkness', 'Helmasaur King', ['Palace of Darkness (Entrance)', 'Palace of Darkness (Center)', 'Palace of Darkness (Big Key Chest)', 'Palace of Darkness (Bonk Section)', 'Palace of Darkness (North)', 'Palace of Darkness (Maze)', 'Palace of Darkness (Harmless Hellway)', 'Palace of Darkness (Final Section)'], ItemFactory('Big Key (Palace of Darkness)'), ItemFactory(['Small Key (Palace of Darkness)'] * 6), ItemFactory(['Map (Palace of Darkness)', 'Compass (Palace of Darkness)'])) - TT = make_dungeon('Thieves Town', 'Blind', ['Thieves Town (Entrance)', 'Thieves Town (Deep)', 'Blind Fight'], ItemFactory('Big Key (Thieves Town)'), [ItemFactory('Small Key (Thieves Town)')], ItemFactory(['Map (Thieves Town)', 'Compass (Thieves Town)'])) - SW = make_dungeon('Skull Woods', 'Mothula', ['Skull Woods Final Section (Entrance)', 'Skull Woods First Section', 'Skull Woods Second Section', 'Skull Woods Second Section (Drop)', 'Skull Woods Final Section (Mothula)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Left)', 'Skull Woods First Section (Top)'], ItemFactory('Big Key (Skull Woods)'), ItemFactory(['Small Key (Skull Woods)'] * 2), ItemFactory(['Map (Skull Woods)', 'Compass (Skull Woods)'])) - SP = make_dungeon('Swamp Palace', 'Arrghus', ['Swamp Palace (Entrance)', 'Swamp Palace (First Room)', 'Swamp Palace (Starting Area)', 'Swamp Palace (Center)', 'Swamp Palace (North)'], ItemFactory('Big Key (Swamp Palace)'), [ItemFactory('Small Key (Swamp Palace)')], ItemFactory(['Map (Swamp Palace)', 'Compass (Swamp Palace)'])) - IP = make_dungeon('Ice Palace', 'Kholdstare', ['Ice Palace (Entrance)', 'Ice Palace (Main)', 'Ice Palace (East)', 'Ice Palace (East Top)', 'Ice Palace (Kholdstare)'], ItemFactory('Big Key (Ice Palace)'), ItemFactory(['Small Key (Ice Palace)'] * 2), ItemFactory(['Map (Ice Palace)', 'Compass (Ice Palace)'])) - MM = make_dungeon('Misery Mire', 'Vitreous', ['Misery Mire (Entrance)', 'Misery Mire (Main)', 'Misery Mire (West)', 'Misery Mire (Final Area)', 'Misery Mire (Vitreous)'], ItemFactory('Big Key (Misery Mire)'), ItemFactory(['Small Key (Misery Mire)'] * 3), ItemFactory(['Map (Misery Mire)', 'Compass (Misery Mire)'])) - TR = make_dungeon('Turtle Rock', 'Trinexx', ['Turtle Rock (Entrance)', 'Turtle Rock (First Section)', 'Turtle Rock (Chain Chomp Room)', 'Turtle Rock (Second Section)', 'Turtle Rock (Big Chest)', 'Turtle Rock (Crystaroller Room)', 'Turtle Rock (Dark Room)', 'Turtle Rock (Eye Bridge)', 'Turtle Rock (Trinexx)'], ItemFactory('Big Key (Turtle Rock)'), ItemFactory(['Small Key (Turtle Rock)'] * 4), ItemFactory(['Map (Turtle Rock)', 'Compass (Turtle Rock)'])) - GT = make_dungeon('Ganons Tower', 'Agahnim2', ['Ganons Tower (Entrance)', 'Ganons Tower (Tile Room)', 'Ganons Tower (Compass Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower (Map Room)', 'Ganons Tower (Firesnake Room)', 'Ganons Tower (Teleport Room)', 'Ganons Tower (Bottom)', 'Ganons Tower (Top)', 'Ganons Tower (Before Moldorm)', 'Ganons Tower (Moldorm)', 'Agahnim 2'], ItemFactory('Big Key (Ganons Tower)'), ItemFactory(['Small Key (Ganons Tower)'] * 4), ItemFactory(['Map (Ganons Tower)', 'Compass (Ganons Tower)'])) + ES = make_dungeon('Hyrule Castle', None, ['Hyrule Castle', 'Sewers', 'Sewer Drop', 'Sewers (Dark)', 'Sanctuary'], None, [ItemFactory('Small Key (Escape)', player)], [ItemFactory('Map (Escape)', player)]) + EP = make_dungeon('Eastern Palace', 'Armos Knights', ['Eastern Palace'], ItemFactory('Big Key (Eastern Palace)', player), [], ItemFactory(['Map (Eastern Palace)', 'Compass (Eastern Palace)'], player)) + DP = make_dungeon('Desert Palace', 'Lanmolas', ['Desert Palace North', 'Desert Palace Main (Inner)', 'Desert Palace Main (Outer)', 'Desert Palace East'], ItemFactory('Big Key (Desert Palace)', player), [ItemFactory('Small Key (Desert Palace)', player)], ItemFactory(['Map (Desert Palace)', 'Compass (Desert Palace)'], player)) + ToH = make_dungeon('Tower of Hera', 'Moldorm', ['Tower of Hera (Bottom)', 'Tower of Hera (Basement)', 'Tower of Hera (Top)'], ItemFactory('Big Key (Tower of Hera)', player), [ItemFactory('Small Key (Tower of Hera)', player)], ItemFactory(['Map (Tower of Hera)', 'Compass (Tower of Hera)'], player)) + PoD = make_dungeon('Palace of Darkness', 'Helmasaur King', ['Palace of Darkness (Entrance)', 'Palace of Darkness (Center)', 'Palace of Darkness (Big Key Chest)', 'Palace of Darkness (Bonk Section)', 'Palace of Darkness (North)', 'Palace of Darkness (Maze)', 'Palace of Darkness (Harmless Hellway)', 'Palace of Darkness (Final Section)'], ItemFactory('Big Key (Palace of Darkness)', player), ItemFactory(['Small Key (Palace of Darkness)'] * 6, player), ItemFactory(['Map (Palace of Darkness)', 'Compass (Palace of Darkness)'], player)) + TT = make_dungeon('Thieves Town', 'Blind', ['Thieves Town (Entrance)', 'Thieves Town (Deep)', 'Blind Fight'], ItemFactory('Big Key (Thieves Town)', player), [ItemFactory('Small Key (Thieves Town)', player)], ItemFactory(['Map (Thieves Town)', 'Compass (Thieves Town)'], player)) + SW = make_dungeon('Skull Woods', 'Mothula', ['Skull Woods Final Section (Entrance)', 'Skull Woods First Section', 'Skull Woods Second Section', 'Skull Woods Second Section (Drop)', 'Skull Woods Final Section (Mothula)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Left)', 'Skull Woods First Section (Top)'], ItemFactory('Big Key (Skull Woods)', player), ItemFactory(['Small Key (Skull Woods)'] * 2, player), ItemFactory(['Map (Skull Woods)', 'Compass (Skull Woods)'], player)) + SP = make_dungeon('Swamp Palace', 'Arrghus', ['Swamp Palace (Entrance)', 'Swamp Palace (First Room)', 'Swamp Palace (Starting Area)', 'Swamp Palace (Center)', 'Swamp Palace (North)'], ItemFactory('Big Key (Swamp Palace)', player), [ItemFactory('Small Key (Swamp Palace)', player)], ItemFactory(['Map (Swamp Palace)', 'Compass (Swamp Palace)'], player)) + IP = make_dungeon('Ice Palace', 'Kholdstare', ['Ice Palace (Entrance)', 'Ice Palace (Main)', 'Ice Palace (East)', 'Ice Palace (East Top)', 'Ice Palace (Kholdstare)'], ItemFactory('Big Key (Ice Palace)', player), ItemFactory(['Small Key (Ice Palace)'] * 2, player), ItemFactory(['Map (Ice Palace)', 'Compass (Ice Palace)'], player)) + MM = make_dungeon('Misery Mire', 'Vitreous', ['Misery Mire (Entrance)', 'Misery Mire (Main)', 'Misery Mire (West)', 'Misery Mire (Final Area)', 'Misery Mire (Vitreous)'], ItemFactory('Big Key (Misery Mire)', player), ItemFactory(['Small Key (Misery Mire)'] * 3, player), ItemFactory(['Map (Misery Mire)', 'Compass (Misery Mire)'], player)) + TR = make_dungeon('Turtle Rock', 'Trinexx', ['Turtle Rock (Entrance)', 'Turtle Rock (First Section)', 'Turtle Rock (Chain Chomp Room)', 'Turtle Rock (Second Section)', 'Turtle Rock (Big Chest)', 'Turtle Rock (Crystaroller Room)', 'Turtle Rock (Dark Room)', 'Turtle Rock (Eye Bridge)', 'Turtle Rock (Trinexx)'], ItemFactory('Big Key (Turtle Rock)', player), ItemFactory(['Small Key (Turtle Rock)'] * 4, player), ItemFactory(['Map (Turtle Rock)', 'Compass (Turtle Rock)'], player)) - GT.bosses['bottom'] = BossFactory('Armos Knights') - GT.bosses['middle'] = BossFactory('Lanmolas') - GT.bosses['top'] = BossFactory('Moldorm') + if world.mode != 'inverted': + AT = make_dungeon('Agahnims Tower', 'Agahnim', ['Agahnims Tower', 'Agahnim 1'], None, ItemFactory(['Small Key (Agahnims Tower)'] * 2, player), []) + GT = make_dungeon('Ganons Tower', 'Agahnim2', ['Ganons Tower (Entrance)', 'Ganons Tower (Tile Room)', 'Ganons Tower (Compass Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower (Map Room)', 'Ganons Tower (Firesnake Room)', 'Ganons Tower (Teleport Room)', 'Ganons Tower (Bottom)', 'Ganons Tower (Top)', 'Ganons Tower (Before Moldorm)', 'Ganons Tower (Moldorm)', 'Agahnim 2'], ItemFactory('Big Key (Ganons Tower)', player), ItemFactory(['Small Key (Ganons Tower)'] * 4, player), ItemFactory(['Map (Ganons Tower)', 'Compass (Ganons Tower)'], player)) + else: + AT = make_dungeon('Inverted Agahnims Tower', 'Agahnim', ['Inverted Agahnims Tower', 'Agahnim 1'], None, ItemFactory(['Small Key (Agahnims Tower)'] * 2, player), []) + GT = make_dungeon('Inverted Ganons Tower', 'Agahnim2', ['Inverted Ganons Tower (Entrance)', 'Ganons Tower (Tile Room)', 'Ganons Tower (Compass Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower (Map Room)', 'Ganons Tower (Firesnake Room)', 'Ganons Tower (Teleport Room)', 'Ganons Tower (Bottom)', 'Ganons Tower (Top)', 'Ganons Tower (Before Moldorm)', 'Ganons Tower (Moldorm)', 'Agahnim 2'], ItemFactory('Big Key (Ganons Tower)', player), ItemFactory(['Small Key (Ganons Tower)'] * 4, player), ItemFactory(['Map (Ganons Tower)', 'Compass (Ganons Tower)'], player)) - world.dungeons = [ES, EP, DP, ToH, AT, PoD, TT, SW, SP, IP, MM, TR, GT] + GT.bosses['bottom'] = BossFactory('Armos Knights', player) + GT.bosses['middle'] = BossFactory('Lanmolas', player) + GT.bosses['top'] = BossFactory('Moldorm', player) + + world.dungeons += [ES, EP, DP, ToH, AT, PoD, TT, SW, SP, IP, MM, TR, GT] def fill_dungeons(world): freebes = ['Ganons Tower - Map Chest', 'Palace of Darkness - Harmless Hellway', 'Palace of Darkness - Big Key Chest', 'Turtle Rock - Big Key Chest'] all_state_base = world.get_all_state() - if world.retro: - world.push_item(world.get_location('Skull Woods - Pinball Room'), ItemFactory('Small Key (Universal)'), False) - else: - world.push_item(world.get_location('Skull Woods - Pinball Room'), ItemFactory('Small Key (Skull Woods)'), False) - world.get_location('Skull Woods - Pinball Room').event = True + for player in range(1, world.players + 1): + pinball_room = world.get_location('Skull Woods - Pinball Room', player) + if world.retro: + world.push_item(pinball_room, ItemFactory('Small Key (Universal)', player), False) + else: + world.push_item(pinball_room, ItemFactory('Small Key (Skull Woods)', player), False) + pinball_room.event = True + pinball_room.locked = True dungeons = [(list(dungeon.regions), dungeon.big_key, list(dungeon.small_keys), list(dungeon.dungeon_items)) for dungeon in world.dungeons] @@ -70,8 +79,8 @@ def fill_dungeons(world): world.push_item(bk_location, big_key, False) bk_location.event = True + bk_location.locked = True dungeon_locations.remove(bk_location) - all_state.clear_cached_unreachable() big_key = None # next place small keys @@ -89,15 +98,15 @@ def fill_dungeons(world): small_keys.append(small_key) dungeons.append((dungeon_regions, big_key, small_keys, dungeon_items)) # infinite regression protection - if loopcnt < 30: + if loopcnt < (30 * world.players): break else: raise RuntimeError('No suitable location for %s' % small_key) world.push_item(sk_location, small_key, False) sk_location.event = True + sk_location.locked = True dungeon_locations.remove(sk_location) - all_state.clear_cached_unreachable() if small_keys: # key placement not finished, loop again @@ -109,7 +118,6 @@ def fill_dungeons(world): di_location = dungeon_locations.pop() world.push_item(di_location, dungeon_item, False) - world.state.clear_cached_unreachable() def get_dungeon_item_pool(world): return [item for dungeon in world.dungeons for item in dungeon.all_items if item.key or world.place_dungeon_items] @@ -117,13 +125,15 @@ def get_dungeon_item_pool(world): def fill_dungeons_restrictive(world, shuffled_locations): all_state_base = world.get_all_state() - skull_woods_big_chest = world.get_location('Skull Woods - Pinball Room') - if world.retro: - world.push_item(skull_woods_big_chest, ItemFactory('Small Key (Universal)'), False) - else: - world.push_item(skull_woods_big_chest, ItemFactory('Small Key (Skull Woods)'), False) - skull_woods_big_chest.event = True - shuffled_locations.remove(skull_woods_big_chest) + for player in range(1, world.players + 1): + pinball_room = world.get_location('Skull Woods - Pinball Room', player) + if world.retro: + world.push_item(pinball_room, ItemFactory('Small Key (Universal)', player), False) + else: + world.push_item(pinball_room, ItemFactory('Small Key (Skull Woods)', player), False) + pinball_room.event = True + pinball_room.locked = True + shuffled_locations.remove(pinball_room) if world.keysanity: #in keysanity dungeon items are distributed as part of the normal item pool @@ -142,7 +152,6 @@ def fill_dungeons_restrictive(world, shuffled_locations): fill_restrictive(world, all_state_base, shuffled_locations, dungeon_items) - world.state.clear_cached_unreachable() dungeon_music_addresses = {'Eastern Palace - Prize': [0x1559A], diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index fed67800a8..46908a9b8a 100755 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -6,9 +6,8 @@ import random import textwrap import sys -from Gui import guiMain from Main import main -from Utils import is_bundled, close_console +from Utils import is_bundled, close_console, output_path class ArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter): @@ -29,7 +28,7 @@ def start(): No Logic: Distribute items without regard for item requirements. ''') - parser.add_argument('--mode', default='open', const='open', nargs='?', choices=['standard', 'open', 'swordless'], + parser.add_argument('--mode', default='open', const='open', nargs='?', choices=['standard', 'open', 'inverted'], help='''\ Select game mode. (default: %(default)s) Open: World starts with Zelda rescued. @@ -37,12 +36,24 @@ def start(): but may lead to weird rain state issues if you exit through the Hyrule Castle side exits before rescuing Zelda in a full shuffle. - Swordless: Like Open, but with no swords. Curtains in - Skull Woods and Agahnims Tower are removed, - Agahnim\'s Tower barrier can be destroyed with - hammer. Misery Mire and Turtle Rock can be opened - without a sword. Hammer damages Ganon. Ether and - Bombos Tablet can be activated with Hammer (and Book). + Inverted: Starting locations are Dark Sanctuary in West Dark + World or at Link's House, which is shuffled freely. + Requires the moon pearl to be Link in the Light World + instead of a bunny. + ''') + parser.add_argument('--swords', default='random', const='random', nargs='?', choices= ['random', 'assured', 'swordless', 'vanilla'], + help='''\ + Select sword placement. (default: %(default)s) + Random: All swords placed randomly. + Assured: Start game with a sword already. + Swordless: No swords. Curtains in Skull Woods and Agahnim\'s + Tower are removed, Agahnim\'s Tower barrier can be + destroyed with hammer. Misery Mire and Turtle Rock + can be opened without a sword. Hammer damages Ganon. + Ether and Bombos Tablet can be activated with Hammer + (and Book). Bombos pads have been added in Ice + Palace, to allow for an alternative to firerod. + Vanilla: Swords are in vanilla locations. ''') parser.add_argument('--goal', default='ganon', const='ganon', nargs='?', choices=['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'], help='''\ @@ -56,15 +67,20 @@ def start(): Triforce Hunt: Places 30 Triforce Pieces in the world, collect 20 of them to beat the game. ''') - parser.add_argument('--difficulty', default='normal', const='normal', nargs='?', choices=['easy', 'normal', 'hard', 'expert', 'insane'], + parser.add_argument('--difficulty', default='normal', const='normal', nargs='?', choices=['normal', 'hard', 'expert'], help='''\ Select game difficulty. Affects available itempool. (default: %(default)s) - Easy: An easy setting with extra equipment. Normal: Normal difficulty. Hard: A harder setting with less equipment and reduced health. Expert: A harder yet setting with minimum equipment and health. - Insane: A setting with the absolute minimum in equipment and no extra health. ''') + parser.add_argument('--item_functionality', default='normal', const='normal', nargs='?', choices=['normal', 'hard', 'expert'], + help='''\ + Select limits on item functionality to increase difficulty. (default: %(default)s) + Normal: Normal functionality. + Hard: Reduced functionality. + Expert: Greatly reduced functionality. + ''') parser.add_argument('--timer', default='none', const='normal', nargs='?', choices=['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'], help='''\ Select game timer setting. Affects available itempool. (default: %(default)s) @@ -146,6 +162,23 @@ def start(): The dungeon variants only mix up dungeons and keep the rest of the overworld vanilla. ''') + parser.add_argument('--crystals_ganon', default='7', const='7', nargs='?', choices=['random', '0', '1', '2', '3', '4', '5', '6', '7'], + help='''\ + How many crystals are needed to defeat ganon. Any other + requirements for ganon for the selected goal still apply. + This setting does not apply when the all dungeons goal is + selected. (default: %(default)s) + Random: Picks a random value between 0 and 7 (inclusive). + 0-7: Number of crystals needed + ''') + parser.add_argument('--crystals_gt', default='7', const='7', nargs='?', choices=['random', '0', '1', '2', '3', '4', '5', '6', '7'], + help='''\ + How many crystals are needed to open GT. For inverted mode + this applies to the castle tower door instead. (default: %(default)s) + Random: Picks a random value between 0 and 7 (inclusive). + 0-7: Number of crystals needed + ''') + parser.add_argument('--rom', default='Zelda no Densetsu - Kamigami no Triforce (Japan).sfc', help='Path to an ALttP JAP(1.0) rom to use as a base.') parser.add_argument('--loglevel', default='info', const='info', nargs='?', choices=['error', 'info', 'warning', 'debug'], help='Select level of logging for output.') parser.add_argument('--seed', help='Define seed number to generate.', type=int) @@ -177,11 +210,13 @@ def start(): Remove Maps and Compasses from Itempool, replacing them by empty slots. ''', action='store_true') - parser.add_argument('--beatableonly', help='''\ - Only check if the game is beatable with placement. Do not - ensure all locations are reachable. This only has an effect - on the restrictive algorithm currently. - ''', action='store_true') + parser.add_argument('--accessibility', default='items', const='items', nargs='?', choices=['items', 'locations', 'none'], help='''\ + Select Item/Location Accessibility. (default: %(default)s) + Items: You can reach all unique inventory items. No guarantees about + reaching all locations or all keys. + Locations: You will be able to reach every location in the game. + None: You will be able to reach enough locations to beat the game. + ''') parser.add_argument('--hints', help='''\ Make telepathic tiles and storytellers give helpful hints. ''', action='store_true') @@ -207,19 +242,32 @@ def start(): ''') parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true') parser.add_argument('--gui', help='Launch the GUI', action='store_true') - # Deliberately not documented, only useful for vt site integration right now: - parser.add_argument('--shufflebosses', help=argparse.SUPPRESS, default='none', const='none', nargs='?', choices=['none', 'basic', 'normal', 'chaos']) parser.add_argument('--jsonout', action='store_true', help='''\ Output .json patch to stdout instead of a patched rom. Used for VT site integration, do not use otherwise. ''') + parser.add_argument('--skip_playthrough', action='store_true', default=False) + parser.add_argument('--enemizercli', default='') + parser.add_argument('--shufflebosses', default='none', choices=['none', 'basic', 'normal', 'chaos']) + parser.add_argument('--shuffleenemies', default=False, action='store_true') + parser.add_argument('--enemy_health', default='default', choices=['default', 'easy', 'normal', 'hard', 'expert']) + parser.add_argument('--enemy_damage', default='default', choices=['default', 'shuffled', 'chaos']) + parser.add_argument('--shufflepalette', default=False, action='store_true') + parser.add_argument('--shufflepots', default=False, action='store_true') + parser.add_argument('--multi', default=1, type=lambda value: min(max(int(value), 1), 255)) + + parser.add_argument('--outputpath') args = parser.parse_args() + if args.outputpath and os.path.isdir(args.outputpath): + output_path.cached_path = args.outputpath + if is_bundled() and len(sys.argv) == 1: # for the bundled builds, if we have no arguments, the user # probably wants the gui. Users of the bundled build who want the command line # interface shouuld specify at least one option, possibly setting a value to a # default if they like all the defaults + from Gui import guiMain close_console() guiMain() sys.exit(0) @@ -240,6 +288,7 @@ def start(): logging.basicConfig(format='%(message)s', level=loglevel) if args.gui: + from Gui import guiMain guiMain(args) elif args.count is not None: seed = args.seed diff --git a/EntranceShuffle.py b/EntranceShuffle.py index 73709adb5a..1cd053bad6 100644 --- a/EntranceShuffle.py +++ b/EntranceShuffle.py @@ -3,9 +3,9 @@ import random # ToDo: With shuffle_ganon option, prevent gtower from linking to an exit only location through a 2 entrance cave. -def link_entrances(world): - connect_two_way(world, 'Links House', 'Links House Exit') # unshuffled. For now - connect_exit(world, 'Chris Houlihan Room Exit', 'Links House') # should always match link's house, except for plandos +def link_entrances(world, player): + connect_two_way(world, 'Links House', 'Links House Exit', player) # unshuffled. For now + connect_exit(world, 'Chris Houlihan Room Exit', 'Links House', player) # should always match link's house, except for plandos Dungeon_Exits = Dungeon_Exits_Base.copy() Cave_Exits = Cave_Exits_Base.copy() @@ -16,24 +16,24 @@ def link_entrances(world): # setup mandatory connections for exitname, regionname in mandatory_connections: - connect_simple(world, exitname, regionname) + connect_simple(world, exitname, regionname, player) # if we do not shuffle, set default connections if world.shuffle == 'vanilla': for exitname, regionname in default_connections: - connect_simple(world, exitname, regionname) + connect_simple(world, exitname, regionname, player) for exitname, regionname in default_dungeon_connections: - connect_simple(world, exitname, regionname) + connect_simple(world, exitname, regionname, player) elif world.shuffle == 'dungeonssimple': for exitname, regionname in default_connections: - connect_simple(world, exitname, regionname) + connect_simple(world, exitname, regionname, player) - simple_shuffle_dungeons(world) + simple_shuffle_dungeons(world, player) elif world.shuffle == 'dungeonsfull': for exitname, regionname in default_connections: - connect_simple(world, exitname, regionname) + connect_simple(world, exitname, regionname, player) - skull_woods_shuffle(world) + skull_woods_shuffle(world, player) dungeon_exits = list(Dungeon_Exits) lw_entrances = list(LW_Dungeon_Entrances) @@ -41,26 +41,26 @@ def link_entrances(world): if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) else: dungeon_exits.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) lw_entrances.append('Hyrule Castle Entrance (South)') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) else: dw_entrances.append('Ganons Tower') dungeon_exits.append('Ganons Tower Exit') if world.mode == 'standard': # rest of hyrule castle must be in light world, so it has to be the one connected to east exit of desert - connect_mandatory_exits(world, lw_entrances, [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')], list(LW_Dungeon_Entrances_Must_Exit)) + connect_mandatory_exits(world, lw_entrances, [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')], list(LW_Dungeon_Entrances_Must_Exit), player) else: - connect_mandatory_exits(world, lw_entrances, dungeon_exits, list(LW_Dungeon_Entrances_Must_Exit)) - connect_mandatory_exits(world, dw_entrances, dungeon_exits, list(DW_Dungeon_Entrances_Must_Exit)) - connect_caves(world, lw_entrances, dw_entrances, dungeon_exits) + connect_mandatory_exits(world, lw_entrances, dungeon_exits, list(LW_Dungeon_Entrances_Must_Exit), player) + connect_mandatory_exits(world, dw_entrances, dungeon_exits, list(DW_Dungeon_Entrances_Must_Exit), player) + connect_caves(world, lw_entrances, dw_entrances, dungeon_exits, player) elif world.shuffle == 'simple': - simple_shuffle_dungeons(world) + simple_shuffle_dungeons(world, player) old_man_entrances = list(Old_Man_Entrances) caves = list(Cave_Exits) @@ -79,8 +79,8 @@ def link_entrances(world): while two_door_caves: entrance1, entrance2 = two_door_caves.pop() exit1, exit2 = caves.pop() - connect_two_way(world, entrance1, exit1) - connect_two_way(world, entrance2, exit2) + connect_two_way(world, entrance1, exit1, player) + connect_two_way(world, entrance2, exit2, player) # now the remaining pairs two_door_caves = list(Two_Door_Caves) @@ -88,8 +88,8 @@ def link_entrances(world): while two_door_caves: entrance1, entrance2 = two_door_caves.pop() exit1, exit2 = caves.pop() - connect_two_way(world, entrance1, exit1) - connect_two_way(world, entrance2, exit2) + connect_two_way(world, entrance1, exit1, player) + connect_two_way(world, entrance2, exit2, player) # at this point only Light World death mountain entrances remain # place old man, has limited options @@ -100,38 +100,38 @@ def link_entrances(world): remaining_entrances.extend(old_man_entrances) random.shuffle(remaining_entrances) old_man_entrance = remaining_entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) # add old man house to ensure it is always somewhere on light death mountain caves.extend(list(Old_Man_House)) caves.extend(list(three_exit_caves)) # connect rest - connect_caves(world, remaining_entrances, [], caves) + connect_caves(world, remaining_entrances, [], caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) # place blacksmith, has limited options random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) bomb_shop_doors.extend(blacksmith_doors) # place bomb shop, has limited options random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) single_doors.extend(bomb_shop_doors) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # place remaining doors - connect_doors(world, single_doors, door_targets) + connect_doors(world, single_doors, door_targets, player) elif world.shuffle == 'restricted': - simple_shuffle_dungeons(world) + simple_shuffle_dungeons(world, player) lw_entrances = list(LW_Entrances + LW_Single_Cave_Doors + Old_Man_Entrances) dw_entrances = list(DW_Entrances + DW_Single_Cave_Doors) @@ -144,17 +144,17 @@ def link_entrances(world): door_targets = list(Single_Cave_Targets) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # in restricted, the only mandatory exits are in dark world - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) # place old man, has limited options # exit has to come from specific set of doors, the entrance is free to move about old_man_entrances = [door for door in old_man_entrances if door in lw_entrances] random.shuffle(old_man_entrances) old_man_exit = old_man_entrances.pop() - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) lw_entrances.remove(old_man_exit) # place blacksmith, has limited options @@ -163,7 +163,7 @@ def link_entrances(world): blacksmith_doors = [door for door in blacksmith_doors if door in all_entrances] random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) if blacksmith_hut in lw_entrances: lw_entrances.remove(blacksmith_hut) if blacksmith_hut in dw_entrances: @@ -176,7 +176,7 @@ def link_entrances(world): bomb_shop_doors = [door for door in bomb_shop_doors if door in all_entrances] random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) if bomb_shop in lw_entrances: lw_entrances.remove(bomb_shop) if bomb_shop in dw_entrances: @@ -185,24 +185,24 @@ def link_entrances(world): # place the old man cave's entrance somewhere in the light world random.shuffle(lw_entrances) old_man_entrance = lw_entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) # place Old Man House in Light World - connect_caves(world, lw_entrances, [], list(Old_Man_House)) #for multiple seeds + connect_caves(world, lw_entrances, [], list(Old_Man_House), player) #for multiple seeds # now scramble the rest - connect_caves(world, lw_entrances, dw_entrances, caves) + connect_caves(world, lw_entrances, dw_entrances, caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) doors = lw_entrances + dw_entrances # place remaining doors - connect_doors(world, doors, door_targets) + connect_doors(world, doors, door_targets, player) elif world.shuffle == 'restricted_legacy': - simple_shuffle_dungeons(world) + simple_shuffle_dungeons(world, player) lw_entrances = list(LW_Entrances) dw_entrances = list(DW_Entrances) @@ -216,7 +216,7 @@ def link_entrances(world): door_targets = list(Single_Cave_Targets) # only use two exit caves to do mandatory dw connections - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) # add three exit doors to pool for remainder caves.extend(three_exit_caves) @@ -227,37 +227,37 @@ def link_entrances(world): lw_entrances.extend(old_man_entrances) random.shuffle(lw_entrances) old_man_entrance = lw_entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) # place Old Man House in Light World - connect_caves(world, lw_entrances, [], Old_Man_House) + connect_caves(world, lw_entrances, [], Old_Man_House, player) # connect rest. There's 2 dw entrances remaining, so we will not run into parity issue placing caves - connect_caves(world, lw_entrances, dw_entrances, caves) + connect_caves(world, lw_entrances, dw_entrances, caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) # place blacksmith, has limited options random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) bomb_shop_doors.extend(blacksmith_doors) # place dam and pyramid fairy, have limited options random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) single_doors.extend(bomb_shop_doors) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # place remaining doors - connect_doors(world, single_doors, door_targets) + connect_doors(world, single_doors, door_targets, player) elif world.shuffle == 'full': - skull_woods_shuffle(world) + skull_woods_shuffle(world, player) lw_entrances = list(LW_Entrances + LW_Dungeon_Entrances + LW_Single_Cave_Doors + Old_Man_Entrances) dw_entrances = list(DW_Entrances + DW_Dungeon_Entrances + DW_Single_Cave_Doors) @@ -271,17 +271,17 @@ def link_entrances(world): old_man_house = list(Old_Man_House) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) else: caves.append(tuple(random.sample(['Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)'],3))) lw_entrances.append('Hyrule Castle Entrance (South)') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) else: dw_entrances.append('Ganons Tower') caves.append('Ganons Tower Exit') @@ -291,34 +291,34 @@ def link_entrances(world): #we also places the Old Man House at this time to make sure he can be connected to the desert one way if random.randint(0, 1) == 0: caves += old_man_house - connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits) + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player) try: caves.remove(old_man_house[0]) except ValueError: pass else: #if the cave wasn't placed we get here - connect_caves(world, lw_entrances, [], old_man_house) - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) + connect_caves(world, lw_entrances, [], old_man_house, player) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) else: - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) caves += old_man_house - connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits) + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player) try: caves.remove(old_man_house[0]) except ValueError: pass else: #if the cave wasn't placed we get here - connect_caves(world, lw_entrances, [], old_man_house) + connect_caves(world, lw_entrances, [], old_man_house, player) if world.mode == 'standard': # rest of hyrule castle must be in light world - connect_caves(world, lw_entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')]) + connect_caves(world, lw_entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')], player) # place old man, has limited options # exit has to come from specific set of doors, the entrance is free to move about old_man_entrances = [door for door in old_man_entrances if door in lw_entrances] random.shuffle(old_man_entrances) old_man_exit = old_man_entrances.pop() - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) lw_entrances.remove(old_man_exit) # place blacksmith, has limited options @@ -327,7 +327,7 @@ def link_entrances(world): blacksmith_doors = [door for door in blacksmith_doors if door in all_entrances] random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) if blacksmith_hut in lw_entrances: lw_entrances.remove(blacksmith_hut) if blacksmith_hut in dw_entrances: @@ -340,7 +340,7 @@ def link_entrances(world): bomb_shop_doors = [door for door in bomb_shop_doors if door in all_entrances] random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) if bomb_shop in lw_entrances: lw_entrances.remove(bomb_shop) if bomb_shop in dw_entrances: @@ -348,21 +348,21 @@ def link_entrances(world): # place the old man cave's entrance somewhere in the light world old_man_entrance = lw_entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) # now scramble the rest - connect_caves(world, lw_entrances, dw_entrances, caves) + connect_caves(world, lw_entrances, dw_entrances, caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) doors = lw_entrances + dw_entrances # place remaining doors - connect_doors(world, doors, door_targets) + connect_doors(world, doors, door_targets, player) elif world.shuffle == 'crossed': - skull_woods_shuffle(world) + skull_woods_shuffle(world, player) entrances = list(LW_Entrances + LW_Dungeon_Entrances + LW_Single_Cave_Doors + Old_Man_Entrances + DW_Entrances + DW_Dungeon_Entrances + DW_Single_Cave_Doors) must_exits = list(DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit + LW_Dungeon_Entrances_Must_Exit) @@ -374,34 +374,34 @@ def link_entrances(world): door_targets = list(Single_Cave_Targets) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) else: caves.append(tuple(random.sample(['Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)'],3))) entrances.append('Hyrule Castle Entrance (South)') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) else: entrances.append('Ganons Tower') caves.append('Ganons Tower Exit') #place must-exit caves - connect_mandatory_exits(world, entrances, caves, must_exits) + connect_mandatory_exits(world, entrances, caves, must_exits, player) if world.mode == 'standard': # rest of hyrule castle must be dealt with - connect_caves(world, entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')]) + connect_caves(world, entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')], player) # place old man, has limited options # exit has to come from specific set of doors, the entrance is free to move about old_man_entrances = [door for door in old_man_entrances if door in entrances] random.shuffle(old_man_entrances) old_man_exit = old_man_entrances.pop() - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) entrances.remove(old_man_exit) # place blacksmith, has limited options @@ -409,7 +409,7 @@ def link_entrances(world): blacksmith_doors = [door for door in blacksmith_doors if door in entrances] random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) entrances.remove(blacksmith_hut) bomb_shop_doors.extend(blacksmith_doors) @@ -419,26 +419,26 @@ def link_entrances(world): bomb_shop_doors = [door for door in bomb_shop_doors if door in entrances] random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) entrances.remove(bomb_shop) # place the old man cave's entrance somewhere random.shuffle(entrances) old_man_entrance = entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) # now scramble the rest - connect_caves(world, entrances, [], caves) + connect_caves(world, entrances, [], caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) # place remaining doors - connect_doors(world, entrances, door_targets) + connect_doors(world, entrances, door_targets, player) elif world.shuffle == 'full_legacy': - skull_woods_shuffle(world) + skull_woods_shuffle(world, player) lw_entrances = list(LW_Entrances + LW_Dungeon_Entrances + Old_Man_Entrances) dw_entrances = list(DW_Entrances + DW_Dungeon_Entrances) @@ -453,27 +453,27 @@ def link_entrances(world): if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) else: caves.append(tuple(random.sample(['Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)'],3))) lw_entrances.append('Hyrule Castle Entrance (South)') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) else: dw_entrances.append('Ganons Tower') caves.append('Ganons Tower Exit') # we randomize which world requirements we fulfill first so we get better dungeon distribution if random.randint(0, 1) == 0: - connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits) - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) else: - connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits) - connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits) + connect_mandatory_exits(world, dw_entrances, caves, dw_must_exits, player) + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player) if world.mode == 'standard': # rest of hyrule castle must be in light world - connect_caves(world, lw_entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')]) + connect_caves(world, lw_entrances, [], [('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')], player) # place old man, has limited options # exit has to come from specific set of doors, the entrance is free to move about @@ -484,35 +484,35 @@ def link_entrances(world): random.shuffle(lw_entrances) old_man_entrance = lw_entrances.pop() - connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)') - connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)') + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) # place Old Man House in Light World - connect_caves(world, lw_entrances, [], list(Old_Man_House)) #need this to avoid badness with multiple seeds + connect_caves(world, lw_entrances, [], list(Old_Man_House), player) #need this to avoid badness with multiple seeds # now scramble the rest - connect_caves(world, lw_entrances, dw_entrances, caves) + connect_caves(world, lw_entrances, dw_entrances, caves, player) # scramble holes - scramble_holes(world) + scramble_holes(world, player) # place blacksmith, has limited options random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) bomb_shop_doors.extend(blacksmith_doors) # place bomb shop, has limited options random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) single_doors.extend(bomb_shop_doors) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # place remaining doors - connect_doors(world, single_doors, door_targets) + connect_doors(world, single_doors, door_targets, player) elif world.shuffle == 'madness_legacy': # here lie dragons, connections are no longer two way lw_entrances = list(LW_Entrances + LW_Dungeon_Entrances + Old_Man_Entrances) @@ -520,7 +520,7 @@ def link_entrances(world): dw_entrances_must_exits = list(DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit) lw_doors = list(LW_Entrances + LW_Dungeon_Entrances + LW_Dungeon_Entrances_Must_Exit) + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', - 'Lumberjack Tree Cave', 'Hyrule Castle Secret Entrance Stairs'] + list(Old_Man_Entrances) + 'Lumberjack Tree Cave'] + list(Old_Man_Entrances) dw_doors = list(DW_Entrances + DW_Dungeon_Entrances + DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit) + ['Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)'] random.shuffle(lw_doors) @@ -530,7 +530,7 @@ def link_entrances(world): dw_entrances.append('Skull Woods Second Section Door (East)') dw_entrances.append('Skull Woods First Section Door') - lw_entrances.extend(['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Entrance (South)']) + lw_entrances.extend(['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave']) lw_entrances_must_exits = list(LW_Dungeon_Entrances_Must_Exit) @@ -554,18 +554,19 @@ def link_entrances(world): if world.mode == 'standard': # cannot move uncle cave - connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance') - connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs') - connect_entrance(world, lw_doors.pop(), 'Hyrule Castle Secret Entrance Exit') + connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance', player) + connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs', player) + connect_entrance(world, 'Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Exit', player) else: lw_hole_entrances.append('Hyrule Castle Secret Entrance Drop') hole_targets.append(('Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance')) + lw_doors.append('Hyrule Castle Secret Entrance Stairs') lw_entrances.append('Hyrule Castle Secret Entrance Stairs') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') - connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit') - connect_entrance(world, 'Pyramid Hole', 'Pyramid') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) + connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Pyramid Hole', 'Pyramid', player) else: dw_entrances.append('Ganons Tower') caves.append('Ganons Tower Exit') @@ -587,32 +588,32 @@ def link_entrances(world): sw_hole_pool = dw_hole_entrances mandatory_dark_world.append('Skull Woods First Section Exit') for target in ['Skull Woods First Section (Left)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Top)']: - connect_entrance(world, sw_hole_pool.pop(), target) + connect_entrance(world, sw_hole_pool.pop(), target, player) # sanctuary has to be in light world - connect_entrance(world, lw_hole_entrances.pop(), 'Sewer Drop') + connect_entrance(world, lw_hole_entrances.pop(), 'Sewer Drop', player) mandatory_light_world.append('Sanctuary Exit') # fill up remaining holes for hole in dw_hole_entrances: exits, target = hole_targets.pop() mandatory_dark_world.append(exits) - connect_entrance(world, hole, target) + connect_entrance(world, hole, target, player) for hole in lw_hole_entrances: exits, target = hole_targets.pop() mandatory_light_world.append(exits) - connect_entrance(world, hole, target) + connect_entrance(world, hole, target, player) # hyrule castle handling if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') - random.shuffle(lw_entrances) - connect_exit(world, 'Hyrule Castle Exit (South)', lw_entrances.pop()) + connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_exit(world, 'Hyrule Castle Exit (South)', 'Hyrule Castle Entrance (South)', player) mandatory_light_world.append(('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) else: lw_doors.append('Hyrule Castle Entrance (South)') + lw_entrances.append('Hyrule Castle Entrance (South)') caves.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) # now let's deal with mandatory reachable stuff @@ -648,8 +649,8 @@ def link_entrances(world): exit = cave[-1] cave = cave[:-1] - connect_exit(world, exit, entrance) - connect_entrance(world, worldoors.pop(), exit) + connect_exit(world, exit, entrance, player) + connect_entrance(world, worldoors.pop(), exit, player) # rest of cave now is forced to be in this world worldspecific.append(cave) @@ -672,8 +673,8 @@ def link_entrances(world): old_man_exit = old_man_entrances.pop() lw_entrances.remove(old_man_exit) - connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit) - connect_entrance(world, lw_doors.pop(), 'Old Man Cave Exit (East)') + connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit, player) + connect_entrance(world, lw_doors.pop(), 'Old Man Cave Exit (East)', player) mandatory_light_world.append('Old Man Cave Exit (West)') # we connect up the mandatory associations we have found @@ -682,18 +683,18 @@ def link_entrances(world): mandatory = (mandatory,) for exit in mandatory: # point out somewhere - connect_exit(world, exit, lw_entrances.pop()) + connect_exit(world, exit, lw_entrances.pop(), player) # point in from somewhere - connect_entrance(world, lw_doors.pop(), exit) + connect_entrance(world, lw_doors.pop(), exit, player) for mandatory in mandatory_dark_world: if not isinstance(mandatory, tuple): mandatory = (mandatory,) for exit in mandatory: # point out somewhere - connect_exit(world, exit, dw_entrances.pop()) + connect_exit(world, exit, dw_entrances.pop(), player) # point in from somewhere - connect_entrance(world, dw_doors.pop(), exit) + connect_entrance(world, dw_doors.pop(), exit, player) # handle remaining caves while caves: @@ -727,8 +728,8 @@ def link_entrances(world): target_entrances = dw_entrances for exit in cave: - connect_exit(world, exit, target_entrances.pop()) - connect_entrance(world, target_doors.pop(), exit) + connect_exit(world, exit, target_entrances.pop(), player) + connect_entrance(world, target_doors.pop(), exit, player) # handle simple doors @@ -740,27 +741,27 @@ def link_entrances(world): # place blacksmith, has limited options random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) bomb_shop_doors.extend(blacksmith_doors) # place dam and pyramid fairy, have limited options random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) single_doors.extend(bomb_shop_doors) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # place remaining doors - connect_doors(world, single_doors, door_targets) + connect_doors(world, single_doors, door_targets, player) elif world.shuffle == 'insanity': # beware ye who enter here - entrances = LW_Entrances + LW_Dungeon_Entrances + DW_Entrances + DW_Dungeon_Entrances + Old_Man_Entrances + ['Skull Woods Second Section Door (East)', 'Skull Woods First Section Door', 'Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Entrance (South)'] + entrances = LW_Entrances + LW_Dungeon_Entrances + DW_Entrances + DW_Dungeon_Entrances + Old_Man_Entrances + ['Skull Woods Second Section Door (East)', 'Skull Woods First Section Door', 'Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave'] entrances_must_exits = DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit + LW_Dungeon_Entrances_Must_Exit + ['Skull Woods Second Section Door (West)'] - doors = LW_Entrances + LW_Dungeon_Entrances + LW_Dungeon_Entrances_Must_Exit + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Secret Entrance Stairs'] + Old_Man_Entrances +\ + doors = LW_Entrances + LW_Dungeon_Entrances + LW_Dungeon_Entrances_Must_Exit + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave'] + Old_Man_Entrances +\ DW_Entrances + DW_Dungeon_Entrances + DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit + ['Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)'] +\ LW_Single_Cave_Doors + DW_Single_Cave_Doors @@ -789,23 +790,24 @@ def link_entrances(world): 'Skull Woods First Section (Left)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Top)'] # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) if world.mode == 'standard': # cannot move uncle cave - connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance') - connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs') - connect_entrance(world, doors.pop(), 'Hyrule Castle Secret Entrance Exit') + connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance', player) + connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs', player) + connect_entrance(world, 'Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Exit', player) else: hole_entrances.append('Hyrule Castle Secret Entrance Drop') hole_targets.append('Hyrule Castle Secret Entrance') + doors.append('Hyrule Castle Secret Entrance Stairs') entrances.append('Hyrule Castle Secret Entrance Stairs') caves.append('Hyrule Castle Secret Entrance Exit') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') - connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit') - connect_entrance(world, 'Pyramid Hole', 'Pyramid') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) + connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Pyramid Hole', 'Pyramid', player) else: entrances.append('Ganons Tower') caves.extend(['Ganons Tower Exit', 'Pyramid Exit']) @@ -820,16 +822,17 @@ def link_entrances(world): # fill up holes for hole in hole_entrances: - connect_entrance(world, hole, hole_targets.pop()) + connect_entrance(world, hole, hole_targets.pop(), player) # hyrule castle handling if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') - connect_exit(world, 'Hyrule Castle Exit (South)', entrances.pop()) + connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_exit(world, 'Hyrule Castle Exit (South)', 'Hyrule Castle Entrance (South)', player) caves.append(('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) else: doors.append('Hyrule Castle Entrance (South)') + entrances.append('Hyrule Castle Entrance (South)') caves.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) # now let's deal with mandatory reachable stuff @@ -854,8 +857,8 @@ def link_entrances(world): exit = cave[-1] cave = cave[:-1] - connect_exit(world, exit, entrance) - connect_entrance(world, doors.pop(), exit) + connect_exit(world, exit, entrance, player) + connect_entrance(world, doors.pop(), exit, player) # rest of cave now is forced to be in this world caves.append(cave) @@ -870,22 +873,22 @@ def link_entrances(world): old_man_exit = old_man_entrances.pop() entrances.remove(old_man_exit) - connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit) - connect_entrance(world, doors.pop(), 'Old Man Cave Exit (East)') + connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit, player) + connect_entrance(world, doors.pop(), 'Old Man Cave Exit (East)', player) caves.append('Old Man Cave Exit (West)') # place blacksmith, has limited options blacksmith_doors = [door for door in blacksmith_doors if door in doors] random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) doors.remove(blacksmith_hut) # place dam and pyramid fairy, have limited options bomb_shop_doors = [door for door in bomb_shop_doors if door in doors] random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) doors.remove(bomb_shop) # handle remaining caves @@ -894,19 +897,19 @@ def link_entrances(world): cave = (cave,) for exit in cave: - connect_exit(world, exit, entrances.pop()) - connect_entrance(world, doors.pop(), exit) + connect_exit(world, exit, entrances.pop(), player) + connect_entrance(world, doors.pop(), exit, player) # place remaining doors - connect_doors(world, doors, door_targets) + connect_doors(world, doors, door_targets, player) elif world.shuffle == 'insanity_legacy': world.fix_fake_world = False # beware ye who enter here - entrances = LW_Entrances + LW_Dungeon_Entrances + DW_Entrances + DW_Dungeon_Entrances + Old_Man_Entrances + ['Skull Woods Second Section Door (East)', 'Skull Woods First Section Door', 'Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Entrance (South)'] + entrances = LW_Entrances + LW_Dungeon_Entrances + DW_Entrances + DW_Dungeon_Entrances + Old_Man_Entrances + ['Skull Woods Second Section Door (East)', 'Skull Woods First Section Door', 'Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave'] entrances_must_exits = DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit + LW_Dungeon_Entrances_Must_Exit + ['Skull Woods Second Section Door (West)'] - doors = LW_Entrances + LW_Dungeon_Entrances + LW_Dungeon_Entrances_Must_Exit + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Secret Entrance Stairs'] + Old_Man_Entrances +\ + doors = LW_Entrances + LW_Dungeon_Entrances + LW_Dungeon_Entrances_Must_Exit + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave'] + Old_Man_Entrances +\ DW_Entrances + DW_Dungeon_Entrances + DW_Entrances_Must_Exit + DW_Dungeon_Entrances_Must_Exit + ['Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)'] random.shuffle(doors) @@ -926,19 +929,20 @@ def link_entrances(world): if world.mode == 'standard': # cannot move uncle cave - connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance') - connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs') - connect_entrance(world, doors.pop(), 'Hyrule Castle Secret Entrance Exit') + connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance', player) + connect_exit(world, 'Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance Stairs', player) + connect_entrance(world, 'Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Exit', player) else: hole_entrances.append('Hyrule Castle Secret Entrance Drop') hole_targets.append('Hyrule Castle Secret Entrance') + doors.append('Hyrule Castle Secret Entrance Stairs') entrances.append('Hyrule Castle Secret Entrance Stairs') caves.append('Hyrule Castle Secret Entrance Exit') if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') - connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit') - connect_entrance(world, 'Pyramid Hole', 'Pyramid') + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) + connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Pyramid Hole', 'Pyramid', player) else: entrances.append('Ganons Tower') caves.extend(['Ganons Tower Exit', 'Pyramid Exit']) @@ -953,16 +957,17 @@ def link_entrances(world): # fill up holes for hole in hole_entrances: - connect_entrance(world, hole, hole_targets.pop()) + connect_entrance(world, hole, hole_targets.pop(), player) # hyrule castle handling if world.mode == 'standard': # must connect front of hyrule castle to do escape - connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') - connect_exit(world, 'Hyrule Castle Exit (South)', entrances.pop()) + connect_entrance(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_exit(world, 'Hyrule Castle Exit (South)', 'Hyrule Castle Entrance (South)', player) caves.append(('Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) else: doors.append('Hyrule Castle Entrance (South)') + entrances.append('Hyrule Castle Entrance (South)') caves.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) # now let's deal with mandatory reachable stuff @@ -987,8 +992,8 @@ def link_entrances(world): exit = cave[-1] cave = cave[:-1] - connect_exit(world, exit, entrance) - connect_entrance(world, doors.pop(), exit) + connect_exit(world, exit, entrance, player) + connect_entrance(world, doors.pop(), exit, player) # rest of cave now is forced to be in this world caves.append(cave) @@ -1003,8 +1008,8 @@ def link_entrances(world): old_man_exit = old_man_entrances.pop() entrances.remove(old_man_exit) - connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit) - connect_entrance(world, doors.pop(), 'Old Man Cave Exit (East)') + connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit, player) + connect_entrance(world, doors.pop(), 'Old Man Cave Exit (East)', player) caves.append('Old Man Cave Exit (West)') # handle remaining caves @@ -1013,8 +1018,8 @@ def link_entrances(world): cave = (cave,) for exit in cave: - connect_exit(world, exit, entrances.pop()) - connect_entrance(world, doors.pop(), exit) + connect_exit(world, exit, entrances.pop(), player) + connect_entrance(world, doors.pop(), exit, player) # handle simple doors @@ -1026,52 +1031,743 @@ def link_entrances(world): # place blacksmith, has limited options random.shuffle(blacksmith_doors) blacksmith_hut = blacksmith_doors.pop() - connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut') + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) bomb_shop_doors.extend(blacksmith_doors) # place dam and pyramid fairy, have limited options random.shuffle(bomb_shop_doors) bomb_shop = bomb_shop_doors.pop() - connect_entrance(world, bomb_shop, 'Big Bomb Shop') + connect_entrance(world, bomb_shop, 'Big Bomb Shop', player) single_doors.extend(bomb_shop_doors) # tavern back door cannot be shuffled yet - connect_doors(world, ['Tavern North'], ['Tavern']) + connect_doors(world, ['Tavern North'], ['Tavern'], player) # place remaining doors - connect_doors(world, single_doors, door_targets) + connect_doors(world, single_doors, door_targets, player) else: raise NotImplementedError('Shuffling not supported yet') # check for swamp palace fix - if world.get_entrance('Dam').connected_region.name != 'Dam' or world.get_entrance('Swamp Palace').connected_region.name != 'Swamp Palace (Entrance)': - world.swamp_patch_required = True + if world.get_entrance('Dam', player).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', player).connected_region.name != 'Swamp Palace (Entrance)': + world.swamp_patch_required[player] = True # check for potion shop location - if world.get_entrance('Potion Shop').connected_region.name != 'Potion Shop': - world.powder_patch_required = True + if world.get_entrance('Potion Shop', player).connected_region.name != 'Potion Shop': + world.powder_patch_required[player] = True # check for ganon location - if world.get_entrance('Pyramid Hole').connected_region.name != 'Pyramid': - world.ganon_at_pyramid = False + if world.get_entrance('Pyramid Hole', player).connected_region.name != 'Pyramid': + world.ganon_at_pyramid[player] = False # check for Ganon's Tower location - if world.get_entrance('Ganons Tower').connected_region.name != 'Ganons Tower (Entrance)': - world.ganonstower_vanilla = False + if world.get_entrance('Ganons Tower', player).connected_region.name != 'Ganons Tower (Entrance)': + world.ganonstower_vanilla[player] = False + +def link_inverted_entrances(world, player): + # Link's house shuffled freely, Houlihan set in mandatory_connections + + Dungeon_Exits = Inverted_Dungeon_Exits_Base.copy() + Cave_Exits = Cave_Exits_Base.copy() + Old_Man_House = Old_Man_House_Base.copy() + Cave_Three_Exits = Cave_Three_Exits_Base.copy() + + unbias_some_entrances(Dungeon_Exits, Cave_Exits, Old_Man_House, Cave_Three_Exits) + + # setup mandatory connections + for exitname, regionname in inverted_mandatory_connections: + connect_simple(world, exitname, regionname, player) + + # if we do not shuffle, set default connections + if world.shuffle == 'vanilla': + for exitname, regionname in inverted_default_connections: + connect_simple(world, exitname, regionname, player) + for exitname, regionname in inverted_default_dungeon_connections: + connect_simple(world, exitname, regionname, player) + elif world.shuffle == 'dungeonssimple': + for exitname, regionname in inverted_default_connections: + connect_simple(world, exitname, regionname, player) + + simple_shuffle_dungeons(world, player) + elif world.shuffle == 'dungeonsfull': + for exitname, regionname in inverted_default_connections: + connect_simple(world, exitname, regionname, player) + + skull_woods_shuffle(world, player) + + dungeon_exits = list(Dungeon_Exits) + lw_entrances = list(Inverted_LW_Dungeon_Entrances) + lw_dungeon_entrances_must_exit = list(Inverted_LW_Dungeon_Entrances_Must_Exit) + dw_entrances = list(Inverted_DW_Dungeon_Entrances) + + # randomize which desert ledge door is a must-exit + if random.randint(0, 1) == 0: + lw_dungeon_entrances_must_exit.append('Desert Palace Entrance (North)') + dp_must_exit = 'Desert Palace Entrance (North)' + lw_entrances.append('Desert Palace Entrance (West)') + else: + lw_dungeon_entrances_must_exit.append('Desert Palace Entrance (West)') + dp_must_exit = 'Desert Palace Entrance (West)' + lw_entrances.append('Desert Palace Entrance (North)') + + dungeon_exits.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) + lw_entrances.append('Hyrule Castle Entrance (South)') + + if not world.shuffle_ganon: + connect_two_way(world, 'Inverted Ganons Tower', 'Inverted Ganons Tower Exit', player) + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)'] + else: + lw_entrances.append('Inverted Ganons Tower') + dungeon_exits.append('Inverted Ganons Tower Exit') + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)', 'Inverted Ganons Tower'] + + # shuffle aga door first. If it's on HC ledge, remaining HC ledge door must be must-exit + all_entrances_aga = lw_entrances + dw_entrances + aga_doors = [i for i in all_entrances_aga] + random.shuffle(aga_doors) + aga_door = aga_doors.pop() + + if aga_door in hc_ledge_entrances: + lw_entrances.remove(aga_door) + hc_ledge_entrances.remove(aga_door) + + random.shuffle(hc_ledge_entrances) + hc_ledge_must_exit = hc_ledge_entrances.pop() + lw_entrances.remove(hc_ledge_must_exit) + lw_dungeon_entrances_must_exit.append(hc_ledge_must_exit) + + if aga_door in lw_entrances: + lw_entrances.remove(aga_door) + elif aga_door in dw_entrances: + dw_entrances.remove(aga_door) + + connect_two_way(world, aga_door, 'Inverted Agahnims Tower Exit', player) + dungeon_exits.remove('Inverted Agahnims Tower Exit') + + all_dungeon_entrances = dw_entrances + lw_entrances + connect_mandatory_exits(world, all_dungeon_entrances, dungeon_exits, lw_dungeon_entrances_must_exit, player, dp_must_exit) + + remaining_dw_entrances = [i for i in all_dungeon_entrances if i in dw_entrances] + remaining_lw_entrances = [i for i in all_dungeon_entrances if i in lw_entrances] + connect_caves(world, remaining_lw_entrances, remaining_dw_entrances, dungeon_exits, player) + + elif world.shuffle == 'simple': + simple_shuffle_dungeons(world, player) + + old_man_entrances = list(Inverted_Old_Man_Entrances) + caves = list(Cave_Exits) + three_exit_caves = list(Cave_Three_Exits) + + single_doors = list(Single_Cave_Doors) + bomb_shop_doors = list(Inverted_Bomb_Shop_Single_Cave_Doors) + blacksmith_doors = list(Inverted_Blacksmith_Single_Cave_Doors) + door_targets = list(Inverted_Single_Cave_Targets) + + # we shuffle all 2 entrance caves as pairs as a start + # start with the ones that need to be directed + two_door_caves = list(Inverted_Two_Door_Caves_Directional) + random.shuffle(two_door_caves) + random.shuffle(caves) + while two_door_caves: + entrance1, entrance2 = two_door_caves.pop() + exit1, exit2 = caves.pop() + connect_two_way(world, entrance1, exit1, player) + connect_two_way(world, entrance2, exit2, player) + + # now the remaining pairs + two_door_caves = list(Inverted_Two_Door_Caves) + random.shuffle(two_door_caves) + while two_door_caves: + entrance1, entrance2 = two_door_caves.pop() + exit1, exit2 = caves.pop() + connect_two_way(world, entrance1, exit1, player) + connect_two_way(world, entrance2, exit2, player) + + # place links house + links_house = random.choice(list(bomb_shop_doors + blacksmith_doors)) + connect_two_way(world, links_house, 'Inverted Links House Exit', player) + if links_house in bomb_shop_doors: + bomb_shop_doors.remove(links_house) + if links_house in blacksmith_doors: + blacksmith_doors.remove(links_house) + + # place dark sanc + sanc_doors = [door for door in Inverted_Dark_Sanctuary_Doors if door in bomb_shop_doors] + sanc_door = random.choice(sanc_doors) + bomb_shop_doors.remove(sanc_door) + connect_doors(world, [sanc_door], ['Inverted Dark Sanctuary'], player) + + lw_dm_entrances = ['Paradox Cave (Bottom)', 'Paradox Cave (Middle)', 'Paradox Cave (Top)', 'Old Man House (Bottom)', + 'Fairy Ascension Cave (Bottom)', 'Fairy Ascension Cave (Top)', 'Spiral Cave (Bottom)', 'Old Man Cave (East)', + 'Death Mountain Return Cave (East)', 'Spiral Cave', 'Old Man House (Top)', 'Spectacle Rock Cave', + 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)'] + + # place old man, bumper cave bottom to DDM entrances not in east bottom + + random.shuffle(old_man_entrances) + old_man_exit = old_man_entrances.pop() + connect_two_way(world, 'Bumper Cave (Bottom)', 'Old Man Cave Exit (West)', player) + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) + if old_man_exit == 'Spike Cave': + bomb_shop_doors.remove('Spike Cave') + bomb_shop_doors.extend(old_man_entrances) + + # add old man house to ensure it is always somewhere on light death mountain + caves.extend(list(Old_Man_House)) + caves.extend(list(three_exit_caves)) + + # connect rest + connect_caves(world, lw_dm_entrances, [], caves, player) + + # scramble holes + scramble_inverted_holes(world, player) + + # place blacksmith, has limited options + blacksmith_doors = [door for door in blacksmith_doors[:]] + random.shuffle(blacksmith_doors) + blacksmith_hut = blacksmith_doors.pop() + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) + bomb_shop_doors.extend(blacksmith_doors) + + # place bomb shop, has limited options + bomb_shop_doors = [door for door in bomb_shop_doors[:]] + random.shuffle(bomb_shop_doors) + bomb_shop = bomb_shop_doors.pop() + connect_entrance(world, bomb_shop, 'Inverted Big Bomb Shop', player) + single_doors.extend(bomb_shop_doors) + + # tavern back door cannot be shuffled yet + connect_doors(world, ['Tavern North'], ['Tavern'], player) + + # place remaining doors + connect_doors(world, single_doors, door_targets, player) + + elif world.shuffle == 'restricted': + simple_shuffle_dungeons(world, player) + + lw_entrances = list(Inverted_LW_Entrances + Inverted_LW_Single_Cave_Doors) + dw_entrances = list(Inverted_DW_Entrances + Inverted_DW_Single_Cave_Doors + Inverted_Old_Man_Entrances) + lw_must_exits = list(Inverted_LW_Entrances_Must_Exit) + old_man_entrances = list(Inverted_Old_Man_Entrances) + caves = list(Cave_Exits + Cave_Three_Exits + Old_Man_House) + single_doors = list(Single_Cave_Doors) + bomb_shop_doors = list(Inverted_Bomb_Shop_Single_Cave_Doors + Inverted_Bomb_Shop_Multi_Cave_Doors) + blacksmith_doors = list(Inverted_Blacksmith_Single_Cave_Doors + Blacksmith_Multi_Cave_Doors) + door_targets = list(Inverted_Single_Cave_Targets) + + # place links house + links_house = random.choice(list(lw_entrances + dw_entrances + lw_must_exits)) + connect_two_way(world, links_house, 'Inverted Links House Exit', player) + if links_house in lw_entrances: + lw_entrances.remove(links_house) + elif links_house in dw_entrances: + dw_entrances.remove(links_house) + elif links_house in lw_must_exits: + lw_must_exits.remove(links_house) + + # place dark sanc + sanc_doors = [door for door in Inverted_Dark_Sanctuary_Doors if door in dw_entrances] + sanc_door = random.choice(sanc_doors) + dw_entrances.remove(sanc_door) + connect_doors(world, [sanc_door], ['Inverted Dark Sanctuary'], player) + + # tavern back door cannot be shuffled yet + connect_doors(world, ['Tavern North'], ['Tavern'], player) + + # place must exits + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player) + + # place old man, has limited options + # exit has to come from specific set of doors, the entrance is free to move about + old_man_entrances = [door for door in old_man_entrances if door in dw_entrances] + random.shuffle(old_man_entrances) + old_man_exit = old_man_entrances.pop() + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) + dw_entrances.remove(old_man_exit) + + # place blacksmith, has limited options + all_entrances = lw_entrances + dw_entrances + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + blacksmith_doors = [door for door in blacksmith_doors if door in all_entrances] + random.shuffle(blacksmith_doors) + blacksmith_hut = blacksmith_doors.pop() + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) + if blacksmith_hut in lw_entrances: + lw_entrances.remove(blacksmith_hut) + if blacksmith_hut in dw_entrances: + dw_entrances.remove(blacksmith_hut) + bomb_shop_doors.extend(blacksmith_doors) + + # place bomb shop, has limited options + all_entrances = lw_entrances + dw_entrances + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + bomb_shop_doors = [door for door in bomb_shop_doors if door in all_entrances] + random.shuffle(bomb_shop_doors) + bomb_shop = bomb_shop_doors.pop() + connect_entrance(world, bomb_shop, 'Inverted Big Bomb Shop', player) + if bomb_shop in lw_entrances: + lw_entrances.remove(bomb_shop) + if bomb_shop in dw_entrances: + dw_entrances.remove(bomb_shop) + + # place the old man cave's entrance somewhere in the dark world + random.shuffle(dw_entrances) + old_man_entrance = dw_entrances.pop() + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + + # now scramble the rest + connect_caves(world, lw_entrances, dw_entrances, caves, player) + + # scramble holes + scramble_inverted_holes(world, player) + + doors = lw_entrances + dw_entrances + # place remaining doors + connect_doors(world, doors, door_targets, player) + elif world.shuffle == 'full': + skull_woods_shuffle(world, player) + + lw_entrances = list(Inverted_LW_Entrances + Inverted_LW_Dungeon_Entrances + Inverted_LW_Single_Cave_Doors) + dw_entrances = list(Inverted_DW_Entrances + Inverted_DW_Dungeon_Entrances + Inverted_DW_Single_Cave_Doors + Inverted_Old_Man_Entrances) + lw_must_exits = list(Inverted_LW_Dungeon_Entrances_Must_Exit + Inverted_LW_Entrances_Must_Exit) + old_man_entrances = list(Inverted_Old_Man_Entrances + Old_Man_Entrances + ['Inverted Agahnims Tower', 'Tower of Hera']) + caves = list(Cave_Exits + Dungeon_Exits + Cave_Three_Exits) # don't need to consider three exit caves, have one exit caves to avoid parity issues + bomb_shop_doors = list(Inverted_Bomb_Shop_Single_Cave_Doors + Inverted_Bomb_Shop_Multi_Cave_Doors) + blacksmith_doors = list(Inverted_Blacksmith_Single_Cave_Doors + Blacksmith_Multi_Cave_Doors) + door_targets = list(Inverted_Single_Cave_Targets) + old_man_house = list(Old_Man_House) + + # randomize which desert ledge door is a must-exit + if random.randint(0, 1) == 0: + lw_must_exits.append('Desert Palace Entrance (North)') + dp_must_exit = 'Desert Palace Entrance (North)' + lw_entrances.append('Desert Palace Entrance (West)') + else: + lw_must_exits.append('Desert Palace Entrance (West)') + dp_must_exit = 'Desert Palace Entrance (West)' + lw_entrances.append('Desert Palace Entrance (North)') + + # tavern back door cannot be shuffled yet + connect_doors(world, ['Tavern North'], ['Tavern'], player) + + caves.append(tuple(random.sample(['Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)'],3))) + lw_entrances.append('Hyrule Castle Entrance (South)') -def connect_simple(world, exitname, regionname): - world.get_entrance(exitname).connect(world.get_region(regionname)) + if not world.shuffle_ganon: + connect_two_way(world, 'Inverted Ganons Tower', 'Inverted Ganons Tower Exit', player) + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)'] + else: + lw_entrances.append('Inverted Ganons Tower') + caves.append('Inverted Ganons Tower Exit') + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)', 'Inverted Ganons Tower'] + + # shuffle aga door first. if it's on hc ledge, then one other hc ledge door has to be must_exit + all_entrances_aga = lw_entrances + dw_entrances + aga_doors = [i for i in all_entrances_aga] + random.shuffle(aga_doors) + aga_door = aga_doors.pop() + + if aga_door in hc_ledge_entrances: + lw_entrances.remove(aga_door) + hc_ledge_entrances.remove(aga_door) + + random.shuffle(hc_ledge_entrances) + hc_ledge_must_exit = hc_ledge_entrances.pop() + lw_entrances.remove(hc_ledge_must_exit) + lw_must_exits.append(hc_ledge_must_exit) + + if aga_door in lw_entrances: + lw_entrances.remove(aga_door) + elif aga_door in dw_entrances: + dw_entrances.remove(aga_door) + + connect_two_way(world, aga_door, 'Inverted Agahnims Tower Exit', player) + caves.remove('Inverted Agahnims Tower Exit') + + # place links house + links_house_doors = [door for door in lw_entrances + dw_entrances + lw_must_exits] + links_house = random.choice(links_house_doors) + connect_two_way(world, links_house, 'Inverted Links House Exit', player) + if links_house in lw_entrances: + lw_entrances.remove(links_house) + if links_house in dw_entrances: + dw_entrances.remove(links_house) + if links_house in lw_must_exits: + lw_must_exits.remove(links_house) + + # place dark sanc + sanc_doors = [door for door in Inverted_Dark_Sanctuary_Doors if door in dw_entrances] + sanc_door = random.choice(sanc_doors) + dw_entrances.remove(sanc_door) + connect_doors(world, [sanc_door], ['Inverted Dark Sanctuary'], player) + + # place old man house + # no dw must exits in inverted, but we randomize whether cave is in light or dark world + if random.randint(0, 1) == 0: + caves += old_man_house + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player, dp_must_exit) + try: + caves.remove(old_man_house[0]) + except ValueError: + pass + else: #if the cave wasn't placed we get here + connect_caves(world, lw_entrances, [], old_man_house, player) + else: + connect_caves(world, dw_entrances, [], old_man_house, player) + connect_mandatory_exits(world, lw_entrances, caves, lw_must_exits, player, dp_must_exit) + + # place old man, has limited options + # exit has to come from specific set of doors, the entrance is free to move about + old_man_entrances = [door for door in old_man_entrances if door in dw_entrances + lw_entrances] + random.shuffle(old_man_entrances) + old_man_exit = old_man_entrances.pop() + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) + if old_man_exit in dw_entrances: + dw_entrances.remove(old_man_exit) + old_man_world = 'dark' + elif old_man_exit in lw_entrances: + lw_entrances.remove(old_man_exit) + old_man_world = 'light' + + # place blacksmith, has limited options + all_entrances = lw_entrances + dw_entrances + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + blacksmith_doors = [door for door in blacksmith_doors if door in all_entrances] + random.shuffle(blacksmith_doors) + blacksmith_hut = blacksmith_doors.pop() + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) + if blacksmith_hut in lw_entrances: + lw_entrances.remove(blacksmith_hut) + if blacksmith_hut in dw_entrances: + dw_entrances.remove(blacksmith_hut) + bomb_shop_doors.extend(blacksmith_doors) + + # place bomb shop, has limited options + all_entrances = lw_entrances + dw_entrances + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + bomb_shop_doors = [door for door in bomb_shop_doors if door in all_entrances] + random.shuffle(bomb_shop_doors) + bomb_shop = bomb_shop_doors.pop() + connect_entrance(world, bomb_shop, 'Inverted Big Bomb Shop', player) + if bomb_shop in lw_entrances: + lw_entrances.remove(bomb_shop) + if bomb_shop in dw_entrances: + dw_entrances.remove(bomb_shop) + + # place the old man cave's entrance somewhere in the same world he'll exit from + if old_man_world == 'light': + random.shuffle(lw_entrances) + old_man_entrance = lw_entrances.pop() + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + elif old_man_world == 'dark': + random.shuffle(dw_entrances) + old_man_entrance = dw_entrances.pop() + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + + # now scramble the rest + connect_caves(world, lw_entrances, dw_entrances, caves, player) + + # scramble holes + scramble_inverted_holes(world, player) + + doors = lw_entrances + dw_entrances + + # place remaining doors + connect_doors(world, doors, door_targets, player) + elif world.shuffle == 'crossed': + skull_woods_shuffle(world, player) + + entrances = list(Inverted_LW_Entrances + Inverted_LW_Dungeon_Entrances + Inverted_LW_Single_Cave_Doors + Inverted_Old_Man_Entrances + Inverted_DW_Entrances + Inverted_DW_Dungeon_Entrances + Inverted_DW_Single_Cave_Doors) + must_exits = list(Inverted_LW_Entrances_Must_Exit + Inverted_LW_Dungeon_Entrances_Must_Exit) + + old_man_entrances = list(Inverted_Old_Man_Entrances + Old_Man_Entrances + ['Inverted Agahnims Tower', 'Tower of Hera']) + caves = list(Cave_Exits + Dungeon_Exits + Cave_Three_Exits + Old_Man_House) # don't need to consider three exit caves, have one exit caves to avoid parity issues + bomb_shop_doors = list(Inverted_Bomb_Shop_Single_Cave_Doors + Inverted_Bomb_Shop_Multi_Cave_Doors) + blacksmith_doors = list(Inverted_Blacksmith_Single_Cave_Doors + Blacksmith_Multi_Cave_Doors) + door_targets = list(Inverted_Single_Cave_Targets) + + # randomize which desert ledge door is a must-exit + if random.randint(0, 1) == 0: + must_exits.append('Desert Palace Entrance (North)') + dp_must_exit = 'Desert Palace Entrance (North)' + entrances.append('Desert Palace Entrance (West)') + else: + must_exits.append('Desert Palace Entrance (West)') + dp_must_exit = 'Desert Palace Entrance (West)' + entrances.append('Desert Palace Entrance (North)') + + caves.append(tuple(random.sample(['Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)'],3))) + entrances.append('Hyrule Castle Entrance (South)') + + if not world.shuffle_ganon: + connect_two_way(world, 'Inverted Ganons Tower', 'Inverted Ganons Tower Exit', player) + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)'] + else: + entrances.append('Inverted Ganons Tower') + caves.append('Inverted Ganons Tower Exit') + hc_ledge_entrances = ['Hyrule Castle Entrance (West)', 'Hyrule Castle Entrance (East)', 'Inverted Ganons Tower'] + + # shuffle aga door. if it's on hc ledge, then one other hc ledge door has to be must_exit + aga_door = random.choice(list(entrances)) + + if aga_door in hc_ledge_entrances: + hc_ledge_entrances.remove(aga_door) + + random.shuffle(hc_ledge_entrances) + hc_ledge_must_exit = hc_ledge_entrances.pop() + entrances.remove(hc_ledge_must_exit) + must_exits.append(hc_ledge_must_exit) + + entrances.remove(aga_door) + connect_two_way(world, aga_door, 'Inverted Agahnims Tower Exit', player) + caves.remove('Inverted Agahnims Tower Exit') -def connect_entrance(world, entrancename, exitname): - entrance = world.get_entrance(entrancename) + # place links house + links_house = random.choice(list(entrances + must_exits)) + connect_two_way(world, links_house, 'Inverted Links House Exit', player) + if links_house in entrances: + entrances.remove(links_house) + elif links_house in must_exits: + must_exits.remove(links_house) + + # place dark sanc + sanc_doors = [door for door in Inverted_Dark_Sanctuary_Doors if door in entrances] + sanc_door = random.choice(sanc_doors) + entrances.remove(sanc_door) + connect_doors(world, [sanc_door], ['Inverted Dark Sanctuary'], player) + + # tavern back door cannot be shuffled yet + connect_doors(world, ['Tavern North'], ['Tavern'], player) + + + #place must-exit caves + connect_mandatory_exits(world, entrances, caves, must_exits, player, dp_must_exit) + + + # place old man, has limited options + # exit has to come from specific set of doors, the entrance is free to move about + old_man_entrances = [door for door in old_man_entrances if door in entrances] + random.shuffle(old_man_entrances) + old_man_exit = old_man_entrances.pop() + connect_two_way(world, old_man_exit, 'Old Man Cave Exit (East)', player) + entrances.remove(old_man_exit) + + # place blacksmith, has limited options + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + blacksmith_doors = [door for door in blacksmith_doors if door in entrances] + random.shuffle(blacksmith_doors) + blacksmith_hut = blacksmith_doors.pop() + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) + entrances.remove(blacksmith_hut) + + # place bomb shop, has limited options + + # cannot place it anywhere already taken (or that are otherwise not eligible for placement) + bomb_shop_doors = [door for door in bomb_shop_doors if door in entrances] + random.shuffle(bomb_shop_doors) + bomb_shop = bomb_shop_doors.pop() + connect_entrance(world, bomb_shop, 'Inverted Big Bomb Shop', player) + entrances.remove(bomb_shop) + + # place the old man cave's entrance somewhere + random.shuffle(entrances) + old_man_entrance = entrances.pop() + connect_two_way(world, old_man_entrance, 'Old Man Cave Exit (West)', player) + + # now scramble the rest + connect_caves(world, entrances, [], caves, player) + + # scramble holes + scramble_inverted_holes(world, player) + + # place remaining doors + connect_doors(world, entrances, door_targets, player) + elif world.shuffle == 'insanity': + # beware ye who enter here + + entrances = Inverted_LW_Entrances + Inverted_LW_Dungeon_Entrances + Inverted_DW_Entrances + Inverted_DW_Dungeon_Entrances + Inverted_Old_Man_Entrances + Old_Man_Entrances + ['Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)', 'Skull Woods First Section Door', 'Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Entrance (South)'] + entrances_must_exits = Inverted_LW_Entrances_Must_Exit + Inverted_LW_Dungeon_Entrances_Must_Exit + + doors = Inverted_LW_Entrances + Inverted_LW_Dungeon_Entrances + Inverted_LW_Entrances_Must_Exit + Inverted_LW_Dungeon_Entrances_Must_Exit + ['Kakariko Well Cave', 'Bat Cave Cave', 'North Fairy Cave', 'Sanctuary', 'Lost Woods Hideout Stump', 'Lumberjack Tree Cave', 'Hyrule Castle Secret Entrance Stairs'] + Inverted_Old_Man_Entrances +\ + Inverted_DW_Entrances + Inverted_DW_Dungeon_Entrances + ['Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)'] +\ + Inverted_LW_Single_Cave_Doors + Inverted_DW_Single_Cave_Doors + ['Desert Palace Entrance (West)', 'Desert Palace Entrance (North)'] + + # randomize which desert ledge door is a must-exit + if random.randint(0, 1) == 0: + entrances_must_exits.append('Desert Palace Entrance (North)') + entrances.append('Desert Palace Entrance (West)') + else: + entrances_must_exits.append('Desert Palace Entrance (West)') + entrances.append('Desert Palace Entrance (North)') + + # TODO: there are other possible entrances we could support here by way of exiting from a connector, + # and rentering to find bomb shop. However appended list here is all those that we currently have + # bomb shop logic for. + # Specifically we could potentially add: 'Dark Death Mountain Ledge (East)' and doors associated with pits + bomb_shop_doors = list(Inverted_Bomb_Shop_Single_Cave_Doors + Inverted_Bomb_Shop_Multi_Cave_Doors + ['Desert Palace Entrance (East)', 'Turtle Rock Isolated Ledge Entrance', 'Bumper Cave (Top)', 'Hookshot Cave Back Entrance']) + blacksmith_doors = list(Inverted_Blacksmith_Single_Cave_Doors + Blacksmith_Multi_Cave_Doors) + door_targets = list(Inverted_Single_Cave_Targets) + + random.shuffle(doors) + + old_man_entrances = list(Inverted_Old_Man_Entrances + Old_Man_Entrances) + ['Tower of Hera', 'Inverted Agahnims Tower'] + + caves = Cave_Exits + Dungeon_Exits + Cave_Three_Exits + ['Old Man House Exit (Bottom)', 'Old Man House Exit (Top)', 'Skull Woods First Section Exit', 'Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)', + 'Kakariko Well Exit', 'Bat Cave Exit', 'North Fairy Cave Exit', 'Lost Woods Hideout Exit', 'Lumberjack Tree Exit', 'Sanctuary Exit'] + + + # shuffle up holes + hole_entrances = ['Kakariko Well Drop', 'Bat Cave Drop', 'North Fairy Cave Drop', 'Lost Woods Hideout Drop', 'Lumberjack Tree Tree', 'Sanctuary Grave', + 'Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', 'Skull Woods Second Section Hole'] + + hole_targets = ['Kakariko Well (top)', 'Bat Cave (right)', 'North Fairy Cave', 'Lost Woods Hideout (top)', 'Lumberjack Tree (top)', 'Sewer Drop', 'Skull Woods Second Section (Drop)', + 'Skull Woods First Section (Left)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Top)'] + + # tavern back door cannot be shuffled yet + connect_doors(world, ['Tavern North'], ['Tavern'], player) + + hole_entrances.append('Hyrule Castle Secret Entrance Drop') + hole_targets.append('Hyrule Castle Secret Entrance') + entrances.append('Hyrule Castle Secret Entrance Stairs') + caves.append('Hyrule Castle Secret Entrance Exit') + + if not world.shuffle_ganon: + connect_two_way(world, 'Inverted Ganons Tower', 'Inverted Ganons Tower Exit', player) + connect_two_way(world, 'Inverted Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Inverted Pyramid Hole', 'Pyramid', player) + else: + entrances.append('Inverted Ganons Tower') + caves.extend(['Inverted Ganons Tower Exit', 'Pyramid Exit']) + hole_entrances.append('Inverted Pyramid Hole') + hole_targets.append('Pyramid') + doors.extend(['Inverted Ganons Tower', 'Inverted Pyramid Entrance']) + + random.shuffle(hole_entrances) + random.shuffle(hole_targets) + random.shuffle(entrances) + + # fill up holes + for hole in hole_entrances: + connect_entrance(world, hole, hole_targets.pop(), player) + + doors.append('Hyrule Castle Entrance (South)') + caves.append(('Hyrule Castle Exit (South)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (East)')) + + # place links house and dark sanc + links_house = random.choice(list(entrances + entrances_must_exits)) + connect_two_way(world, links_house, 'Inverted Links House Exit', player) + if links_house in entrances: + entrances.remove(links_house) + elif links_house in entrances_must_exits: + entrances_must_exits.remove(links_house) + doors.remove(links_house) + + sanc_doors = [door for door in Inverted_Dark_Sanctuary_Doors if door in entrances] + sanc_door = random.choice(sanc_doors) + entrances.remove(sanc_door) + doors.remove(sanc_door) + connect_doors(world, [sanc_door], ['Inverted Dark Sanctuary'], player) + + # now let's deal with mandatory reachable stuff + def extract_reachable_exit(cavelist): + random.shuffle(cavelist) + candidate = None + for cave in cavelist: + if isinstance(cave, tuple) and len(cave) > 1: + # special handling: TRock has two entries that we should consider entrance only + # ToDo this should be handled in a more sensible manner + if cave[0] in ['Turtle Rock Exit (Front)', 'Spectacle Rock Cave Exit (Peak)'] and len(cave) == 2: + continue + candidate = cave + break + if candidate is None: + raise RuntimeError('No suitable cave.') + cavelist.remove(candidate) + return candidate + + def connect_reachable_exit(entrance, caves, doors): + cave = extract_reachable_exit(caves) + + exit = cave[-1] + cave = cave[:-1] + connect_exit(world, exit, entrance, player) + connect_entrance(world, doors.pop(), exit, player) + # rest of cave now is forced to be in this world + caves.append(cave) + + # connect mandatory exits + for entrance in entrances_must_exits: + connect_reachable_exit(entrance, caves, doors) + + # place old man, has limited options + # exit has to come from specific set of doors, the entrance is free to move about + old_man_entrances = [entrance for entrance in old_man_entrances if entrance in entrances] + random.shuffle(old_man_entrances) + old_man_exit = old_man_entrances.pop() + entrances.remove(old_man_exit) + + connect_exit(world, 'Old Man Cave Exit (East)', old_man_exit, player) + connect_entrance(world, doors.pop(), 'Old Man Cave Exit (East)', player) + caves.append('Old Man Cave Exit (West)') + + # place blacksmith, has limited options + blacksmith_doors = [door for door in blacksmith_doors if door in doors] + random.shuffle(blacksmith_doors) + blacksmith_hut = blacksmith_doors.pop() + connect_entrance(world, blacksmith_hut, 'Blacksmiths Hut', player) + doors.remove(blacksmith_hut) + + # place dam and pyramid fairy, have limited options + bomb_shop_doors = [door for door in bomb_shop_doors if door in doors] + random.shuffle(bomb_shop_doors) + bomb_shop = bomb_shop_doors.pop() + connect_entrance(world, bomb_shop, 'Inverted Big Bomb Shop', player) + doors.remove(bomb_shop) + + # handle remaining caves + for cave in caves: + if isinstance(cave, str): + cave = (cave,) + + for exit in cave: + connect_exit(world, exit, entrances.pop(), player) + connect_entrance(world, doors.pop(), exit, player) + + # place remaining doors + connect_doors(world, doors, door_targets, player) + else: + raise NotImplementedError('Shuffling not supported yet') + + # patch swamp drain + if world.get_entrance('Dam', player).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', player).connected_region.name != 'Swamp Palace (Entrance)': + world.swamp_patch_required[player] = True + + # check for potion shop location + if world.get_entrance('Potion Shop', player).connected_region.name != 'Potion Shop': + world.powder_patch_required[player] = True + + # check for ganon location + if world.get_entrance('Inverted Pyramid Hole', player).connected_region.name != 'Pyramid': + world.ganon_at_pyramid[player] = False + + # check for Ganon's Tower location + if world.get_entrance('Inverted Ganons Tower', player).connected_region.name != 'Ganons Tower (Entrance)': + world.ganonstower_vanilla[player] = False + +def connect_simple(world, exitname, regionname, player): + world.get_entrance(exitname, player).connect(world.get_region(regionname, player)) + + +def connect_entrance(world, entrancename, exitname, player): + entrance = world.get_entrance(entrancename, player) # check if we got an entrance or a region to connect to try: - region = world.get_region(exitname) + region = world.get_region(exitname, player) exit = None except RuntimeError: - exit = world.get_entrance(exitname) + exit = world.get_entrance(exitname, player) region = exit.parent_region # if this was already connected somewhere, remove the backreference @@ -1082,24 +1778,23 @@ def connect_entrance(world, entrancename, exitname): addresses = door_addresses[entrance.name][0] entrance.connect(region, addresses, target) - world.spoiler.set_entrance(entrance.name, exit.name if exit is not None else region.name, 'entrance') + world.spoiler.set_entrance(entrance.name, exit.name if exit is not None else region.name, 'entrance', player) - -def connect_exit(world, exitname, entrancename): - entrance = world.get_entrance(entrancename) - exit = world.get_entrance(exitname) +def connect_exit(world, exitname, entrancename, player): + entrance = world.get_entrance(entrancename, player) + exit = world.get_entrance(exitname, player) # if this was already connected somewhere, remove the backreference if exit.connected_region is not None: exit.connected_region.entrances.remove(exit) exit.connect(entrance.parent_region, door_addresses[entrance.name][1], exit_ids[exit.name][1]) - world.spoiler.set_entrance(entrance.name, exit.name, 'exit') + world.spoiler.set_entrance(entrance.name, exit.name, 'exit', player) -def connect_two_way(world, entrancename, exitname): - entrance = world.get_entrance(entrancename) - exit = world.get_entrance(exitname) +def connect_two_way(world, entrancename, exitname, player): + entrance = world.get_entrance(entrancename, player) + exit = world.get_entrance(exitname, player) # if these were already connected somewhere, remove the backreference if entrance.connected_region is not None: @@ -1109,10 +1804,10 @@ def connect_two_way(world, entrancename, exitname): entrance.connect(exit.parent_region, door_addresses[entrance.name][0], exit_ids[exit.name][0]) exit.connect(entrance.parent_region, door_addresses[entrance.name][1], exit_ids[exit.name][1]) - world.spoiler.set_entrance(entrance.name, exit.name, 'both') + world.spoiler.set_entrance(entrance.name, exit.name, 'both', player) -def scramble_holes(world): +def scramble_holes(world, player): hole_entrances = [('Kakariko Well Cave', 'Kakariko Well Drop'), ('Bat Cave Cave', 'Bat Cave Drop'), ('North Fairy Cave', 'North Fairy Cave Drop'), @@ -1127,15 +1822,15 @@ def scramble_holes(world): ('Lumberjack Tree Exit', 'Lumberjack Tree (top)')] if not world.shuffle_ganon: - connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit') - connect_entrance(world, 'Pyramid Hole', 'Pyramid') + connect_two_way(world, 'Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Pyramid Hole', 'Pyramid', player) else: hole_targets.append(('Pyramid Exit', 'Pyramid')) if world.mode == 'standard': # cannot move uncle cave - connect_two_way(world, 'Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Exit') - connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance') + connect_two_way(world, 'Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Exit', player) + connect_entrance(world, 'Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance', player) else: hole_entrances.append(('Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Drop')) hole_targets.append(('Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance')) @@ -1146,30 +1841,71 @@ def scramble_holes(world): if world.shuffle_ganon: random.shuffle(hole_targets) exit, target = hole_targets.pop() - connect_two_way(world, 'Pyramid Entrance', exit) - connect_entrance(world, 'Pyramid Hole', target) + connect_two_way(world, 'Pyramid Entrance', exit, player) + connect_entrance(world, 'Pyramid Hole', target, player) if world.shuffle != 'crossed': hole_targets.append(('Sanctuary Exit', 'Sewer Drop')) random.shuffle(hole_targets) for entrance, drop in hole_entrances: exit, target = hole_targets.pop() - connect_two_way(world, entrance, exit) - connect_entrance(world, drop, target) + connect_two_way(world, entrance, exit, player) + connect_entrance(world, drop, target, player) -def connect_random(world, exitlist, targetlist, two_way=False): +def scramble_inverted_holes(world, player): + hole_entrances = [('Kakariko Well Cave', 'Kakariko Well Drop'), + ('Bat Cave Cave', 'Bat Cave Drop'), + ('North Fairy Cave', 'North Fairy Cave Drop'), + ('Lost Woods Hideout Stump', 'Lost Woods Hideout Drop'), + ('Lumberjack Tree Cave', 'Lumberjack Tree Tree'), + ('Sanctuary', 'Sanctuary Grave')] + + hole_targets = [('Kakariko Well Exit', 'Kakariko Well (top)'), + ('Bat Cave Exit', 'Bat Cave (right)'), + ('North Fairy Cave Exit', 'North Fairy Cave'), + ('Lost Woods Hideout Exit', 'Lost Woods Hideout (top)'), + ('Lumberjack Tree Exit', 'Lumberjack Tree (top)')] + + if not world.shuffle_ganon: + connect_two_way(world, 'Inverted Pyramid Entrance', 'Pyramid Exit', player) + connect_entrance(world, 'Inverted Pyramid Hole', 'Pyramid', player) + else: + hole_targets.append(('Pyramid Exit', 'Pyramid')) + + + hole_entrances.append(('Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance Drop')) + hole_targets.append(('Hyrule Castle Secret Entrance Exit', 'Hyrule Castle Secret Entrance')) + + # do not shuffle sanctuary into pyramid hole unless shuffle is crossed + if world.shuffle == 'crossed': + hole_targets.append(('Sanctuary Exit', 'Sewer Drop')) + if world.shuffle_ganon: + random.shuffle(hole_targets) + exit, target = hole_targets.pop() + connect_two_way(world, 'Inverted Pyramid Entrance', exit, player) + connect_entrance(world, 'Inverted Pyramid Hole', target, player) + if world.shuffle != 'crossed': + hole_targets.append(('Sanctuary Exit', 'Sewer Drop')) + + random.shuffle(hole_targets) + for entrance, drop in hole_entrances: + exit, target = hole_targets.pop() + connect_two_way(world, entrance, exit, player) + connect_entrance(world, drop, target, player) + +def connect_random(world, exitlist, targetlist, player, two_way=False): targetlist = list(targetlist) random.shuffle(targetlist) for exit, target in zip(exitlist, targetlist): if two_way: - connect_two_way(world, exit, target) + connect_two_way(world, exit, target, player) else: - connect_entrance(world, exit, target) + connect_entrance(world, exit, target, player) -def connect_mandatory_exits(world, entrances, caves, must_be_exits): +def connect_mandatory_exits(world, entrances, caves, must_be_exits, player, dp_must_exit=None): """This works inplace""" random.shuffle(entrances) random.shuffle(caves) @@ -1187,18 +1923,22 @@ def connect_mandatory_exits(world, entrances, caves, must_be_exits): raise RuntimeError('No more caves left. Should not happen!') # all caves are sorted so that the last exit is always reachable - connect_two_way(world, exit, cave[-1]) + connect_two_way(world, exit, cave[-1], player) if len(cave) == 2: entrance = entrances.pop() - # ToDo Better solution, this is a hot fix. Do not connect both sides of trock ledge only to each other - if entrance == 'Dark Death Mountain Ledge (West)': + # ToDo Better solution, this is a hot fix. Do not connect both sides of trock/desert ledge only to each other + if world.mode != 'inverted' and entrance == 'Dark Death Mountain Ledge (West)': new_entrance = entrances.pop() entrances.append(entrance) entrance = new_entrance - connect_two_way(world, entrance, cave[0]) + if world.mode == 'inverted' and entrance == dp_must_exit: + new_entrance = entrances.pop() + entrances.append(entrance) + entrance = new_entrance + connect_two_way(world, entrance, cave[0], player) elif cave[-1] == 'Spectacle Rock Cave Exit': #Spectacle rock only has one exit for exit in cave[:-1]: - connect_two_way(world,entrances.pop(),exit) + connect_two_way(world,entrances.pop(),exit, player) else:#save for later so we can connect to multiple exits caves.append(cave[0:-1]) random.shuffle(caves) @@ -1207,11 +1947,11 @@ def connect_mandatory_exits(world, entrances, caves, must_be_exits): for cave in used_caves: if cave in caves: #check if we placed multiple entrances from this 3 or 4 exit for exit in cave: - connect_two_way(world, entrances.pop(), exit) + connect_two_way(world, entrances.pop(), exit, player) caves.remove(cave) -def connect_caves(world, lw_entrances, dw_entrances, caves): +def connect_caves(world, lw_entrances, dw_entrances, caves, player): """This works inplace""" random.shuffle(lw_entrances) random.shuffle(dw_entrances) @@ -1236,103 +1976,157 @@ def connect_caves(world, lw_entrances, dw_entrances, caves): target = lw_entrances if target is dw_entrances else dw_entrances for exit in cave: - connect_two_way(world, target.pop(), exit) + connect_two_way(world, target.pop(), exit, player) -def connect_doors(world, doors, targets): +def connect_doors(world, doors, targets, player): """This works inplace""" random.shuffle(doors) random.shuffle(targets) while doors: door = doors.pop() target = targets.pop() - connect_entrance(world, door, target) + connect_entrance(world, door, target, player) -def skull_woods_shuffle(world): +def skull_woods_shuffle(world, player): connect_random(world, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', 'Skull Woods Second Section Hole'], - ['Skull Woods First Section (Left)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Top)', 'Skull Woods Second Section (Drop)']) + ['Skull Woods First Section (Left)', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Top)', 'Skull Woods Second Section (Drop)'], player) connect_random(world, ['Skull Woods First Section Door', 'Skull Woods Second Section Door (East)', 'Skull Woods Second Section Door (West)'], - ['Skull Woods First Section Exit', 'Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)'], True) + ['Skull Woods First Section Exit', 'Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)'], player, True) -def simple_shuffle_dungeons(world): - skull_woods_shuffle(world) +def simple_shuffle_dungeons(world, player): + skull_woods_shuffle(world, player) dungeon_entrances = ['Eastern Palace', 'Tower of Hera', 'Thieves Town', 'Skull Woods Final Section', 'Palace of Darkness', 'Ice Palace', 'Misery Mire', 'Swamp Palace'] dungeon_exits = ['Eastern Palace Exit', 'Tower of Hera Exit', 'Thieves Town Exit', 'Skull Woods Final Section Exit', 'Palace of Darkness Exit', 'Ice Palace Exit', 'Misery Mire Exit', 'Swamp Palace Exit'] - if not world.shuffle_ganon: - connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit') + if world.mode != 'inverted': + if not world.shuffle_ganon: + connect_two_way(world, 'Ganons Tower', 'Ganons Tower Exit', player) + else: + dungeon_entrances.append('Ganons Tower') + dungeon_exits.append('Ganons Tower Exit') else: - dungeon_entrances.append('Ganons Tower') - dungeon_exits.append('Ganons Tower Exit') + dungeon_entrances.append('Inverted Agahnims Tower') + dungeon_exits.append('Inverted Agahnims Tower Exit') # shuffle up single entrance dungeons - connect_random(world, dungeon_entrances, dungeon_exits, True) + connect_random(world, dungeon_entrances, dungeon_exits, player, True) # mix up 4 door dungeons multi_dungeons = ['Desert', 'Turtle Rock'] - if world.mode == 'open': + if world.mode == 'open' or (world.mode == 'inverted' and world.shuffle_ganon): multi_dungeons.append('Hyrule Castle') random.shuffle(multi_dungeons) dp_target = multi_dungeons[0] tr_target = multi_dungeons[1] - if world.mode != 'open': + if world.mode not in ['open', 'inverted'] or (world.mode == 'inverted' and world.shuffle_ganon is False): # place hyrule castle as intended hc_target = 'Hyrule Castle' else: hc_target = multi_dungeons[2] # ToDo improve this? - if hc_target == 'Hyrule Castle': - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)') - connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Hyrule Castle Exit (East)') - connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Hyrule Castle Exit (West)') - connect_two_way(world, 'Agahnims Tower', 'Agahnims Tower Exit') - elif hc_target == 'Desert': - connect_two_way(world, 'Desert Palace Entrance (South)', 'Hyrule Castle Exit (South)') - connect_two_way(world, 'Desert Palace Entrance (East)', 'Hyrule Castle Exit (East)') - connect_two_way(world, 'Desert Palace Entrance (West)', 'Hyrule Castle Exit (West)') - connect_two_way(world, 'Desert Palace Entrance (North)', 'Agahnims Tower Exit') - elif hc_target == 'Turtle Rock': - connect_two_way(world, 'Turtle Rock', 'Hyrule Castle Exit (South)') - connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Hyrule Castle Exit (East)') - connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Hyrule Castle Exit (West)') - connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Agahnims Tower Exit') - if dp_target == 'Hyrule Castle': - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Desert Palace Exit (South)') - connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Desert Palace Exit (East)') - connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Desert Palace Exit (West)') - connect_two_way(world, 'Agahnims Tower', 'Desert Palace Exit (North)') - elif dp_target == 'Desert': - connect_two_way(world, 'Desert Palace Entrance (South)', 'Desert Palace Exit (South)') - connect_two_way(world, 'Desert Palace Entrance (East)', 'Desert Palace Exit (East)') - connect_two_way(world, 'Desert Palace Entrance (West)', 'Desert Palace Exit (West)') - connect_two_way(world, 'Desert Palace Entrance (North)', 'Desert Palace Exit (North)') - elif dp_target == 'Turtle Rock': - connect_two_way(world, 'Turtle Rock', 'Desert Palace Exit (South)') - connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Desert Palace Exit (East)') - connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Desert Palace Exit (West)') - connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Desert Palace Exit (North)') + if world.mode != 'inverted': + if hc_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Hyrule Castle Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Agahnims Tower', 'Agahnims Tower Exit', player) + elif hc_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Hyrule Castle Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Agahnims Tower Exit', player) + elif hc_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Hyrule Castle Exit (East)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Agahnims Tower Exit', player) - if tr_target == 'Hyrule Castle': - connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Turtle Rock Exit (Front)') - connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Turtle Rock Ledge Exit (East)') - connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Turtle Rock Ledge Exit (West)') - connect_two_way(world, 'Agahnims Tower', 'Turtle Rock Isolated Ledge Exit') - elif tr_target == 'Desert': - connect_two_way(world, 'Desert Palace Entrance (South)', 'Turtle Rock Exit (Front)') - connect_two_way(world, 'Desert Palace Entrance (North)', 'Turtle Rock Ledge Exit (East)') - connect_two_way(world, 'Desert Palace Entrance (West)', 'Turtle Rock Ledge Exit (West)') - connect_two_way(world, 'Desert Palace Entrance (East)', 'Turtle Rock Isolated Ledge Exit') - elif tr_target == 'Turtle Rock': - connect_two_way(world, 'Turtle Rock', 'Turtle Rock Exit (Front)') - connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Turtle Rock Isolated Ledge Exit') - connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Turtle Rock Ledge Exit (West)') - connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Turtle Rock Ledge Exit (East)') + if dp_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Agahnims Tower', 'Desert Palace Exit (North)', player) + elif dp_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Desert Palace Exit (North)', player) + elif dp_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Desert Palace Exit (North)', player) + + if tr_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Turtle Rock Ledge Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Agahnims Tower', 'Turtle Rock Isolated Ledge Exit', player) + elif tr_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Turtle Rock Ledge Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Turtle Rock Isolated Ledge Exit', player) + elif tr_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Turtle Rock Isolated Ledge Exit', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Turtle Rock Ledge Exit (East)', player) + else: + if hc_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Hyrule Castle Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Inverted Ganons Tower', 'Inverted Ganons Tower Exit', player) + elif hc_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Hyrule Castle Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Inverted Ganons Tower Exit', player) + elif hc_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Hyrule Castle Exit (South)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Inverted Ganons Tower Exit', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Hyrule Castle Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Hyrule Castle Exit (East)', player) + + if dp_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Inverted Ganons Tower', 'Desert Palace Exit (North)', player) + elif dp_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Desert Palace Exit (North)', player) + elif dp_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Desert Palace Exit (South)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Desert Palace Exit (East)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Desert Palace Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Desert Palace Exit (North)', player) + + if tr_target == 'Hyrule Castle': + connect_two_way(world, 'Hyrule Castle Entrance (South)', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Hyrule Castle Entrance (East)', 'Turtle Rock Ledge Exit (East)', player) + connect_two_way(world, 'Hyrule Castle Entrance (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Inverted Ganons Tower', 'Turtle Rock Isolated Ledge Exit', player) + elif tr_target == 'Desert': + connect_two_way(world, 'Desert Palace Entrance (South)', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Desert Palace Entrance (North)', 'Turtle Rock Ledge Exit (East)', player) + connect_two_way(world, 'Desert Palace Entrance (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Desert Palace Entrance (East)', 'Turtle Rock Isolated Ledge Exit', player) + elif tr_target == 'Turtle Rock': + connect_two_way(world, 'Turtle Rock', 'Turtle Rock Exit (Front)', player) + connect_two_way(world, 'Turtle Rock Isolated Ledge Entrance', 'Turtle Rock Isolated Ledge Exit', player) + connect_two_way(world, 'Dark Death Mountain Ledge (West)', 'Turtle Rock Ledge Exit (West)', player) + connect_two_way(world, 'Dark Death Mountain Ledge (East)', 'Turtle Rock Ledge Exit (East)', player) def unbias_some_entrances(Dungeon_Exits, Cave_Exits, Old_Man_House, Cave_Three_Exits): def shuffle_lists_in_list(ls): @@ -1731,6 +2525,308 @@ Single_Cave_Targets = ['Blinds Hideout', 'Kakariko Gamble Game', 'Dam'] +Inverted_LW_Dungeon_Entrances = ['Desert Palace Entrance (South)', + 'Eastern Palace', + 'Tower of Hera', + 'Hyrule Castle Entrance (West)', + 'Hyrule Castle Entrance (East)'] + +Inverted_DW_Dungeon_Entrances = ['Thieves Town', + 'Skull Woods Final Section', + 'Ice Palace', + 'Misery Mire', + 'Palace of Darkness', + 'Swamp Palace', + 'Turtle Rock', + 'Dark Death Mountain Ledge (West)', + 'Dark Death Mountain Ledge (East)', + 'Turtle Rock Isolated Ledge Entrance', + 'Inverted Agahnims Tower'] + +Inverted_LW_Dungeon_Entrances_Must_Exit = ['Desert Palace Entrance (East)'] + +Inverted_Dungeon_Exits_Base = [['Desert Palace Exit (South)', 'Desert Palace Exit (West)', 'Desert Palace Exit (East)'], + 'Desert Palace Exit (North)', + 'Eastern Palace Exit', + 'Tower of Hera Exit', + 'Thieves Town Exit', + 'Skull Woods Final Section Exit', + 'Ice Palace Exit', + 'Misery Mire Exit', + 'Palace of Darkness Exit', + 'Swamp Palace Exit', + 'Inverted Agahnims Tower Exit', + ['Turtle Rock Ledge Exit (East)', + 'Turtle Rock Exit (Front)', 'Turtle Rock Ledge Exit (West)', 'Turtle Rock Isolated Ledge Exit']] + +Inverted_LW_Entrances_Must_Exit = ['Death Mountain Return Cave (West)', + 'Two Brothers House (West)'] + +Inverted_Two_Door_Caves_Directional = [('Old Man Cave (West)', 'Death Mountain Return Cave (West)'), + ('Two Brothers House (East)', 'Two Brothers House (West)')] + + +Inverted_Two_Door_Caves = [('Elder House (East)', 'Elder House (West)'), + ('Superbunny Cave (Bottom)', 'Superbunny Cave (Top)'), + ('Hookshot Cave', 'Hookshot Cave Back Entrance')] + + + +Inverted_Old_Man_Entrances = ['Dark Death Mountain Fairy', + 'Spike Cave'] + +Inverted_LW_Entrances = ['Elder House (East)', + 'Elder House (West)', + 'Two Brothers House (East)', + 'Old Man Cave (East)', + 'Old Man Cave (West)', + 'Old Man House (Bottom)', + 'Old Man House (Top)', + 'Death Mountain Return Cave (East)', + 'Paradox Cave (Bottom)', + 'Paradox Cave (Middle)', + 'Paradox Cave (Top)', + 'Spectacle Rock Cave', + 'Spectacle Rock Cave Peak', + 'Spectacle Rock Cave (Bottom)', + 'Fairy Ascension Cave (Bottom)', + 'Fairy Ascension Cave (Top)', + 'Spiral Cave', + 'Spiral Cave (Bottom)'] + + +Inverted_DW_Entrances = ['Bumper Cave (Bottom)', + 'Superbunny Cave (Top)', + 'Superbunny Cave (Bottom)', + 'Hookshot Cave', + 'Hookshot Cave Back Entrance'] + +Inverted_Bomb_Shop_Multi_Cave_Doors = ['Hyrule Castle Entrance (South)', + 'Misery Mire', + 'Thieves Town', + 'Bumper Cave (Bottom)', + 'Swamp Palace', + 'Hyrule Castle Secret Entrance Stairs', + 'Skull Woods First Section Door', + 'Skull Woods Second Section Door (East)', + 'Skull Woods Second Section Door (West)', + 'Skull Woods Final Section', + 'Ice Palace', + 'Turtle Rock', + 'Dark Death Mountain Ledge (West)', + 'Dark Death Mountain Ledge (East)', + 'Superbunny Cave (Top)', + 'Superbunny Cave (Bottom)', + 'Hookshot Cave', + 'Inverted Agahnims Tower', + 'Desert Palace Entrance (South)', + 'Tower of Hera', + 'Two Brothers House (West)', + 'Old Man Cave (East)', + 'Old Man House (Bottom)', + 'Old Man House (Top)', + 'Death Mountain Return Cave (East)', + 'Death Mountain Return Cave (West)', + 'Spectacle Rock Cave Peak', + 'Spectacle Rock Cave', + 'Spectacle Rock Cave (Bottom)', + 'Paradox Cave (Bottom)', + 'Paradox Cave (Middle)', + 'Paradox Cave (Top)', + 'Fairy Ascension Cave (Bottom)', + 'Fairy Ascension Cave (Top)', + 'Spiral Cave', + 'Spiral Cave (Bottom)', + 'Palace of Darkness', + 'Hyrule Castle Entrance (West)', + 'Hyrule Castle Entrance (East)', + 'Inverted Ganons Tower', + 'Desert Palace Entrance (West)', + 'Desert Palace Entrance (North)'] + +Inverted_Blacksmith_Multi_Cave_Doors = [] # same as non-inverted + +Inverted_LW_Single_Cave_Doors = LW_Single_Cave_Doors + ['Inverted Big Bomb Shop'] + +Inverted_DW_Single_Cave_Doors = ['Bonk Fairy (Dark)', + 'Inverted Dark Sanctuary', + 'Inverted Links House', + 'Dark Lake Hylia Fairy', + 'C-Shaped House', + 'Bumper Cave (Top)', + 'Dark Lake Hylia Shop', + 'Dark World Shop', + 'Red Shield Shop', + 'Mire Shed', + 'East Dark World Hint', + 'Dark Desert Hint', + 'Palace of Darkness Hint', + 'Dark Lake Hylia Ledge Spike Cave', + 'Cave Shop (Dark Death Mountain)', + 'Dark World Potion Shop', + 'Pyramid Fairy', + 'Archery Game', + 'Dark World Lumberjack Shop', + 'Hype Cave', + 'Brewery', + 'Dark Lake Hylia Ledge Hint', + 'Chest Game', + 'Dark Desert Fairy', + 'Dark Lake Hylia Ledge Fairy', + 'Fortune Teller (Dark)', + 'Dark World Hammer Peg Cave'] + + +Inverted_Bomb_Shop_Single_Cave_Doors = ['Waterfall of Wishing', + 'Capacity Upgrade', + 'Bonk Rock Cave', + 'Graveyard Cave', + 'Checkerboard Cave', + 'Cave 45', + 'Kings Grave', + 'Bonk Fairy (Light)', + 'Hookshot Fairy', + 'East Dark World Hint', + 'Palace of Darkness Hint', + 'Dark Lake Hylia Fairy', + 'Dark Lake Hylia Ledge Fairy', + 'Dark Lake Hylia Ledge Spike Cave', + 'Dark Lake Hylia Ledge Hint', + 'Hype Cave', + 'Bonk Fairy (Dark)', + 'Brewery', + 'C-Shaped House', + 'Chest Game', + 'Dark World Hammer Peg Cave', + 'Red Shield Shop', + 'Inverted Dark Sanctuary', + 'Fortune Teller (Dark)', + 'Dark World Shop', + 'Dark World Lumberjack Shop', + 'Dark World Potion Shop', + 'Archery Game', + 'Mire Shed', + 'Dark Desert Hint', + 'Dark Desert Fairy', + 'Spike Cave', + 'Cave Shop (Dark Death Mountain)', + 'Bumper Cave (Top)', + 'Mimic Cave', + 'Dark Lake Hylia Shop', + 'Inverted Links House'] + +Inverted_Blacksmith_Single_Cave_Doors = ['Blinds Hideout', + 'Lake Hylia Fairy', + 'Light Hype Fairy', + 'Desert Fairy', + 'Chicken House', + 'Aginahs Cave', + 'Sahasrahlas Hut', + 'Cave Shop (Lake Hylia)', + 'Blacksmiths Hut', + 'Sick Kids House', + 'Lost Woods Gamble', + 'Fortune Teller (Light)', + 'Snitch Lady (East)', + 'Snitch Lady (West)', + 'Bush Covered House', + 'Tavern (Front)', + 'Light World Bomb Hut', + 'Kakariko Shop', + 'Mini Moldorm Cave', + 'Long Fairy Cave', + 'Good Bee Cave', + '20 Rupee Cave', + '50 Rupee Cave', + 'Ice Rod Cave', + 'Library', + 'Potion Shop', + 'Dam', + 'Lumberjack House', + 'Lake Hylia Fortune Teller', + 'Kakariko Gamble Game', + 'Inverted Big Bomb Shop'] + + +Inverted_Single_Cave_Targets = ['Blinds Hideout', + 'Bonk Fairy (Light)', + 'Lake Hylia Healer Fairy', + 'Swamp Healer Fairy', + 'Desert Healer Fairy', + 'Kings Grave', + 'Chicken House', + 'Aginahs Cave', + 'Sahasrahlas Hut', + 'Cave Shop (Lake Hylia)', + 'Sick Kids House', + 'Lost Woods Gamble', + 'Fortune Teller (Light)', + 'Snitch Lady (East)', + 'Snitch Lady (West)', + 'Bush Covered House', + 'Tavern (Front)', + 'Light World Bomb Hut', + 'Kakariko Shop', + 'Cave 45', + 'Graveyard Cave', + 'Checkerboard Cave', + 'Mini Moldorm Cave', + 'Long Fairy Cave', + 'Good Bee Cave', + '20 Rupee Cave', + '50 Rupee Cave', + 'Ice Rod Cave', + 'Bonk Rock Cave', + 'Library', + 'Potion Shop', + 'Hookshot Fairy', + 'Waterfall of Wishing', + 'Capacity Upgrade', + 'Pyramid Fairy', + 'East Dark World Hint', + 'Palace of Darkness Hint', + 'Dark Lake Hylia Healer Fairy', + 'Dark Lake Hylia Ledge Healer Fairy', + 'Dark Lake Hylia Ledge Spike Cave', + 'Dark Lake Hylia Ledge Hint', + 'Hype Cave', + 'Bonk Fairy (Dark)', + 'Brewery', + 'C-Shaped House', + 'Chest Game', + 'Dark World Hammer Peg Cave', + 'Red Shield Shop', + 'Fortune Teller (Dark)', + 'Village of Outcasts Shop', + 'Dark Lake Hylia Shop', + 'Dark World Lumberjack Shop', + 'Archery Game', + 'Mire Shed', + 'Dark Desert Hint', + 'Dark Desert Healer Fairy', + 'Spike Cave', + 'Cave Shop (Dark Death Mountain)', + 'Dark Death Mountain Healer Fairy', + 'Mimic Cave', + 'Dark World Potion Shop', + 'Lumberjack House', + 'Lake Hylia Fortune Teller', + 'Kakariko Gamble Game', + 'Dam'] + +# in inverted we put dark sanctuary in west dark world for now +Inverted_Dark_Sanctuary_Doors = ['Inverted Dark Sanctuary', + 'Fortune Teller (Dark)', + 'Brewery', + 'C-Shaped House', + 'Chest Game', + 'Dark World Lumberjack Shop', + 'Red Shield Shop', + 'Bumper Cave (Bottom)', + 'Bumper Cave (Top)', + 'Skull Woods Final Section', + 'Thieves Town'] + # these are connections that cannot be shuffled and always exist. They link together separate parts of the world we need to divide into regions mandatory_connections = [('Lake Hylia Central Island Pier', 'Lake Hylia Central Island'), ('Lake Hylia Central Island Teleporter', 'Dark Lake Hylia Central Island'), @@ -1909,6 +3005,221 @@ mandatory_connections = [('Lake Hylia Central Island Pier', 'Lake Hylia Central ('Pyramid Drop', 'East Dark World') ] +inverted_mandatory_connections = [('Lake Hylia Central Island Pier', 'Lake Hylia Central Island'), + ('Zoras River', 'Zoras River'), + ('Kings Grave Outer Rocks', 'Kings Grave Area'), + ('Kings Grave Inner Rocks', 'Light World'), + ('Kakariko Well (top to bottom)', 'Kakariko Well (bottom)'), + ('Master Sword Meadow', 'Master Sword Meadow'), + ('Hobo Bridge', 'Hobo Bridge'), + ('Desert Palace East Wing', 'Desert Palace East'), + ('Bat Cave Drop Ledge', 'Bat Cave Drop Ledge'), + ('Bat Cave Door', 'Bat Cave (left)'), + ('Lost Woods Hideout (top to bottom)', 'Lost Woods Hideout (bottom)'), + ('Lumberjack Tree (top to bottom)', 'Lumberjack Tree (bottom)'), + ('Desert Palace Stairs', 'Desert Palace Stairs'), + ('Desert Palace Stairs Drop', 'Light World'), + ('Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (North) Spot'), + ('Desert Ledge Return Rocks', 'Desert Ledge'), + ('Throne Room', 'Sewers (Dark)'), ('Sewers Door', 'Sewers'), + ('Sanctuary Push Door', 'Sanctuary'), + ('Sewer Drop', 'Sewers'), + ('Sewers Back Door', 'Sewers (Dark)'), + ('Agahnim 1', 'Agahnim 1'), + ('Death Mountain Entrance Rock', 'Death Mountain Entrance'), + ('Death Mountain Entrance Drop', 'Light World'), + ('Spectacle Rock Cave Drop', 'Spectacle Rock Cave (Bottom)'), + ('Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave (Bottom)'), + ('Death Mountain Return Ledge Drop', 'Light World'), + ('Old Man House Front to Back', 'Old Man House Back'), + ('Old Man House Back to Front', 'Old Man House'), + ('Broken Bridge (West)', 'East Death Mountain (Bottom)'), + ('Broken Bridge (East)', 'Death Mountain'), + ('East Death Mountain Drop', 'East Death Mountain (Bottom)'), + ('Spiral Cave Ledge Access', 'Spiral Cave Ledge'), + ('Spiral Cave Ledge Drop', 'East Death Mountain (Bottom)'), + ('Spiral Cave (top to bottom)', 'Spiral Cave (Bottom)'), + ('East Death Mountain (Top)', 'East Death Mountain (Top)'), + ('Death Mountain (Top)', 'Death Mountain (Top)'), + ('Death Mountain Drop', 'Death Mountain'), + ('Tower of Hera Small Key Door', 'Tower of Hera (Basement)'), + ('Tower of Hera Big Key Door', 'Tower of Hera (Top)'), + ('Dark Lake Hylia Drop (East)', 'Dark Lake Hylia'), + ('Dark Lake Hylia Drop (South)', 'Dark Lake Hylia'), + ('Dark Lake Hylia Teleporter', 'Dark Lake Hylia'), + ('Dark Lake Hylia Ledge Pier', 'Dark Lake Hylia Ledge'), + ('Dark Lake Hylia Ledge Drop', 'Dark Lake Hylia'), + ('East Dark World Pier', 'East Dark World'), + ('South Dark World Bridge', 'South Dark World'), + ('East Dark World Bridge', 'East Dark World'), + ('Village of Outcasts Heavy Rock', 'West Dark World'), + ('Village of Outcasts Drop', 'South Dark World'), + ('Village of Outcasts Eastern Rocks', 'Hammer Peg Area'), + ('Village of Outcasts Pegs', 'Dark Grassy Lawn'), + ('Peg Area Rocks', 'West Dark World'), + ('Grassy Lawn Pegs', 'West Dark World'), + ('East Dark World River Pier', 'Northeast Dark World'), + ('West Dark World Gap', 'West Dark World'), + ('East Dark World Broken Bridge Pass', 'East Dark World'), + ('Northeast Dark World Broken Bridge Pass', 'Northeast Dark World'), + ('Bumper Cave Entrance Rock', 'Bumper Cave Entrance'), + ('Bumper Cave Entrance Drop', 'West Dark World'), + ('Bumper Cave Ledge Drop', 'West Dark World'), + ('Skull Woods Forest', 'Skull Woods Forest'), + ('Paradox Cave Push Block Reverse', 'Paradox Cave Chest Area'), + ('Paradox Cave Push Block', 'Paradox Cave Front'), + ('Paradox Cave Bomb Jump', 'Paradox Cave'), + ('Paradox Cave Drop', 'Paradox Cave Chest Area'), + ('Light World Death Mountain Shop', 'Light World Death Mountain Shop'), + ('Fairy Ascension Rocks', 'Fairy Ascension Plateau'), + ('Fairy Ascension Drop', 'East Death Mountain (Bottom)'), + ('Fairy Ascension Ledge Drop', 'Fairy Ascension Plateau'), + ('Fairy Ascension Ledge Access', 'Fairy Ascension Ledge'), + ('Fairy Ascension Cave Climb', 'Fairy Ascension Cave (Top)'), + ('Fairy Ascension Cave Pots', 'Fairy Ascension Cave (Bottom)'), + ('Fairy Ascension Cave Drop', 'Fairy Ascension Cave (Drop)'), + ('Dark Death Mountain Drop (East)', 'Dark Death Mountain (East Bottom)'), + ('Swamp Palace Moat', 'Swamp Palace (First Room)'), + ('Swamp Palace Small Key Door', 'Swamp Palace (Starting Area)'), + ('Swamp Palace (Center)', 'Swamp Palace (Center)'), + ('Swamp Palace (North)', 'Swamp Palace (North)'), + ('Thieves Town Big Key Door', 'Thieves Town (Deep)'), + ('Skull Woods Torch Room', 'Skull Woods Final Section (Mothula)'), + ('Skull Woods First Section Bomb Jump', 'Skull Woods First Section (Top)'), + ('Skull Woods First Section South Door', 'Skull Woods First Section (Right)'), + ('Skull Woods First Section West Door', 'Skull Woods First Section (Left)'), + ('Skull Woods First Section (Right) North Door', 'Skull Woods First Section'), + ('Skull Woods First Section (Left) Door to Right', 'Skull Woods First Section (Right)'), + ('Skull Woods First Section (Left) Door to Exit', 'Skull Woods First Section'), + ('Skull Woods First Section (Top) One-Way Path', 'Skull Woods First Section'), + ('Skull Woods Second Section (Drop)', 'Skull Woods Second Section'), + ('Blind Fight', 'Blind Fight'), + ('Desert Palace Pots (Outer)', 'Desert Palace Main (Inner)'), + ('Desert Palace Pots (Inner)', 'Desert Palace Main (Outer)'), + ('Ice Palace Entrance Room', 'Ice Palace (Main)'), + ('Ice Palace (East)', 'Ice Palace (East)'), + ('Ice Palace (East Top)', 'Ice Palace (East Top)'), + ('Ice Palace (Kholdstare)', 'Ice Palace (Kholdstare)'), + ('Misery Mire Entrance Gap', 'Misery Mire (Main)'), + ('Misery Mire (West)', 'Misery Mire (West)'), + ('Misery Mire Big Key Door', 'Misery Mire (Final Area)'), + ('Misery Mire (Vitreous)', 'Misery Mire (Vitreous)'), + ('Turtle Rock Entrance Gap', 'Turtle Rock (First Section)'), + ('Turtle Rock Entrance Gap Reverse', 'Turtle Rock (Entrance)'), + ('Turtle Rock Pokey Room', 'Turtle Rock (Chain Chomp Room)'), + ('Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Second Section)'), + ('Turtle Rock (Chain Chomp Room) (South)', 'Turtle Rock (First Section)'), + ('Turtle Rock Chain Chomp Staircase', 'Turtle Rock (Chain Chomp Room)'), + ('Turtle Rock (Big Chest) (North)', 'Turtle Rock (Second Section)'), + ('Turtle Rock Big Key Door', 'Turtle Rock (Crystaroller Room)'), + ('Turtle Rock Big Key Door Reverse', 'Turtle Rock (Second Section)'), + ('Turtle Rock Dark Room Staircase', 'Turtle Rock (Dark Room)'), + ('Turtle Rock (Dark Room) (North)', 'Turtle Rock (Crystaroller Room)'), + ('Turtle Rock (Dark Room) (South)', 'Turtle Rock (Eye Bridge)'), + ('Turtle Rock Dark Room (South)', 'Turtle Rock (Dark Room)'), + ('Turtle Rock (Trinexx)', 'Turtle Rock (Trinexx)'), + ('Palace of Darkness Bridge Room', 'Palace of Darkness (Center)'), + ('Palace of Darkness Bonk Wall', 'Palace of Darkness (Bonk Section)'), + ('Palace of Darkness Big Key Chest Staircase', 'Palace of Darkness (Big Key Chest)'), + ('Palace of Darkness (North)', 'Palace of Darkness (North)'), + ('Palace of Darkness Big Key Door', 'Palace of Darkness (Final Section)'), + ('Palace of Darkness Hammer Peg Drop', 'Palace of Darkness (Center)'), + ('Palace of Darkness Spike Statue Room Door', 'Palace of Darkness (Harmless Hellway)'), + ('Palace of Darkness Maze Door', 'Palace of Darkness (Maze)'), + ('Ganons Tower (Tile Room)', 'Ganons Tower (Tile Room)'), + ('Ganons Tower (Tile Room) Key Door', 'Ganons Tower (Compass Room)'), + ('Ganons Tower (Bottom) (East)', 'Ganons Tower (Bottom)'), + ('Ganons Tower (Hookshot Room)', 'Ganons Tower (Hookshot Room)'), + ('Ganons Tower (Map Room)', 'Ganons Tower (Map Room)'), + ('Ganons Tower (Double Switch Room)', 'Ganons Tower (Firesnake Room)'), + ('Ganons Tower (Firesnake Room)', 'Ganons Tower (Teleport Room)'), + ('Ganons Tower (Bottom) (West)', 'Ganons Tower (Bottom)'), + ('Ganons Tower Big Key Door', 'Ganons Tower (Top)'), + ('Ganons Tower Torch Rooms', 'Ganons Tower (Before Moldorm)'), + ('Ganons Tower Moldorm Door', 'Ganons Tower (Moldorm)'), + ('Ganons Tower Moldorm Gap', 'Agahnim 2'), + ('Ganon Drop', 'Bottom of Pyramid'), + ('Pyramid Drop', 'East Dark World'), + ('Post Aga Teleporter', 'Light World'), + ('LW Hyrule Castle Ledge SQ', 'Hyrule Castle Ledge'), + ('EDM Hyrule Castle Ledge SQ', 'Hyrule Castle Ledge'), + ('WDM Hyrule Castle Ledge SQ', 'Hyrule Castle Ledge'), + ('Secret Passage Inner Bushes', 'Light World'), + ('Secret Passage Outer Bushes', 'Hyrule Castle Secret Entrance Area'), + ('Potion Shop Inner Bushes', 'Light World'), + ('Potion Shop Outer Bushes', 'Potion Shop Area'), + ('Potion Shop Inner Rock', 'Northeast Light World'), + ('Potion Shop Outer Rock', 'Potion Shop Area'), + ('Potion Shop River Drop', 'River'), + ('Graveyard Cave Inner Bushes', 'Light World'), + ('Graveyard Cave Outer Bushes', 'Graveyard Cave Area'), + ('Graveyard Cave Mirror Spot', 'West Dark World'), + ('Light World River Drop', 'River'), + ('Light World Pier', 'Light World'), + ('Potion Shop Pier', 'Potion Shop Area'), + ('Hyrule Castle Ledge Courtyard Drop', 'Light World'), + ('Mimic Cave Ledge Access', 'Mimic Cave Ledge'), + ('Mimic Cave Ledge Drop', 'East Death Mountain (Bottom)'), + ('Turtle Rock Tail Drop', 'Turtle Rock (Top)'), + ('Turtle Rock Drop', 'Dark Death Mountain'), + ('Desert Ledge Drop', 'Light World'), + ('Floating Island Drop', 'Dark Death Mountain'), + ('Dark Lake Hylia Central Island Teleporter', 'Lake Hylia Central Island'), + ('Dark Desert Teleporter', 'Light World'), + ('East Dark World Teleporter', 'Light World'), + ('South Dark World Teleporter', 'Light World'), + ('West Dark World Teleporter', 'Light World'), + ('Dark Death Mountain Teleporter (West)', 'Death Mountain'), + ('Dark Death Mountain Teleporter (East)', 'East Death Mountain (Top)'), + ('Dark Death Mountain Teleporter (East Bottom)', 'East Death Mountain (Bottom)'), + ('Mire Mirror Spot', 'Dark Desert'), + ('Dark Desert Drop', 'Dark Desert'), + ('Desert Palace Stairs Mirror Spot', 'Dark Desert'), + ('Desert Palace North Mirror Spot', 'Dark Desert'), + ('Maze Race Mirror Spot', 'West Dark World'), + ('Lake Hylia Central Island Mirror Spot', 'Dark Lake Hylia'), + ('Hammer Peg Area Mirror Spot', 'Hammer Peg Area'), + ('Bumper Cave Ledge Mirror Spot', 'Bumper Cave Ledge'), + ('Bumper Cave Entrance Mirror Spot', 'Bumper Cave Entrance'), + ('Death Mountain Mirror Spot', 'Dark Death Mountain'), + ('East Death Mountain Mirror Spot (Top)', 'Dark Death Mountain'), + ('East Death Mountain Mirror Spot (Bottom)', 'Dark Death Mountain (East Bottom)'), + ('Death Mountain (Top) Mirror Spot', 'Dark Death Mountain'), + ('Dark Death Mountain Ledge Mirror Spot (East)', 'Dark Death Mountain Ledge'), + ('Dark Death Mountain Ledge Mirror Spot (West)', 'Dark Death Mountain Ledge'), + ('Floating Island Mirror Spot', 'Death Mountain Floating Island (Dark World)'), + ('Laser Bridge Mirror Spot', 'Dark Death Mountain Isolated Ledge'), + ('East Dark World Mirror Spot', 'East Dark World'), + ('West Dark World Mirror Spot', 'West Dark World'), + ('South Dark World Mirror Spot', 'South Dark World'), + ('Potion Shop Mirror Spot', 'Northeast Dark World'), + ('Northeast Dark World Mirror Spot', 'Northeast Dark World'), + ('Shopping Mall Mirror Spot', 'Dark Lake Hylia Ledge'), + ('Skull Woods Mirror Spot', 'Skull Woods Forest (West)'), + ('DDM Flute', 'The Sky'), + ('DDM Landing', 'Dark Death Mountain'), + ('NEDW Flute', 'The Sky'), + ('NEDW Landing', 'Northeast Dark World'), + ('WDW Flute', 'The Sky'), + ('WDW Landing', 'West Dark World'), + ('SDW Flute', 'The Sky'), + ('SDW Landing', 'South Dark World'), + ('EDW Flute', 'The Sky'), + ('EDW Landing', 'East Dark World'), + ('DLHL Flute', 'The Sky'), + ('DLHL Landing', 'Dark Lake Hylia Ledge'), + ('DD Flute', 'The Sky'), + ('DD Landing', 'Dark Desert Ledge'), + ('EDDM Flute', 'The Sky'), + ('Dark Grassy Lawn Flute', 'The Sky'), + ('Hammer Peg Area Flute', 'The Sky'), + ('Chris Houlihan Room Exit', 'Pyramid Ledge'), + ('Bush Covered Lawn Inner Bushes', 'Light World'), + ('Bush Covered Lawn Outer Bushes', 'Bush Covered Lawn'), + ('Bush Covered Lawn Mirror Spot', 'Dark Grassy Lawn'), + ('Bomb Hut Inner Bushes', 'Light World'), + ('Bomb Hut Outer Bushes', 'Bomb Hut Area'), + ('Bomb Hut Mirror Spot', 'West Dark World')] # non-shuffled entrance links default_connections = [('Waterfall of Wishing', 'Waterfall of Wishing'), ("Blinds Hideout", "Blinds Hideout"), @@ -1982,8 +3293,8 @@ default_connections = [('Waterfall of Wishing', 'Waterfall of Wishing'), ('Old Man Cave (West)', 'Old Man Cave'), ('Old Man Cave (East)', 'Old Man Cave'), - ('Old Man Cave Exit (West)', 'Death Mountain'), - ('Old Man Cave Exit (East)', 'Light World'), + ('Old Man Cave Exit (West)', 'Light World'), + ('Old Man Cave Exit (East)', 'Death Mountain'), ('Old Man House (Bottom)', 'Old Man House'), ('Old Man House Exit (Bottom)', 'Death Mountain'), ('Old Man House (Top)', 'Old Man House Back'), @@ -2061,6 +3372,154 @@ default_connections = [('Waterfall of Wishing', 'Waterfall of Wishing'), ('Pyramid Entrance', 'Bottom of Pyramid') ] +inverted_default_connections = [('Waterfall of Wishing', 'Waterfall of Wishing'), + ('Blinds Hideout', 'Blinds Hideout'), + ('Dam', 'Dam'), + ('Lumberjack House', 'Lumberjack House'), + ('Hyrule Castle Secret Entrance Drop', 'Hyrule Castle Secret Entrance'), + ('Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Secret Entrance'), + ('Hyrule Castle Secret Entrance Exit', 'Light World'), + ('Bonk Fairy (Light)', 'Bonk Fairy (Light)'), + ('Lake Hylia Fairy', 'Lake Hylia Healer Fairy'), + ('Lake Hylia Fortune Teller', 'Lake Hylia Fortune Teller'), + ('Light Hype Fairy', 'Swamp Healer Fairy'), + ('Desert Fairy', 'Desert Healer Fairy'), + ('Kings Grave', 'Kings Grave'), + ('Tavern North', 'Tavern'), + ('Chicken House', 'Chicken House'), + ('Aginahs Cave', 'Aginahs Cave'), + ('Sahasrahlas Hut', 'Sahasrahlas Hut'), + ('Cave Shop (Lake Hylia)', 'Cave Shop (Lake Hylia)'), + ('Capacity Upgrade', 'Capacity Upgrade'), + ('Kakariko Well Drop', 'Kakariko Well (top)'), + ('Kakariko Well Cave', 'Kakariko Well (bottom)'), + ('Kakariko Well Exit', 'Light World'), + ('Blacksmiths Hut', 'Blacksmiths Hut'), + ('Bat Cave Drop', 'Bat Cave (right)'), + ('Bat Cave Cave', 'Bat Cave (left)'), + ('Bat Cave Exit', 'Light World'), + ('Sick Kids House', 'Sick Kids House'), + ('Elder House (East)', 'Elder House'), + ('Elder House (West)', 'Elder House'), + ('Elder House Exit (East)', 'Light World'), + ('Elder House Exit (West)', 'Light World'), + ('North Fairy Cave Drop', 'North Fairy Cave'), + ('North Fairy Cave', 'North Fairy Cave'), + ('North Fairy Cave Exit', 'Light World'), + ('Lost Woods Gamble', 'Lost Woods Gamble'), + ('Fortune Teller (Light)', 'Fortune Teller (Light)'), + ('Snitch Lady (East)', 'Snitch Lady (East)'), + ('Snitch Lady (West)', 'Snitch Lady (West)'), + ('Bush Covered House', 'Bush Covered House'), + ('Tavern (Front)', 'Tavern (Front)'), + ('Light World Bomb Hut', 'Light World Bomb Hut'), + ('Kakariko Shop', 'Kakariko Shop'), + ('Lost Woods Hideout Drop', 'Lost Woods Hideout (top)'), + ('Lost Woods Hideout Stump', 'Lost Woods Hideout (bottom)'), + ('Lost Woods Hideout Exit', 'Light World'), + ('Lumberjack Tree Tree', 'Lumberjack Tree (top)'), + ('Lumberjack Tree Cave', 'Lumberjack Tree (bottom)'), + ('Lumberjack Tree Exit', 'Light World'), + ('Cave 45', 'Cave 45'), + ('Graveyard Cave', 'Graveyard Cave'), + ('Checkerboard Cave', 'Checkerboard Cave'), + ('Mini Moldorm Cave', 'Mini Moldorm Cave'), + ('Long Fairy Cave', 'Long Fairy Cave'), + ('Good Bee Cave', 'Good Bee Cave'), + ('20 Rupee Cave', '20 Rupee Cave'), + ('50 Rupee Cave', '50 Rupee Cave'), + ('Ice Rod Cave', 'Ice Rod Cave'), + ('Bonk Rock Cave', 'Bonk Rock Cave'), + ('Library', 'Library'), + ('Kakariko Gamble Game', 'Kakariko Gamble Game'), + ('Potion Shop', 'Potion Shop'), + ('Two Brothers House (East)', 'Two Brothers House'), + ('Two Brothers House (West)', 'Two Brothers House'), + ('Two Brothers House Exit (East)', 'Light World'), + ('Two Brothers House Exit (West)', 'Maze Race Ledge'), + ('Sanctuary', 'Sanctuary'), + ('Sanctuary Grave', 'Sewer Drop'), + ('Sanctuary Exit', 'Light World'), + ('Old Man House (Bottom)', 'Old Man House'), + ('Old Man House Exit (Bottom)', 'Death Mountain'), + ('Old Man House (Top)', 'Old Man House Back'), + ('Old Man House Exit (Top)', 'Death Mountain'), + ('Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Peak)'), + ('Spectacle Rock Cave (Bottom)', 'Spectacle Rock Cave (Bottom)'), + ('Spectacle Rock Cave', 'Spectacle Rock Cave (Top)'), + ('Spectacle Rock Cave Exit', 'Death Mountain'), + ('Spectacle Rock Cave Exit (Top)', 'Death Mountain'), + ('Spectacle Rock Cave Exit (Peak)', 'Death Mountain'), + ('Paradox Cave (Bottom)', 'Paradox Cave Front'), + ('Paradox Cave (Middle)', 'Paradox Cave'), + ('Paradox Cave (Top)', 'Paradox Cave'), + ('Paradox Cave Exit (Bottom)', 'East Death Mountain (Bottom)'), + ('Paradox Cave Exit (Middle)', 'East Death Mountain (Bottom)'), + ('Paradox Cave Exit (Top)', 'East Death Mountain (Top)'), + ('Hookshot Fairy', 'Hookshot Fairy'), + ('Fairy Ascension Cave (Bottom)', 'Fairy Ascension Cave (Bottom)'), + ('Fairy Ascension Cave (Top)', 'Fairy Ascension Cave (Top)'), + ('Fairy Ascension Cave Exit (Bottom)', 'Fairy Ascension Plateau'), + ('Fairy Ascension Cave Exit (Top)', 'Fairy Ascension Ledge'), + ('Spiral Cave', 'Spiral Cave (Top)'), + ('Spiral Cave (Bottom)', 'Spiral Cave (Bottom)'), + ('Spiral Cave Exit', 'East Death Mountain (Bottom)'), + ('Spiral Cave Exit (Top)', 'Spiral Cave Ledge'), + ('Pyramid Fairy', 'Pyramid Fairy'), + ('East Dark World Hint', 'East Dark World Hint'), + ('Palace of Darkness Hint', 'Palace of Darkness Hint'), + ('Dark Lake Hylia Shop', 'Dark Lake Hylia Shop'), + ('Dark Lake Hylia Fairy', 'Dark Lake Hylia Healer Fairy'), + ('Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Healer Fairy'), + ('Dark Lake Hylia Ledge Spike Cave', 'Dark Lake Hylia Ledge Spike Cave'), + ('Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Hint'), + ('Hype Cave', 'Hype Cave'), + ('Bonk Fairy (Dark)', 'Bonk Fairy (Dark)'), + ('Brewery', 'Brewery'), + ('C-Shaped House', 'C-Shaped House'), + ('Chest Game', 'Chest Game'), + ('Dark World Hammer Peg Cave', 'Dark World Hammer Peg Cave'), + ('Red Shield Shop', 'Red Shield Shop'), + ('Fortune Teller (Dark)', 'Fortune Teller (Dark)'), + ('Dark World Shop', 'Village of Outcasts Shop'), + ('Dark World Lumberjack Shop', 'Dark World Lumberjack Shop'), + ('Dark World Potion Shop', 'Dark World Potion Shop'), + ('Archery Game', 'Archery Game'), + ('Mire Shed', 'Mire Shed'), + ('Dark Desert Hint', 'Dark Desert Hint'), + ('Dark Desert Fairy', 'Dark Desert Healer Fairy'), + ('Spike Cave', 'Spike Cave'), + ('Hookshot Cave', 'Hookshot Cave'), + ('Superbunny Cave (Top)', 'Superbunny Cave'), + ('Cave Shop (Dark Death Mountain)', 'Cave Shop (Dark Death Mountain)'), + ('Superbunny Cave (Bottom)', 'Superbunny Cave'), + ('Superbunny Cave Exit (Bottom)', 'Dark Death Mountain (East Bottom)'), + ('Hookshot Cave Exit (North)', 'Death Mountain Floating Island (Dark World)'), + ('Hookshot Cave Back Entrance', 'Hookshot Cave'), + ('Mimic Cave', 'Mimic Cave'), + ('Inverted Pyramid Hole', 'Pyramid'), + ('Inverted Links House', 'Inverted Links House'), + ('Inverted Links House Exit', 'South Dark World'), + ('Inverted Big Bomb Shop', 'Inverted Big Bomb Shop'), + ('Inverted Dark Sanctuary', 'Inverted Dark Sanctuary'), + ('Old Man Cave (West)', 'Bumper Cave'), + ('Old Man Cave (East)', 'Death Mountain Return Cave'), + ('Old Man Cave Exit (West)', 'West Dark World'), + ('Old Man Cave Exit (East)', 'Dark Death Mountain'), + ('Dark Death Mountain Fairy', 'Old Man Cave'), + ('Bumper Cave (Bottom)', 'Old Man Cave'), + ('Bumper Cave (Top)', 'Dark Death Mountain Healer Fairy'), + ('Bumper Cave Exit (Top)', 'Death Mountain Return Ledge'), + ('Bumper Cave Exit (Bottom)', 'Light World'), + ('Death Mountain Return Cave (West)', 'Bumper Cave'), + ('Death Mountain Return Cave (East)', 'Death Mountain Return Cave'), + ('Death Mountain Return Cave Exit (West)', 'Death Mountain'), + ('Death Mountain Return Cave Exit (East)', 'Death Mountain'), + ('Hookshot Cave Exit (South)', 'Dark Death Mountain'), + ('Superbunny Cave Exit (Top)', 'Dark Death Mountain'), + ('Pyramid Exit', 'Light World'), + ('Inverted Pyramid Entrance', 'Bottom of Pyramid')] + # non shuffled dungeons default_dungeon_connections = [('Desert Palace Entrance (South)', 'Desert Palace Main (Inner)'), ('Desert Palace Entrance (West)', 'Desert Palace Main (Outer)'), @@ -2121,6 +3580,58 @@ default_dungeon_connections = [('Desert Palace Entrance (South)', 'Desert Palace ('Ganons Tower Exit', 'Dark Death Mountain (Top)') ] +inverted_default_dungeon_connections = [('Desert Palace Entrance (South)', 'Desert Palace Main (Inner)'), + ('Desert Palace Entrance (West)', 'Desert Palace Main (Outer)'), + ('Desert Palace Entrance (North)', 'Desert Palace North'), + ('Desert Palace Entrance (East)', 'Desert Palace Main (Outer)'), + ('Desert Palace Exit (South)', 'Desert Palace Stairs'), + ('Desert Palace Exit (West)', 'Desert Ledge'), + ('Desert Palace Exit (East)', 'Desert Palace Lone Stairs'), + ('Desert Palace Exit (North)', 'Desert Palace Entrance (North) Spot'), + ('Eastern Palace', 'Eastern Palace'), + ('Eastern Palace Exit', 'Light World'), + ('Tower of Hera', 'Tower of Hera (Bottom)'), + ('Tower of Hera Exit', 'Death Mountain (Top)'), + ('Hyrule Castle Entrance (South)', 'Hyrule Castle'), + ('Hyrule Castle Entrance (West)', 'Hyrule Castle'), + ('Hyrule Castle Entrance (East)', 'Hyrule Castle'), + ('Hyrule Castle Exit (South)', 'Light World'), + ('Hyrule Castle Exit (West)', 'Hyrule Castle Ledge'), + ('Hyrule Castle Exit (East)', 'Hyrule Castle Ledge'), + ('Thieves Town', 'Thieves Town (Entrance)'), + ('Thieves Town Exit', 'West Dark World'), + ('Skull Woods First Section Hole (East)', 'Skull Woods First Section (Right)'), + ('Skull Woods First Section Hole (West)', 'Skull Woods First Section (Left)'), + ('Skull Woods First Section Hole (North)', 'Skull Woods First Section (Top)'), + ('Skull Woods First Section Door', 'Skull Woods First Section'), + ('Skull Woods First Section Exit', 'Skull Woods Forest'), + ('Skull Woods Second Section Hole', 'Skull Woods Second Section (Drop)'), + ('Skull Woods Second Section Door (East)', 'Skull Woods Second Section'), + ('Skull Woods Second Section Door (West)', 'Skull Woods Second Section'), + ('Skull Woods Second Section Exit (East)', 'Skull Woods Forest'), + ('Skull Woods Second Section Exit (West)', 'Skull Woods Forest (West)'), + ('Skull Woods Final Section', 'Skull Woods Final Section (Entrance)'), + ('Skull Woods Final Section Exit', 'Skull Woods Forest (West)'), + ('Ice Palace', 'Ice Palace (Entrance)'), + ('Misery Mire', 'Misery Mire (Entrance)'), + ('Misery Mire Exit', 'Dark Desert'), + ('Palace of Darkness', 'Palace of Darkness (Entrance)'), + ('Palace of Darkness Exit', 'East Dark World'), + ('Swamp Palace', 'Swamp Palace (Entrance)'), + ('Swamp Palace Exit', 'South Dark World'), + ('Turtle Rock', 'Turtle Rock (Entrance)'), + ('Turtle Rock Ledge Exit (West)', 'Dark Death Mountain Ledge'), + ('Turtle Rock Ledge Exit (East)', 'Dark Death Mountain Ledge'), + ('Dark Death Mountain Ledge (West)', 'Turtle Rock (Second Section)'), + ('Dark Death Mountain Ledge (East)', 'Turtle Rock (Big Chest)'), + ('Turtle Rock Isolated Ledge Exit', 'Dark Death Mountain Isolated Ledge'), + ('Turtle Rock Isolated Ledge Entrance', 'Turtle Rock (Eye Bridge)'), + ('Inverted Ganons Tower', 'Inverted Ganons Tower (Entrance)'), + ('Inverted Ganons Tower Exit', 'Hyrule Castle Ledge'), + ('Inverted Agahnims Tower', 'Inverted Agahnims Tower'), + ('Inverted Agahnims Tower Exit', 'Dark Death Mountain'), + ('Turtle Rock Exit (Front)', 'Dark Death Mountain'), + ('Ice Palace Exit', 'Dark Lake Hylia')] # format: # Key=Name @@ -2130,6 +3641,7 @@ default_dungeon_connections = [('Desert Palace Entrance (South)', 'Desert Palace # ToDo somehow merge this with creation of the locations door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0x0ae8, 0x08b8, 0x0b07, 0x08bf, 0x06, 0xfe, 0x0816, 0x0000)), + 'Inverted Big Bomb Shop': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0x0ae8, 0x08b8, 0x0b07, 0x08bf, 0x06, 0xfe, 0x0816, 0x0000)), 'Desert Palace Entrance (South)': (0x08, (0x0084, 0x30, 0x0314, 0x0c56, 0x00a6, 0x0ca8, 0x0128, 0x0cc3, 0x0133, 0x0a, 0xfa, 0x0000, 0x0000)), 'Desert Palace Entrance (West)': (0x0A, (0x0083, 0x30, 0x0280, 0x0c46, 0x0003, 0x0c98, 0x0088, 0x0cb3, 0x0090, 0x0a, 0xfd, 0x0000, 0x0000)), 'Desert Palace Entrance (North)': (0x0B, (0x0063, 0x30, 0x0016, 0x0c00, 0x00a2, 0x0c28, 0x0128, 0x0c6d, 0x012f, 0x00, 0x0e, 0x0000, 0x0000)), @@ -2139,7 +3651,9 @@ door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0 'Hyrule Castle Entrance (South)': (0x03, (0x0061, 0x1b, 0x0530, 0x0692, 0x0784, 0x06cc, 0x07f8, 0x06ff, 0x0803, 0x0e, 0xfa, 0x0000, 0x87be)), 'Hyrule Castle Entrance (West)': (0x02, (0x0060, 0x1b, 0x0016, 0x0600, 0x06ae, 0x0604, 0x0728, 0x066d, 0x0733, 0x00, 0x02, 0x0000, 0x8124)), 'Hyrule Castle Entrance (East)': (0x04, (0x0062, 0x1b, 0x004a, 0x0600, 0x0856, 0x0604, 0x08c8, 0x066d, 0x08d3, 0x00, 0xfa, 0x0000, 0x8158)), + 'Inverted Pyramid Entrance': (0x35, (0x0010, 0x1b, 0x0418, 0x0679, 0x06b4, 0x06c6, 0x0728, 0x06e6, 0x0733, 0x07, 0xf9, 0x0000, 0x0000)), 'Agahnims Tower': (0x23, (0x00e0, 0x1b, 0x0032, 0x0600, 0x0784, 0x0634, 0x07f8, 0x066d, 0x0803, 0x00, 0x0a, 0x0000, 0x82be)), + 'Inverted Ganons Tower': (0x23, (0x00e0, 0x1b, 0x0032, 0x0600, 0x0784, 0x0634, 0x07f8, 0x066d, 0x0803, 0x00, 0x0a, 0x0000, 0x82be)), 'Thieves Town': (0x33, (0x00db, 0x58, 0x0b2e, 0x075a, 0x0176, 0x07a8, 0x01f8, 0x07c7, 0x0203, 0x06, 0xfa, 0x0000, 0x0000)), 'Skull Woods First Section Door': (0x29, (0x0058, 0x40, 0x0f4c, 0x01f6, 0x0262, 0x0248, 0x02e8, 0x0263, 0x02ef, 0x0a, 0xfe, 0x0000, 0x0000)), 'Skull Woods Second Section Door (East)': (0x28, (0x0057, 0x40, 0x0eb8, 0x01e6, 0x01c2, 0x0238, 0x0248, 0x0253, 0x024f, 0x0a, 0xfe, 0x0000, 0x0000)), @@ -2187,12 +3701,14 @@ door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0 'Hookshot Cave': (0x39, (0x003c, 0x45, 0x04da, 0x00a3, 0x0cd6, 0x0107, 0x0d48, 0x0112, 0x0d53, 0x0b, 0xfa, 0x0000, 0x0000)), 'Hookshot Cave Back Entrance': (0x3A, (0x002c, 0x45, 0x004c, 0x0000, 0x0c56, 0x0038, 0x0cc8, 0x006f, 0x0cd3, 0x00, 0x0a, 0x0000, 0x0000)), 'Ganons Tower': (0x36, (0x000c, 0x43, 0x0052, 0x0000, 0x0884, 0x0028, 0x08f8, 0x006f, 0x0903, 0x00, 0xfc, 0x0000, 0x0000)), + 'Inverted Agahnims Tower': (0x36, (0x000c, 0x43, 0x0052, 0x0000, 0x0884, 0x0028, 0x08f8, 0x006f, 0x0903, 0x00, 0xfc, 0x0000, 0x0000)), 'Pyramid Entrance': (0x35, (0x0010, 0x5b, 0x0b0e, 0x075a, 0x0674, 0x07a8, 0x06e8, 0x07c7, 0x06f3, 0x06, 0xfa, 0x0000, 0x0000)), 'Skull Woods First Section Hole (West)': ([0xDB84D, 0xDB84E], None), 'Skull Woods First Section Hole (East)': ([0xDB84F, 0xDB850], None), 'Skull Woods First Section Hole (North)': ([0xDB84C], None), 'Skull Woods Second Section Hole': ([0xDB851, 0xDB852], None), 'Pyramid Hole': ([0xDB854, 0xDB855, 0xDB856], None), + 'Inverted Pyramid Hole': ([0xDB854, 0xDB855, 0xDB856, 0x180340], None), 'Waterfall of Wishing': (0x5B, (0x0114, 0x0f, 0x0080, 0x0200, 0x0e00, 0x0207, 0x0e60, 0x026f, 0x0e7d, 0x00, 0x00, 0x0000, 0x0000)), 'Dam': (0x4D, (0x010b, 0x3b, 0x04a0, 0x0e8a, 0x06fa, 0x0ed8, 0x0778, 0x0ef7, 0x077f, 0x06, 0xfa, 0x0000, 0x0000)), 'Blinds Hideout': (0x60, (0x0119, 0x18, 0x02b2, 0x064a, 0x0186, 0x0697, 0x0208, 0x06b7, 0x0213, 0x06, 0xfa, 0x0000, 0x0000)), @@ -2252,6 +3768,7 @@ door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0 'Dark World Hammer Peg Cave': (0x7E, (0x0127, 0x62, 0x0894, 0x091e, 0x0492, 0x09a6, 0x0508, 0x098b, 0x050f, 0x00, 0x00, 0x0000, 0x0000)), 'Red Shield Shop': (0x74, (0x0110, 0x5a, 0x079a, 0x06e8, 0x04d6, 0x0738, 0x0548, 0x0755, 0x0553, 0x08, 0xf8, 0x0AA8, 0x0000)), 'Dark Sanctuary Hint': (0x59, (0x0112, 0x53, 0x001e, 0x0400, 0x06e2, 0x0446, 0x0758, 0x046d, 0x075f, 0x00, 0x00, 0x0000, 0x0000)), + 'Inverted Dark Sanctuary': (0x59, (0x0112, 0x53, 0x001e, 0x0400, 0x06e2, 0x0446, 0x0758, 0x046d, 0x075f, 0x00, 0x00, 0x0000, 0x0000)), 'Fortune Teller (Dark)': (0x65, (0x0122, 0x51, 0x0610, 0x04b4, 0x027e, 0x0507, 0x02f8, 0x0523, 0x0303, 0x0a, 0xf6, 0x091E, 0x0000)), 'Dark World Shop': (0x5F, (0x010f, 0x58, 0x1058, 0x0814, 0x02be, 0x0868, 0x0338, 0x0883, 0x0343, 0x0a, 0xf6, 0x0000, 0x0000)), 'Dark World Lumberjack Shop': (0x56, (0x010f, 0x42, 0x041c, 0x0074, 0x04e2, 0x00c7, 0x0558, 0x00e3, 0x055f, 0x0a, 0xf6, 0x0000, 0x0000)), @@ -2265,6 +3782,7 @@ door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0 'Dark Death Mountain Fairy': (0x6F, (0x0115, 0x43, 0x1400, 0x0294, 0x0600, 0x02e8, 0x0678, 0x0303, 0x0685, 0x0a, 0xf6, 0x0000, 0x0000)), 'Mimic Cave': (0x4E, (0x010c, 0x05, 0x07e0, 0x0103, 0x0d00, 0x0156, 0x0d78, 0x0172, 0x0d7d, 0x0b, 0xf5, 0x0000, 0x0000)), 'Big Bomb Shop': (0x52, (0x011c, 0x6c, 0x0506, 0x0a9a, 0x0832, 0x0ae7, 0x08b8, 0x0b07, 0x08bf, 0x06, 0xfa, 0x0816, 0x0000)), + 'Inverted Links House': (0x52, (0x011c, 0x6c, 0x0506, 0x0a9a, 0x0832, 0x0ae7, 0x08b8, 0x0b07, 0x08bf, 0x06, 0xfa, 0x0816, 0x0000)), 'Dark Lake Hylia Shop': (0x73, (0x010f, 0x75, 0x0380, 0x0c6a, 0x0a00, 0x0cb8, 0x0a58, 0x0cd7, 0x0a85, 0x06, 0xfa, 0x0000, 0x0000)), 'Lumberjack House': (0x75, (0x011f, 0x02, 0x049c, 0x0088, 0x04e6, 0x00d8, 0x0558, 0x00f7, 0x0563, 0x08, 0xf8, 0x07AA, 0x0000)), 'Lake Hylia Fortune Teller': (0x72, (0x0122, 0x35, 0x0380, 0x0c6a, 0x0a00, 0x0cb8, 0x0a58, 0x0cd7, 0x0a85, 0x06, 0xfa, 0x0000, 0x0000)), @@ -2275,6 +3793,7 @@ door_addresses = {'Links House': (0x00, (0x0104, 0x2c, 0x0506, 0x0a9a, 0x0832, 0 # value = entrance # # | (entrance #, exit #) exit_ids = {'Links House Exit': (0x01, 0x00), + 'Inverted Links House Exit': (0x01, 0x00), 'Chris Houlihan Room Exit': (None, 0x3D), 'Desert Palace Exit (South)': (0x09, 0x0A), 'Desert Palace Exit (West)': (0x0B, 0x0C), @@ -2286,6 +3805,7 @@ exit_ids = {'Links House Exit': (0x01, 0x00), 'Hyrule Castle Exit (West)': (0x03, 0x02), 'Hyrule Castle Exit (East)': (0x05, 0x04), 'Agahnims Tower Exit': (0x24, 0x25), + 'Inverted Agahnims Tower Exit': (0x24, 0x25), 'Thieves Town Exit': (0x34, 0x35), 'Skull Woods First Section Exit': (0x2A, 0x2B), 'Skull Woods Second Section Exit (East)': (0x29, 0x2A), @@ -2333,6 +3853,7 @@ exit_ids = {'Links House Exit': (0x01, 0x00), 'Hookshot Cave Exit (South)': (0x3A, 0x3B), 'Hookshot Cave Exit (North)': (0x3B, 0x3C), 'Ganons Tower Exit': (0x37, 0x38), + 'Inverted Ganons Tower Exit': (0x37, 0x38), 'Pyramid Exit': (0x36, 0x37), 'Waterfall of Wishing': 0x5C, 'Dam': 0x4E, @@ -2384,6 +3905,7 @@ exit_ids = {'Links House Exit': (0x01, 0x00), 'East Dark World Hint': 0x69, 'Palace of Darkness Hint': 0x68, 'Big Bomb Shop': 0x53, + 'Inverted Big Bomb Shop': 0x53, 'Village of Outcasts Shop': 0x60, 'Dark Lake Hylia Shop': 0x60, 'Dark World Lumberjack Shop': 0x60, @@ -2397,6 +3919,7 @@ exit_ids = {'Links House Exit': (0x01, 0x00), 'Dark World Hammer Peg Cave': 0x83, 'Red Shield Shop': 0x57, 'Dark Sanctuary Hint': 0x5A, + 'Inverted Dark Sanctuary': 0x5A, 'Fortune Teller (Dark)': 0x66, 'Archery Game': 0x59, 'Mire Shed': 0x5F, diff --git a/Fill.py b/Fill.py index c1becd4480..bfc1145e38 100644 --- a/Fill.py +++ b/Fill.py @@ -1,6 +1,9 @@ import random import logging +from BaseClasses import CollectionState + + class FillError(RuntimeError): pass @@ -167,31 +170,41 @@ def fill_restrictive(world, base_state, locations, itempool): return new_state while itempool and locations: - item_to_place = itempool.pop() + items_to_place = [] + nextpool = [] + placing_players = set() + for item in reversed(itempool): + if item.player not in placing_players: + placing_players.add(item.player) + items_to_place.append(item) + else: + nextpool.insert(0, item) + itempool = nextpool + maximum_exploration_state = sweep_from_pool() perform_access_check = True - if world.check_beatable_only: + if world.accessibility == 'none': perform_access_check = not world.has_beaten_game(maximum_exploration_state) + for item_to_place in items_to_place: + spot_to_fill = None + for location in locations: + if location.can_fill(maximum_exploration_state, item_to_place, perform_access_check): + spot_to_fill = location + break - spot_to_fill = None - for location in locations: - if location.can_fill(maximum_exploration_state, item_to_place, perform_access_check): - spot_to_fill = location - break + if spot_to_fill is None: + # we filled all reachable spots. Maybe the game can be beaten anyway? + if world.can_beat_game(): + if world.accessibility != 'none': + logging.getLogger('').warning('Not all items placed. Game beatable anyway. (Could not place %s)' % item_to_place) + continue + raise FillError('No more spots to place %s' % item_to_place) - if spot_to_fill is None: - # we filled all reachable spots. Maybe the game can be beaten anyway? - if world.can_beat_game(): - if not world.check_beatable_only: - logging.getLogger('').warning('Not all items placed. Game beatable anyway.') - break - raise FillError('No more spots to place %s' % item_to_place) - - world.push_item(spot_to_fill, item_to_place, False) - locations.remove(spot_to_fill) - spot_to_fill.event = True + world.push_item(spot_to_fill, item_to_place, False) + locations.remove(spot_to_fill) + spot_to_fill.event = True def distribute_items_restrictive(world, gftower_trash_count=0, fill_locations=None): @@ -207,20 +220,25 @@ def distribute_items_restrictive(world, gftower_trash_count=0, fill_locations=No restitempool = [item for item in world.itempool if not item.advancement and not item.priority] # fill in gtower locations with trash first - if world.ganonstower_vanilla: - gtower_locations = [location for location in fill_locations if 'Ganons Tower' in location.name] - random.shuffle(gtower_locations) - trashcnt = 0 - while gtower_locations and restitempool and trashcnt < gftower_trash_count: - spot_to_fill = gtower_locations.pop() - item_to_place = restitempool.pop() - world.push_item(spot_to_fill, item_to_place, False) - fill_locations.remove(spot_to_fill) - trashcnt += 1 + for player in range(1, world.players + 1): + if world.ganonstower_vanilla[player]: + gtower_locations = [location for location in fill_locations if 'Ganons Tower' in location.name and location.player == player] + random.shuffle(gtower_locations) + trashcnt = 0 + while gtower_locations and restitempool and trashcnt < gftower_trash_count: + spot_to_fill = gtower_locations.pop() + item_to_place = restitempool.pop() + world.push_item(spot_to_fill, item_to_place, False) + fill_locations.remove(spot_to_fill) + trashcnt += 1 random.shuffle(fill_locations) fill_locations.reverse() + # Make sure the escape small key is placed first in standard keysanity to prevent running out of spots + if world.keysanity and world.mode == 'standard': + progitempool.sort(key=lambda item: 1 if item.name == 'Small Key (Escape)' else 0) + fill_restrictive(world, world.state, fill_locations, progitempool) random.shuffle(fill_locations) @@ -297,3 +315,96 @@ def flood_items(world): world.push_item(location, item_to_place, True) itempool.remove(item_to_place) break + +def balance_multiworld_progression(world): + state = CollectionState(world) + checked_locations = [] + unchecked_locations = world.get_locations().copy() + random.shuffle(unchecked_locations) + + reachable_locations_count = {} + for player in range(1, world.players + 1): + reachable_locations_count[player] = 0 + + def get_sphere_locations(sphere_state, locations): + if not world.keysanity: + sphere_state.sweep_for_events(key_only=True, locations=locations) + return [loc for loc in locations if sphere_state.can_reach(loc)] + + while True: + sphere_locations = get_sphere_locations(state, unchecked_locations) + for location in sphere_locations: + unchecked_locations.remove(location) + reachable_locations_count[location.player] += 1 + + if checked_locations: + average_reachable_locations = sum(reachable_locations_count.values()) / world.players + threshold = ((average_reachable_locations + max(reachable_locations_count.values())) / 2) * 0.8 #todo: probably needs some tweaking + + balancing_players = [player for player, reachables in reachable_locations_count.items() if reachables < threshold] + if balancing_players: + balancing_state = state.copy() + balancing_unchecked_locations = unchecked_locations.copy() + balancing_reachables = reachable_locations_count.copy() + balancing_sphere = sphere_locations.copy() + candidate_items = [] + while True: + for location in balancing_sphere: + if location.event: + balancing_state.collect(location.item, True, location) + if location.item.player in balancing_players: + candidate_items.append(location) + balancing_sphere = get_sphere_locations(balancing_state, balancing_unchecked_locations) + for location in balancing_sphere: + balancing_unchecked_locations.remove(location) + balancing_reachables[location.player] += 1 + if world.has_beaten_game(balancing_state) or all([reachables >= threshold for reachables in balancing_reachables.values()]): + break + + unlocked_locations = [l for l in unchecked_locations if l not in balancing_unchecked_locations] + items_to_replace = [] + for player in balancing_players: + locations_to_test = [l for l in unlocked_locations if l.player == player] + items_to_test = [l for l in candidate_items if l.item.player == player and l.player != player] + while items_to_test: + testing = items_to_test.pop() + reducing_state = state.copy() + for location in [*[l for l in items_to_replace if l.item.player == player], *items_to_test]: + reducing_state.collect(location.item, True, location) + + reducing_state.sweep_for_events(locations=locations_to_test) + + if testing.locked: + continue + + if world.has_beaten_game(balancing_state): + if not world.has_beaten_game(reducing_state): + items_to_replace.append(testing) + else: + reduced_sphere = get_sphere_locations(reducing_state, locations_to_test) + if reachable_locations_count[player] + len(reduced_sphere) < threshold: + items_to_replace.append(testing) + + replaced_items = False + locations_for_replacing = [l for l in checked_locations if not l.event and not l.locked] + while locations_for_replacing and items_to_replace: + new_location = locations_for_replacing.pop() + old_location = items_to_replace.pop() + new_location.item, old_location.item = old_location.item, new_location.item + new_location.event = True + old_location.event = False + state.collect(new_location.item, True, new_location) + replaced_items = True + if replaced_items: + for location in get_sphere_locations(state, [l for l in unlocked_locations if l.player in balancing_players]): + unchecked_locations.remove(location) + reachable_locations_count[location.player] += 1 + sphere_locations.append(location) + + for location in sphere_locations: + if location.event: + state.collect(location.item, True, location) + checked_locations.extend(sphere_locations) + + if world.has_beaten_game(state): + break diff --git a/Gui.py b/Gui.py index 33d83c7fee..e02457d15c 100755 --- a/Gui.py +++ b/Gui.py @@ -5,7 +5,7 @@ import json import random import os import shutil -from tkinter import Checkbutton, OptionMenu, Toplevel, LabelFrame, PhotoImage, Tk, LEFT, RIGHT, BOTTOM, TOP, StringVar, IntVar, Frame, Label, W, E, X, Entry, Spinbox, Button, filedialog, messagebox, ttk +from tkinter import Checkbutton, OptionMenu, Toplevel, LabelFrame, PhotoImage, Tk, LEFT, RIGHT, BOTTOM, TOP, StringVar, IntVar, Frame, Label, W, E, X, BOTH, Entry, Spinbox, Button, filedialog, messagebox, ttk from urllib.parse import urlparse from urllib.request import urlopen @@ -66,8 +66,6 @@ def guiMain(args=None): retroCheckbutton = Checkbutton(checkBoxFrame, text="Retro mode (universal keys)", variable=retroVar) dungeonItemsVar = IntVar() dungeonItemsCheckbutton = Checkbutton(checkBoxFrame, text="Place Dungeon Items (Compasses/Maps)", onvalue=0, offvalue=1, variable=dungeonItemsVar) - beatableOnlyVar = IntVar() - beatableOnlyCheckbutton = Checkbutton(checkBoxFrame, text="Only ensure seed is beatable, not all items must be reachable", variable=beatableOnlyVar) disableMusicVar = IntVar() disableMusicCheckbutton = Checkbutton(checkBoxFrame, text="Disable game music", variable=disableMusicVar) shuffleGanonVar = IntVar() @@ -85,7 +83,6 @@ def guiMain(args=None): keysanityCheckbutton.pack(expand=True, anchor=W) retroCheckbutton.pack(expand=True, anchor=W) dungeonItemsCheckbutton.pack(expand=True, anchor=W) - beatableOnlyCheckbutton.pack(expand=True, anchor=W) disableMusicCheckbutton.pack(expand=True, anchor=W) shuffleGanonCheckbutton.pack(expand=True, anchor=W) hintsCheckbutton.pack(expand=True, anchor=W) @@ -145,7 +142,7 @@ def guiMain(args=None): modeFrame = Frame(drowDownFrame) modeVar = StringVar() modeVar.set('open') - modeOptionMenu = OptionMenu(modeFrame, modeVar, 'standard', 'open', 'swordless') + modeOptionMenu = OptionMenu(modeFrame, modeVar, 'standard', 'open', 'inverted') modeOptionMenu.pack(side=RIGHT) modeLabel = Label(modeFrame, text='Game Mode') modeLabel.pack(side=LEFT) @@ -169,7 +166,7 @@ def guiMain(args=None): difficultyFrame = Frame(drowDownFrame) difficultyVar = StringVar() difficultyVar.set('normal') - difficultyOptionMenu = OptionMenu(difficultyFrame, difficultyVar, 'easy', 'normal', 'hard', 'expert', 'insane') + difficultyOptionMenu = OptionMenu(difficultyFrame, difficultyVar, 'normal', 'hard', 'expert') difficultyOptionMenu.pack(side=RIGHT) difficultyLabel = Label(difficultyFrame, text='Game difficulty') difficultyLabel.pack(side=LEFT) @@ -242,17 +239,77 @@ def guiMain(args=None): heartcolorFrame.pack(expand=True, anchor=E) fastMenuFrame.pack(expand=True, anchor=E) - bottomFrame = Frame(randomizerWindow) + enemizerFrame = LabelFrame(randomizerWindow, text="Enemizer", padx=5, pady=5) + enemizerFrame.columnconfigure(0, weight=1) + enemizerFrame.columnconfigure(1, weight=1) + enemizerFrame.columnconfigure(2, weight=1) + enemizerPathFrame = Frame(enemizerFrame) + enemizerPathFrame.grid(row=0, column=0, columnspan=3, sticky=W) + enemizerCLIlabel = Label(enemizerPathFrame, text="EnemizerCLI path: ") + enemizerCLIlabel.pack(side=LEFT) + enemizerCLIpathVar = StringVar() + enemizerCLIpathEntry = Entry(enemizerPathFrame, textvariable=enemizerCLIpathVar, width=80) + enemizerCLIpathEntry.pack(side=LEFT) + def EnemizerSelectPath(): + path = filedialog.askopenfilename(filetypes=[("EnemizerCLI executable", "*EnemizerCLI*")]) + if path: + enemizerCLIpathVar.set(path) + enemizerCLIbrowseButton = Button(enemizerPathFrame, text='...', command=EnemizerSelectPath) + enemizerCLIbrowseButton.pack(side=LEFT) + + enemyShuffleVar = IntVar() + enemyShuffleButton = Checkbutton(enemizerFrame, text="Enemy shuffle", variable=enemyShuffleVar) + enemyShuffleButton.grid(row=1, column=0) + paletteShuffleVar = IntVar() + paletteShuffleButton = Checkbutton(enemizerFrame, text="Palette shuffle", variable=paletteShuffleVar) + paletteShuffleButton.grid(row=1, column=1) + potShuffleVar = IntVar() + potShuffleButton = Checkbutton(enemizerFrame, text="Pot shuffle", variable=potShuffleVar) + potShuffleButton.grid(row=1, column=2) + + enemizerBossFrame = Frame(enemizerFrame) + enemizerBossFrame.grid(row=2, column=0) + enemizerBossLabel = Label(enemizerBossFrame, text='Boss shuffle') + enemizerBossLabel.pack(side=LEFT) + enemizerBossVar = StringVar() + enemizerBossVar.set('none') + enemizerBossOption = OptionMenu(enemizerBossFrame, enemizerBossVar, 'none', 'basic', 'normal', 'chaos') + enemizerBossOption.pack(side=LEFT) + + enemizerDamageFrame = Frame(enemizerFrame) + enemizerDamageFrame.grid(row=2, column=1) + enemizerDamageLabel = Label(enemizerDamageFrame, text='Enemy damage') + enemizerDamageLabel.pack(side=LEFT) + enemizerDamageVar = StringVar() + enemizerDamageVar.set('default') + enemizerDamageOption = OptionMenu(enemizerDamageFrame, enemizerDamageVar, 'default', 'shuffled', 'chaos') + enemizerDamageOption.pack(side=LEFT) + + enemizerHealthFrame = Frame(enemizerFrame) + enemizerHealthFrame.grid(row=2, column=2) + enemizerHealthLabel = Label(enemizerHealthFrame, text='Enemy health') + enemizerHealthLabel.pack(side=LEFT) + enemizerHealthVar = StringVar() + enemizerHealthVar.set('default') + enemizerHealthOption = OptionMenu(enemizerHealthFrame, enemizerHealthVar, 'default', 'easy', 'normal', 'hard', 'expert') + enemizerHealthOption.pack(side=LEFT) + + bottomFrame = Frame(randomizerWindow, pady=5) + + worldLabel = Label(bottomFrame, text='Worlds') + worldVar = StringVar() + worldSpinbox = Spinbox(bottomFrame, from_=1, to=100, width=5, textvariable=worldVar) seedLabel = Label(bottomFrame, text='Seed #') seedVar = StringVar() - seedEntry = Entry(bottomFrame, textvariable=seedVar) + seedEntry = Entry(bottomFrame, width=15, textvariable=seedVar) countLabel = Label(bottomFrame, text='Count') countVar = StringVar() - countSpinbox = Spinbox(bottomFrame, from_=1, to=100, textvariable=countVar) + countSpinbox = Spinbox(bottomFrame, from_=1, to=100, width=5, textvariable=countVar) def generateRom(): guiargs = Namespace + guiargs.multi = int(worldVar.get()) guiargs.seed = int(seedVar.get()) if seedVar.get() else None guiargs.count = int(countVar.get()) if countVar.get() != '1' else None guiargs.mode = modeVar.get() @@ -271,11 +328,17 @@ def guiMain(args=None): guiargs.keysanity = bool(keysanityVar.get()) guiargs.retro = bool(retroVar.get()) guiargs.nodungeonitems = bool(dungeonItemsVar.get()) - guiargs.beatableonly = bool(beatableOnlyVar.get()) guiargs.quickswap = bool(quickSwapVar.get()) guiargs.disablemusic = bool(disableMusicVar.get()) guiargs.shuffleganon = bool(shuffleGanonVar.get()) guiargs.hints = bool(hintsVar.get()) + guiargs.enemizercli = enemizerCLIpathVar.get() + guiargs.shufflebosses = enemizerBossVar.get() + guiargs.shuffleenemies = bool(enemyShuffleVar.get()) + guiargs.enemy_health = enemizerHealthVar.get() + guiargs.enemy_damage = enemizerDamageVar.get() + guiargs.shufflepalette = bool(paletteShuffleVar.get()) + guiargs.shufflepots = bool(potShuffleVar.get()) guiargs.custom = bool(customVar.get()) guiargs.customitemarray = [int(bowVar.get()), int(silverarrowVar.get()), int(boomerangVar.get()), int(magicboomerangVar.get()), int(hookshotVar.get()), int(mushroomVar.get()), int(magicpowderVar.get()), int(firerodVar.get()), int(icerodVar.get()), int(bombosVar.get()), int(etherVar.get()), int(quakeVar.get()), int(lampVar.get()), int(hammerVar.get()), int(shovelVar.get()), int(fluteVar.get()), int(bugnetVar.get()), @@ -286,10 +349,11 @@ def guiMain(args=None): int(arrow1Var.get()), int(arrow10Var.get()), int(bomb1Var.get()), int(bomb3Var.get()), int(rupee1Var.get()), int(rupee5Var.get()), int(rupee20Var.get()), int(rupee50Var.get()), int(rupee100Var.get()), int(rupee300Var.get()), int(rupoorVar.get()), int(blueclockVar.get()), int(greenclockVar.get()), int(redclockVar.get()), int(triforcepieceVar.get()), int(triforcecountVar.get()), int(triforceVar.get()), int(rupoorcostVar.get()), int(universalkeyVar.get())] - guiargs.shufflebosses = None guiargs.rom = romVar.get() guiargs.jsonout = None guiargs.sprite = sprite + guiargs.skip_playthrough = False + guiargs.outputpath = None try: if guiargs.count is not None: seed = guiargs.seed @@ -305,7 +369,9 @@ def guiMain(args=None): generateButton = Button(bottomFrame, text='Generate Patched Rom', command=generateRom) - seedLabel.pack(side=LEFT) + worldLabel.pack(side=LEFT) + worldSpinbox.pack(side=LEFT) + seedLabel.pack(side=LEFT, padx=(5, 0)) seedEntry.pack(side=LEFT) countLabel.pack(side=LEFT, padx=(5, 0)) countSpinbox.pack(side=LEFT) @@ -317,6 +383,7 @@ def guiMain(args=None): rightHalfFrame.pack(side=RIGHT) topFrame.pack(side=TOP) bottomFrame.pack(side=BOTTOM) + enemizerFrame.pack(side=BOTTOM, fill=BOTH) # Adjuster Controls @@ -384,6 +451,7 @@ def guiMain(args=None): fastMenuLabel2 = Label(fastMenuFrame2, text='Menu speed') fastMenuLabel2.pack(side=LEFT) + heartbeepFrame2.pack(expand=True, anchor=E) heartcolorFrame2.pack(expand=True, anchor=E) fastMenuFrame2.pack(expand=True, anchor=E) @@ -999,7 +1067,6 @@ def guiMain(args=None): retroVar.set(args.retro) if args.nodungeonitems: dungeonItemsVar.set(int(not args.nodungeonitems)) - beatableOnlyVar.set(int(args.beatableonly)) quickSwapVar.set(int(args.quickswap)) disableMusicVar.set(int(args.disablemusic)) if args.count: diff --git a/InvertedRegions.py b/InvertedRegions.py new file mode 100644 index 0000000000..bc2ea357a8 --- /dev/null +++ b/InvertedRegions.py @@ -0,0 +1,642 @@ +import collections +from BaseClasses import Region, Location, Entrance, RegionType, Shop, ShopType + + +def create_inverted_regions(world, player): + + world.regions += [ + create_lw_region(player, 'Light World', ['Mushroom', 'Bottle Merchant', 'Flute Spot', 'Sunken Treasure', 'Purple Chest', 'Bombos Tablet'], + ["Blinds Hideout", "Hyrule Castle Secret Entrance Drop", 'Kings Grave Outer Rocks', 'Dam', + 'Inverted Big Bomb Shop', 'Tavern North', 'Chicken House', 'Aginahs Cave', 'Sahasrahlas Hut', 'Kakariko Well Drop', 'Kakariko Well Cave', + 'Blacksmiths Hut', 'Bat Cave Drop Ledge', 'Bat Cave Cave', 'Sick Kids House', 'Hobo Bridge', 'Lost Woods Hideout Drop', 'Lost Woods Hideout Stump', + 'Lumberjack Tree Tree', 'Lumberjack Tree Cave', 'Mini Moldorm Cave', 'Ice Rod Cave', 'Lake Hylia Central Island Pier', + 'Bonk Rock Cave', 'Library', 'Two Brothers House (East)', 'Desert Palace Stairs', 'Eastern Palace', 'Master Sword Meadow', + 'Sanctuary', 'Sanctuary Grave', 'Death Mountain Entrance Rock', 'Light World River Drop', + 'Elder House (East)', 'Elder House (West)', 'North Fairy Cave', 'North Fairy Cave Drop', 'Lost Woods Gamble', 'Snitch Lady (East)', 'Snitch Lady (West)', 'Tavern (Front)', + 'Kakariko Shop', 'Long Fairy Cave', 'Good Bee Cave', '20 Rupee Cave', 'Cave Shop (Lake Hylia)', + 'Bonk Fairy (Light)', '50 Rupee Cave', 'Fortune Teller (Light)', 'Lake Hylia Fairy', 'Light Hype Fairy', 'Desert Fairy', 'Lumberjack House', 'Lake Hylia Fortune Teller', 'Kakariko Gamble Game', + 'East Dark World Mirror Spot', 'West Dark World Mirror Spot', 'South Dark World Mirror Spot', 'Cave 45', 'Checkerboard Cave', 'Mire Mirror Spot', 'Hammer Peg Area Mirror Spot', + 'Shopping Mall Mirror Spot', 'Skull Woods Mirror Spot', 'Inverted Pyramid Entrance','Hyrule Castle Entrance (South)', 'Secret Passage Outer Bushes', 'LW Hyrule Castle Ledge SQ', 'Bush Covered Lawn Outer Bushes', + 'Potion Shop Outer Bushes', 'Graveyard Cave Outer Bushes', 'Bomb Hut Outer Bushes']), + create_lw_region(player, 'Bush Covered Lawn', None, ['Bush Covered House', 'Bush Covered Lawn Inner Bushes', 'Bush Covered Lawn Mirror Spot']), + create_lw_region(player, 'Bomb Hut Area', None, ['Light World Bomb Hut', 'Bomb Hut Inner Bushes', 'Bomb Hut Mirror Spot']), + create_lw_region(player, 'Hyrule Castle Secret Entrance Area', None, ['Hyrule Castle Secret Entrance Stairs', 'Secret Passage Inner Bushes']), + create_lw_region(player, 'Death Mountain Entrance', None, ['Old Man Cave (West)', 'Death Mountain Entrance Drop', 'Bumper Cave Entrance Mirror Spot']), + create_lw_region(player, 'Lake Hylia Central Island', None, ['Capacity Upgrade', 'Lake Hylia Central Island Mirror Spot']), + create_cave_region(player, 'Blinds Hideout', 'a bounty of five items', ["Blind\'s Hideout - Top", + "Blind\'s Hideout - Left", + "Blind\'s Hideout - Right", + "Blind\'s Hideout - Far Left", + "Blind\'s Hideout - Far Right"]), + create_lw_region(player, 'Northeast Light World', None, ['Zoras River', 'Waterfall of Wishing', 'Potion Shop Outer Rock', 'Northeast Dark World Mirror Spot']), + create_lw_region(player, 'Potion Shop Area', None, ['Potion Shop', 'Potion Shop Inner Bushes', 'Potion Shop Inner Rock', 'Potion Shop Mirror Spot', 'Potion Shop River Drop']), + create_lw_region(player, 'Graveyard Cave Area', None, ['Graveyard Cave', 'Graveyard Cave Inner Bushes', 'Graveyard Cave Mirror Spot']), + create_lw_region(player, 'River', None, ['Light World Pier', 'Potion Shop Pier']), + create_cave_region(player, 'Hyrule Castle Secret Entrance', 'a drop\'s exit', ['Link\'s Uncle', 'Secret Passage'], ['Hyrule Castle Secret Entrance Exit']), + create_lw_region(player, 'Zoras River', ['King Zora', 'Zora\'s Ledge']), + create_cave_region(player, 'Waterfall of Wishing', 'a cave with two chests', ['Waterfall Fairy - Left', 'Waterfall Fairy - Right']), + create_lw_region(player, 'Kings Grave Area', None, ['Kings Grave', 'Kings Grave Inner Rocks']), + create_cave_region(player, 'Kings Grave', 'a cave with a chest', ['King\'s Tomb']), + create_cave_region(player, 'North Fairy Cave', 'a drop\'s exit', None, ['North Fairy Cave Exit']), + create_cave_region(player, 'Dam', 'the dam', ['Floodgate', 'Floodgate Chest']), + create_cave_region(player, 'Inverted Links House', 'your house', ['Link\'s House'], ['Inverted Links House Exit']), + create_cave_region(player, 'Chris Houlihan Room', 'I AM ERROR', None, ['Chris Houlihan Room Exit']), + create_cave_region(player, 'Tavern', 'the tavern', ['Kakariko Tavern']), + create_cave_region(player, 'Elder House', 'a connector', None, ['Elder House Exit (East)', 'Elder House Exit (West)']), + create_cave_region(player, 'Snitch Lady (East)', 'a boring house'), + create_cave_region(player, 'Snitch Lady (West)', 'a boring house'), + create_cave_region(player, 'Bush Covered House', 'the grass man'), + create_cave_region(player, 'Tavern (Front)', 'the tavern'), + create_cave_region(player, 'Light World Bomb Hut', 'a restock room'), + create_cave_region(player, 'Kakariko Shop', 'a common shop'), + create_cave_region(player, 'Fortune Teller (Light)', 'a fortune teller'), + create_cave_region(player, 'Lake Hylia Fortune Teller', 'a fortune teller'), + create_cave_region(player, 'Lumberjack House', 'a boring house'), + create_cave_region(player, 'Bonk Fairy (Light)', 'a fairy fountain'), + create_cave_region(player, 'Bonk Fairy (Dark)', 'a fairy fountain'), + create_cave_region(player, 'Lake Hylia Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Swamp Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Desert Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Lake Hylia Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Lake Hylia Ledge Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Desert Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Death Mountain Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Chicken House', 'a house with a chest', ['Chicken House']), + create_cave_region(player, 'Aginahs Cave', 'a cave with a chest', ['Aginah\'s Cave']), + create_cave_region(player, 'Sahasrahlas Hut', 'Sahasrahla', ['Sahasrahla\'s Hut - Left', 'Sahasrahla\'s Hut - Middle', 'Sahasrahla\'s Hut - Right', 'Sahasrahla']), + create_cave_region(player, 'Kakariko Well (top)', 'a drop\'s exit', ['Kakariko Well - Top', 'Kakariko Well - Left', 'Kakariko Well - Middle', + 'Kakariko Well - Right', 'Kakariko Well - Bottom'], ['Kakariko Well (top to bottom)']), + create_cave_region(player, 'Kakariko Well (bottom)', 'a drop\'s exit', None, ['Kakariko Well Exit']), + create_cave_region(player, 'Blacksmiths Hut', 'the smith', ['Blacksmith', 'Missing Smith']), + create_lw_region(player, 'Bat Cave Drop Ledge', None, ['Bat Cave Drop']), + create_cave_region(player, 'Bat Cave (right)', 'a drop\'s exit', ['Magic Bat'], ['Bat Cave Door']), + create_cave_region(player, 'Bat Cave (left)', 'a drop\'s exit', None, ['Bat Cave Exit']), + create_cave_region(player, 'Sick Kids House', 'the sick kid', ['Sick Kid']), + create_lw_region(player, 'Hobo Bridge', ['Hobo']), + create_cave_region(player, 'Lost Woods Hideout (top)', 'a drop\'s exit', ['Lost Woods Hideout'], ['Lost Woods Hideout (top to bottom)']), + create_cave_region(player, 'Lost Woods Hideout (bottom)', 'a drop\'s exit', None, ['Lost Woods Hideout Exit']), + create_cave_region(player, 'Lumberjack Tree (top)', 'a drop\'s exit', ['Lumberjack Tree'], ['Lumberjack Tree (top to bottom)']), + create_cave_region(player, 'Lumberjack Tree (bottom)', 'a drop\'s exit', None, ['Lumberjack Tree Exit']), + create_cave_region(player, 'Cave 45', 'a cave with an item', ['Cave 45']), + create_cave_region(player, 'Graveyard Cave', 'a cave with an item', ['Graveyard Cave']), + create_cave_region(player, 'Checkerboard Cave', 'a cave with an item', ['Checkerboard Cave']), + create_cave_region(player, 'Long Fairy Cave', 'a fairy fountain'), + create_cave_region(player, 'Mini Moldorm Cave', 'a bounty of five items', ['Mini Moldorm Cave - Far Left', 'Mini Moldorm Cave - Left', 'Mini Moldorm Cave - Right', + 'Mini Moldorm Cave - Far Right', 'Mini Moldorm Cave - Generous Guy']), + create_cave_region(player, 'Ice Rod Cave', 'a cave with a chest', ['Ice Rod Cave']), + create_cave_region(player, 'Good Bee Cave', 'a cold bee'), + create_cave_region(player, '20 Rupee Cave', 'a cave with some cash'), + create_cave_region(player, 'Cave Shop (Lake Hylia)', 'a common shop'), + create_cave_region(player, 'Cave Shop (Dark Death Mountain)', 'a common shop'), + create_cave_region(player, 'Bonk Rock Cave', 'a cave with a chest', ['Bonk Rock Cave']), + create_cave_region(player, 'Library', 'the library', ['Library']), + create_cave_region(player, 'Kakariko Gamble Game', 'a game of chance'), + create_cave_region(player, 'Potion Shop', 'the potion shop', ['Potion Shop']), + create_lw_region(player, 'Lake Hylia Island', ['Lake Hylia Island']), + create_cave_region(player, 'Capacity Upgrade', 'the queen of fairies'), + create_cave_region(player, 'Two Brothers House', 'a connector', None, ['Two Brothers House Exit (East)', 'Two Brothers House Exit (West)']), + create_lw_region(player, 'Maze Race Ledge', ['Maze Race'], ['Two Brothers House (West)', 'Maze Race Mirror Spot']), + create_cave_region(player, '50 Rupee Cave', 'a cave with some cash'), + create_lw_region(player, 'Desert Ledge', ['Desert Ledge'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)', 'Desert Ledge Drop']), + create_lw_region(player, 'Desert Palace Stairs', None, ['Desert Palace Entrance (South)', 'Desert Palace Stairs Mirror Spot']), + create_lw_region(player, 'Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)']), + create_lw_region(player, 'Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks', 'Desert Palace North Mirror Spot']), + create_dungeon_region(player, 'Desert Palace Main (Outer)', 'Desert Palace', ['Desert Palace - Big Chest', 'Desert Palace - Torch', 'Desert Palace - Map Chest'], + ['Desert Palace Pots (Outer)', 'Desert Palace Exit (West)', 'Desert Palace Exit (East)', 'Desert Palace East Wing']), + create_dungeon_region(player, 'Desert Palace Main (Inner)', 'Desert Palace', None, ['Desert Palace Exit (South)', 'Desert Palace Pots (Inner)']), + create_dungeon_region(player, 'Desert Palace East', 'Desert Palace', ['Desert Palace - Compass Chest', 'Desert Palace - Big Key Chest']), + create_dungeon_region(player, 'Desert Palace North', 'Desert Palace', ['Desert Palace - Boss', 'Desert Palace - Prize'], ['Desert Palace Exit (North)']), + create_dungeon_region(player, 'Eastern Palace', 'Eastern Palace', ['Eastern Palace - Compass Chest', 'Eastern Palace - Big Chest', 'Eastern Palace - Cannonball Chest', + 'Eastern Palace - Big Key Chest', 'Eastern Palace - Map Chest', 'Eastern Palace - Boss', 'Eastern Palace - Prize'], ['Eastern Palace Exit']), + create_lw_region(player, 'Master Sword Meadow', ['Master Sword Pedestal']), + create_cave_region(player, 'Lost Woods Gamble', 'a game of chance'), + create_lw_region(player, 'Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Inverted Ganons Tower', 'Hyrule Castle Ledge Courtyard Drop', 'Inverted Pyramid Hole']), + create_dungeon_region(player, 'Hyrule Castle', 'Hyrule Castle', ['Hyrule Castle - Boomerang Chest', 'Hyrule Castle - Map Chest', 'Hyrule Castle - Zelda\'s Chest'], + ['Hyrule Castle Exit (East)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (South)', 'Throne Room']), + create_dungeon_region(player, 'Sewer Drop', 'a drop\'s exit', None, ['Sewer Drop']), # This exists only to be referenced for access checks + create_dungeon_region(player, 'Sewers (Dark)', 'a drop\'s exit', ['Sewers - Dark Cross'], ['Sewers Door']), + create_dungeon_region(player, 'Sewers', 'a drop\'s exit', ['Sewers - Secret Room - Left', 'Sewers - Secret Room - Middle', + 'Sewers - Secret Room - Right'], ['Sanctuary Push Door', 'Sewers Back Door']), + create_dungeon_region(player, 'Sanctuary', 'a drop\'s exit', ['Sanctuary'], ['Sanctuary Exit']), + create_dungeon_region(player, 'Inverted Agahnims Tower', 'Castle Tower', ['Castle Tower - Room 03', 'Castle Tower - Dark Maze'], ['Agahnim 1', 'Inverted Agahnims Tower Exit']), + create_dungeon_region(player, 'Agahnim 1', 'Castle Tower', ['Agahnim 1'], None), + create_cave_region(player, 'Old Man Cave', 'a connector', ['Old Man'], ['Old Man Cave Exit (East)', 'Old Man Cave Exit (West)']), + create_cave_region(player, 'Old Man House', 'a connector', None, ['Old Man House Exit (Bottom)', 'Old Man House Front to Back']), + create_cave_region(player, 'Old Man House Back', 'a connector', None, ['Old Man House Exit (Top)', 'Old Man House Back to Front']), + create_lw_region(player, 'Death Mountain', None, ['Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave', + 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)', 'Broken Bridge (West)', 'Death Mountain Mirror Spot', 'WDM Hyrule Castle Ledge SQ']), + create_cave_region(player, 'Death Mountain Return Cave', 'a connector', None, ['Death Mountain Return Cave Exit (West)', 'Death Mountain Return Cave Exit (East)']), + create_lw_region(player, 'Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)', 'Bumper Cave Ledge Mirror Spot']), + create_cave_region(player, 'Spectacle Rock Cave (Top)', 'a connector', ['Spectacle Rock Cave'], ['Spectacle Rock Cave Drop', 'Spectacle Rock Cave Exit (Top)']), + create_cave_region(player, 'Spectacle Rock Cave (Bottom)', 'a connector', None, ['Spectacle Rock Cave Exit']), + create_cave_region(player, 'Spectacle Rock Cave (Peak)', 'a connector', None, ['Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave Exit (Peak)']), + create_lw_region(player, 'East Death Mountain (Bottom)', None, ['Broken Bridge (East)', 'Paradox Cave (Bottom)', 'Paradox Cave (Middle)', 'East Death Mountain Mirror Spot (Bottom)', 'Hookshot Fairy', + 'Fairy Ascension Rocks', 'Spiral Cave (Bottom)', 'EDM Hyrule Castle Ledge SQ']), + create_cave_region(player, 'Hookshot Fairy', 'fairies deep in a cave'), + create_cave_region(player, 'Paradox Cave Front', 'a connector', None, ['Paradox Cave Push Block Reverse', 'Paradox Cave Exit (Bottom)', 'Light World Death Mountain Shop']), + create_cave_region(player, 'Paradox Cave Chest Area', 'a connector', ['Paradox Cave Lower - Far Left', + 'Paradox Cave Lower - Left', + 'Paradox Cave Lower - Right', + 'Paradox Cave Lower - Far Right', + 'Paradox Cave Lower - Middle', + 'Paradox Cave Upper - Left', + 'Paradox Cave Upper - Right'], + ['Paradox Cave Push Block', 'Paradox Cave Bomb Jump']), + create_cave_region(player, 'Paradox Cave', 'a connector', None, ['Paradox Cave Exit (Middle)', 'Paradox Cave Exit (Top)', 'Paradox Cave Drop']), + create_cave_region(player, 'Light World Death Mountain Shop', 'a common shop'), + create_lw_region(player, 'East Death Mountain (Top)', ['Floating Island'], ['Paradox Cave (Top)', 'Death Mountain (Top)', 'Spiral Cave Ledge Access', 'East Death Mountain Drop', 'East Death Mountain Mirror Spot (Top)', 'Fairy Ascension Ledge Access', 'Mimic Cave Ledge Access', + 'Floating Island Mirror Spot']), + create_lw_region(player, 'Spiral Cave Ledge', None, ['Spiral Cave', 'Spiral Cave Ledge Drop', 'Dark Death Mountain Ledge Mirror Spot (West)']), + create_lw_region(player, 'Mimic Cave Ledge', None, ['Mimic Cave', 'Mimic Cave Ledge Drop', 'Dark Death Mountain Ledge Mirror Spot (East)']), + create_cave_region(player, 'Spiral Cave (Top)', 'a connector', ['Spiral Cave'], ['Spiral Cave (top to bottom)', 'Spiral Cave Exit (Top)']), + create_cave_region(player, 'Spiral Cave (Bottom)', 'a connector', None, ['Spiral Cave Exit']), + create_lw_region(player, 'Fairy Ascension Plateau', None, ['Fairy Ascension Drop', 'Fairy Ascension Cave (Bottom)']), + create_cave_region(player, 'Fairy Ascension Cave (Bottom)', 'a connector', None, ['Fairy Ascension Cave Climb', 'Fairy Ascension Cave Exit (Bottom)']), + create_cave_region(player, 'Fairy Ascension Cave (Drop)', 'a connector', None, ['Fairy Ascension Cave Pots']), + create_cave_region(player, 'Fairy Ascension Cave (Top)', 'a connector', None, ['Fairy Ascension Cave Exit (Top)', 'Fairy Ascension Cave Drop']), + create_lw_region(player, 'Fairy Ascension Ledge', None, ['Fairy Ascension Ledge Drop', 'Fairy Ascension Cave (Top)', 'Laser Bridge Mirror Spot']), + create_lw_region(player, 'Death Mountain (Top)', ['Ether Tablet', 'Spectacle Rock'], ['East Death Mountain (Top)', 'Tower of Hera', 'Death Mountain Drop', 'Death Mountain (Top) Mirror Spot']), + create_dw_region(player, 'Bumper Cave Ledge', ['Bumper Cave Ledge'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)']), + create_dungeon_region(player, 'Tower of Hera (Bottom)', 'Tower of Hera', ['Tower of Hera - Basement Cage', 'Tower of Hera - Map Chest'], ['Tower of Hera Small Key Door', 'Tower of Hera Big Key Door', 'Tower of Hera Exit']), + create_dungeon_region(player, 'Tower of Hera (Basement)', 'Tower of Hera', ['Tower of Hera - Big Key Chest']), + create_dungeon_region(player, 'Tower of Hera (Top)', 'Tower of Hera', ['Tower of Hera - Compass Chest', 'Tower of Hera - Big Chest', 'Tower of Hera - Boss', 'Tower of Hera - Prize']), + + create_dw_region(player, 'East Dark World', ['Pyramid'], ['Pyramid Fairy', 'South Dark World Bridge', 'Palace of Darkness', 'Dark Lake Hylia Drop (East)', + 'Dark Lake Hylia Fairy', 'Palace of Darkness Hint', 'East Dark World Hint', 'Northeast Dark World Broken Bridge Pass', 'East Dark World Teleporter', 'EDW Flute']), + create_dw_region(player, 'Northeast Dark World', ['Catfish'], ['West Dark World Gap', 'Dark World Potion Shop', 'East Dark World Broken Bridge Pass', 'NEDW Flute', 'Dark Lake Hylia Teleporter']), + create_cave_region(player, 'Palace of Darkness Hint', 'a storyteller'), + create_cave_region(player, 'East Dark World Hint', 'a storyteller'), + create_dw_region(player, 'South Dark World', ['Stumpy', 'Digging Game'], ['Dark Lake Hylia Drop (South)', 'Hype Cave', 'Swamp Palace', 'Village of Outcasts Heavy Rock', 'East Dark World Bridge', 'Inverted Links House', 'Archery Game', 'Bonk Fairy (Dark)', + 'Dark Lake Hylia Shop', 'South Dark World Teleporter', 'Post Aga Teleporter', 'SDW Flute']), + create_cave_region(player, 'Inverted Big Bomb Shop', 'the bomb shop'), + create_cave_region(player, 'Archery Game', 'a game of skill'), + create_dw_region(player, 'Dark Lake Hylia', None, ['East Dark World Pier', 'Dark Lake Hylia Ledge Pier', 'Ice Palace', 'Dark Lake Hylia Central Island Teleporter']), + create_dw_region(player, 'Dark Lake Hylia Ledge', None, ['Dark Lake Hylia Ledge Drop', 'Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Spike Cave', 'DLHL Flute']), + create_cave_region(player, 'Dark Lake Hylia Ledge Hint', 'a storyteller'), + create_cave_region(player, 'Dark Lake Hylia Ledge Spike Cave', 'a spiky hint'), + create_cave_region(player, 'Hype Cave', 'a bounty of five items', ['Hype Cave - Top', 'Hype Cave - Middle Right', 'Hype Cave - Middle Left', + 'Hype Cave - Bottom', 'Hype Cave - Generous Guy']), + create_dw_region(player, 'West Dark World', ['Frog'], ['Village of Outcasts Drop', 'East Dark World River Pier', 'Brewery', 'C-Shaped House', 'Chest Game', 'Thieves Town', 'Bumper Cave Entrance Rock', + 'Skull Woods Forest', 'Village of Outcasts Pegs', 'Village of Outcasts Eastern Rocks', 'Red Shield Shop', 'Inverted Dark Sanctuary', 'Fortune Teller (Dark)', 'Dark World Lumberjack Shop', + 'West Dark World Teleporter', 'WDW Flute']), + create_dw_region(player, 'Dark Grassy Lawn', None, ['Grassy Lawn Pegs', 'Dark World Shop', 'Dark Grassy Lawn Flute']), + create_dw_region(player, 'Hammer Peg Area', ['Dark Blacksmith Ruins'], ['Dark World Hammer Peg Cave', 'Peg Area Rocks', 'Hammer Peg Area Flute']), + create_dw_region(player, 'Bumper Cave Entrance', None, ['Bumper Cave (Bottom)', 'Bumper Cave Entrance Drop']), + create_cave_region(player, 'Fortune Teller (Dark)', 'a fortune teller'), + create_cave_region(player, 'Village of Outcasts Shop', 'a common shop'), + create_cave_region(player, 'Dark Lake Hylia Shop', 'a common shop'), + create_cave_region(player, 'Dark World Lumberjack Shop', 'a common shop'), + create_cave_region(player, 'Dark World Potion Shop', 'a common shop'), + create_cave_region(player, 'Dark World Hammer Peg Cave', 'a cave with an item', ['Peg Cave']), + create_cave_region(player, 'Pyramid Fairy', 'a cave with two chests', ['Pyramid Fairy - Left', 'Pyramid Fairy - Right']), + create_cave_region(player, 'Brewery', 'a house with a chest', ['Brewery']), + create_cave_region(player, 'C-Shaped House', 'a house with a chest', ['C-Shaped House']), + create_cave_region(player, 'Chest Game', 'a game of 16 chests', ['Chest Game']), + create_cave_region(player, 'Red Shield Shop', 'the rare shop'), + create_cave_region(player, 'Inverted Dark Sanctuary', 'a storyteller'), + create_cave_region(player, 'Bumper Cave', 'a connector', None, ['Bumper Cave Exit (Bottom)', 'Bumper Cave Exit (Top)']), + create_dw_region(player, 'Skull Woods Forest', None, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', + 'Skull Woods First Section Door', 'Skull Woods Second Section Door (East)']), + create_dw_region(player, 'Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section']), + create_dw_region(player, 'Dark Desert', None, ['Misery Mire', 'Mire Shed', 'Dark Desert Hint', 'Dark Desert Fairy', 'DD Flute']), + create_dw_region(player, 'Dark Desert Ledge', None, ['Dark Desert Drop', 'Dark Desert Teleporter']), + create_cave_region(player, 'Mire Shed', 'a cave with two chests', ['Mire Shed - Left', 'Mire Shed - Right']), + create_cave_region(player, 'Dark Desert Hint', 'a storyteller'), + create_dw_region(player, 'Dark Death Mountain', None, ['Dark Death Mountain Drop (East)', 'Inverted Agahnims Tower', 'Superbunny Cave (Top)', 'Hookshot Cave', 'Turtle Rock', + 'Spike Cave', 'Dark Death Mountain Fairy', 'Dark Death Mountain Teleporter (West)', 'Turtle Rock Tail Drop', 'DDM Flute']), + create_dw_region(player, 'Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)']), + create_dw_region(player, 'Turtle Rock (Top)', None, ['Dark Death Mountain Teleporter (East)', 'Turtle Rock Drop']), + create_dw_region(player, 'Dark Death Mountain Isolated Ledge', None, ['Turtle Rock Isolated Ledge Entrance']), + create_dw_region(player, 'Dark Death Mountain (East Bottom)', None, ['Superbunny Cave (Bottom)', 'Cave Shop (Dark Death Mountain)', 'Dark Death Mountain Teleporter (East Bottom)', 'EDDM Flute']), + create_cave_region(player, 'Superbunny Cave', 'a connector', ['Superbunny Cave - Top', 'Superbunny Cave - Bottom'], + ['Superbunny Cave Exit (Top)', 'Superbunny Cave Exit (Bottom)']), + create_cave_region(player, 'Spike Cave', 'Spike Cave', ['Spike Cave']), + create_cave_region(player, 'Hookshot Cave', 'a connector', ['Hookshot Cave - Top Right', 'Hookshot Cave - Top Left', 'Hookshot Cave - Bottom Right', 'Hookshot Cave - Bottom Left'], + ['Hookshot Cave Exit (South)', 'Hookshot Cave Exit (North)']), + create_dw_region(player, 'Death Mountain Floating Island (Dark World)', None, ['Floating Island Drop', 'Hookshot Cave Back Entrance']), + create_cave_region(player, 'Mimic Cave', 'Mimic Cave', ['Mimic Cave']), + + create_dungeon_region(player, 'Swamp Palace (Entrance)', 'Swamp Palace', None, ['Swamp Palace Moat', 'Swamp Palace Exit']), + create_dungeon_region(player, 'Swamp Palace (First Room)', 'Swamp Palace', ['Swamp Palace - Entrance'], ['Swamp Palace Small Key Door']), + create_dungeon_region(player, 'Swamp Palace (Starting Area)', 'Swamp Palace', ['Swamp Palace - Map Chest'], ['Swamp Palace (Center)']), + create_dungeon_region(player, 'Swamp Palace (Center)', 'Swamp Palace', ['Swamp Palace - Big Chest', 'Swamp Palace - Compass Chest', + 'Swamp Palace - Big Key Chest', 'Swamp Palace - West Chest'], ['Swamp Palace (North)']), + create_dungeon_region(player, 'Swamp Palace (North)', 'Swamp Palace', ['Swamp Palace - Flooded Room - Left', 'Swamp Palace - Flooded Room - Right', + 'Swamp Palace - Waterfall Room', 'Swamp Palace - Boss', 'Swamp Palace - Prize']), + create_dungeon_region(player, 'Thieves Town (Entrance)', 'Thieves\' Town', ['Thieves\' Town - Big Key Chest', + 'Thieves\' Town - Map Chest', + 'Thieves\' Town - Compass Chest', + 'Thieves\' Town - Ambush Chest'], ['Thieves Town Big Key Door', 'Thieves Town Exit']), + create_dungeon_region(player, 'Thieves Town (Deep)', 'Thieves\' Town', ['Thieves\' Town - Attic', + 'Thieves\' Town - Big Chest', + 'Thieves\' Town - Blind\'s Cell'], ['Blind Fight']), + create_dungeon_region(player, 'Blind Fight', 'Thieves\' Town', ['Thieves\' Town - Boss', 'Thieves\' Town - Prize']), + create_dungeon_region(player, 'Skull Woods First Section', 'Skull Woods', ['Skull Woods - Map Chest'], ['Skull Woods First Section Exit', 'Skull Woods First Section Bomb Jump', 'Skull Woods First Section South Door', 'Skull Woods First Section West Door']), + create_dungeon_region(player, 'Skull Woods First Section (Right)', 'Skull Woods', ['Skull Woods - Pinball Room'], ['Skull Woods First Section (Right) North Door']), + create_dungeon_region(player, 'Skull Woods First Section (Left)', 'Skull Woods', ['Skull Woods - Compass Chest', 'Skull Woods - Pot Prison'], ['Skull Woods First Section (Left) Door to Exit', 'Skull Woods First Section (Left) Door to Right']), + create_dungeon_region(player, 'Skull Woods First Section (Top)', 'Skull Woods', ['Skull Woods - Big Chest'], ['Skull Woods First Section (Top) One-Way Path']), + create_dungeon_region(player, 'Skull Woods Second Section (Drop)', 'Skull Woods', None, ['Skull Woods Second Section (Drop)']), + create_dungeon_region(player, 'Skull Woods Second Section', 'Skull Woods', ['Skull Woods - Big Key Chest'], ['Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)']), + create_dungeon_region(player, 'Skull Woods Final Section (Entrance)', 'Skull Woods', ['Skull Woods - Bridge Room'], ['Skull Woods Torch Room', 'Skull Woods Final Section Exit']), + create_dungeon_region(player, 'Skull Woods Final Section (Mothula)', 'Skull Woods', ['Skull Woods - Boss', 'Skull Woods - Prize']), + create_dungeon_region(player, 'Ice Palace (Entrance)', 'Ice Palace', None, ['Ice Palace Entrance Room', 'Ice Palace Exit']), + create_dungeon_region(player, 'Ice Palace (Main)', 'Ice Palace', ['Ice Palace - Compass Chest', 'Ice Palace - Freezor Chest', + 'Ice Palace - Big Chest', 'Ice Palace - Iced T Room'], ['Ice Palace (East)', 'Ice Palace (Kholdstare)']), + create_dungeon_region(player, 'Ice Palace (East)', 'Ice Palace', ['Ice Palace - Spike Room'], ['Ice Palace (East Top)']), + create_dungeon_region(player, 'Ice Palace (East Top)', 'Ice Palace', ['Ice Palace - Big Key Chest', 'Ice Palace - Map Chest']), + create_dungeon_region(player, 'Ice Palace (Kholdstare)', 'Ice Palace', ['Ice Palace - Boss', 'Ice Palace - Prize']), + create_dungeon_region(player, 'Misery Mire (Entrance)', 'Misery Mire', None, ['Misery Mire Entrance Gap', 'Misery Mire Exit']), + create_dungeon_region(player, 'Misery Mire (Main)', 'Misery Mire', ['Misery Mire - Big Chest', 'Misery Mire - Map Chest', 'Misery Mire - Main Lobby', + 'Misery Mire - Bridge Chest', 'Misery Mire - Spike Chest'], ['Misery Mire (West)', 'Misery Mire Big Key Door']), + create_dungeon_region(player, 'Misery Mire (West)', 'Misery Mire', ['Misery Mire - Compass Chest', 'Misery Mire - Big Key Chest']), + create_dungeon_region(player, 'Misery Mire (Final Area)', 'Misery Mire', None, ['Misery Mire (Vitreous)']), + create_dungeon_region(player, 'Misery Mire (Vitreous)', 'Misery Mire', ['Misery Mire - Boss', 'Misery Mire - Prize']), + create_dungeon_region(player, 'Turtle Rock (Entrance)', 'Turtle Rock', None, ['Turtle Rock Entrance Gap', 'Turtle Rock Exit (Front)']), + create_dungeon_region(player, 'Turtle Rock (First Section)', 'Turtle Rock', ['Turtle Rock - Compass Chest', 'Turtle Rock - Roller Room - Left', + 'Turtle Rock - Roller Room - Right'], ['Turtle Rock Pokey Room', 'Turtle Rock Entrance Gap Reverse']), + create_dungeon_region(player, 'Turtle Rock (Chain Chomp Room)', 'Turtle Rock', ['Turtle Rock - Chain Chomps'], ['Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)']), + create_dungeon_region(player, 'Turtle Rock (Second Section)', 'Turtle Rock', ['Turtle Rock - Big Key Chest'], ['Turtle Rock Ledge Exit (West)', 'Turtle Rock Chain Chomp Staircase', 'Turtle Rock Big Key Door']), + create_dungeon_region(player, 'Turtle Rock (Big Chest)', 'Turtle Rock', ['Turtle Rock - Big Chest'], ['Turtle Rock (Big Chest) (North)', 'Turtle Rock Ledge Exit (East)']), + create_dungeon_region(player, 'Turtle Rock (Crystaroller Room)', 'Turtle Rock', ['Turtle Rock - Crystaroller Room'], ['Turtle Rock Dark Room Staircase', 'Turtle Rock Big Key Door Reverse']), + create_dungeon_region(player, 'Turtle Rock (Dark Room)', 'Turtle Rock', None, ['Turtle Rock (Dark Room) (North)', 'Turtle Rock (Dark Room) (South)']), + create_dungeon_region(player, 'Turtle Rock (Eye Bridge)', 'Turtle Rock', ['Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', + 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'], + ['Turtle Rock Dark Room (South)', 'Turtle Rock (Trinexx)', 'Turtle Rock Isolated Ledge Exit']), + create_dungeon_region(player, 'Turtle Rock (Trinexx)', 'Turtle Rock', ['Turtle Rock - Boss', 'Turtle Rock - Prize']), + create_dungeon_region(player, 'Palace of Darkness (Entrance)', 'Palace of Darkness', ['Palace of Darkness - Shooter Room'], ['Palace of Darkness Bridge Room', 'Palace of Darkness Bonk Wall', 'Palace of Darkness Exit']), + create_dungeon_region(player, 'Palace of Darkness (Center)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Bridge', 'Palace of Darkness - Stalfos Basement'], + ['Palace of Darkness Big Key Chest Staircase', 'Palace of Darkness (North)', 'Palace of Darkness Big Key Door']), + create_dungeon_region(player, 'Palace of Darkness (Big Key Chest)', 'Palace of Darkness', ['Palace of Darkness - Big Key Chest']), + create_dungeon_region(player, 'Palace of Darkness (Bonk Section)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Ledge', 'Palace of Darkness - Map Chest'], ['Palace of Darkness Hammer Peg Drop']), + create_dungeon_region(player, 'Palace of Darkness (North)', 'Palace of Darkness', ['Palace of Darkness - Compass Chest', 'Palace of Darkness - Dark Basement - Left', 'Palace of Darkness - Dark Basement - Right'], + ['Palace of Darkness Spike Statue Room Door', 'Palace of Darkness Maze Door']), + create_dungeon_region(player, 'Palace of Darkness (Maze)', 'Palace of Darkness', ['Palace of Darkness - Dark Maze - Top', 'Palace of Darkness - Dark Maze - Bottom', 'Palace of Darkness - Big Chest']), + create_dungeon_region(player, 'Palace of Darkness (Harmless Hellway)', 'Palace of Darkness', ['Palace of Darkness - Harmless Hellway']), + create_dungeon_region(player, 'Palace of Darkness (Final Section)', 'Palace of Darkness', ['Palace of Darkness - Boss', 'Palace of Darkness - Prize']), + create_dungeon_region(player, 'Inverted Ganons Tower (Entrance)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Torch', 'Ganons Tower - Hope Room - Left', 'Ganons Tower - Hope Room - Right'], + ['Ganons Tower (Tile Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower Big Key Door', 'Inverted Ganons Tower Exit']), + create_dungeon_region(player, 'Ganons Tower (Tile Room)', 'Ganon\'s Tower', ['Ganons Tower - Tile Room'], ['Ganons Tower (Tile Room) Key Door']), + create_dungeon_region(player, 'Ganons Tower (Compass Room)', 'Ganon\'s Tower', ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', + 'Ganons Tower - Compass Room - Bottom Left', 'Ganons Tower - Compass Room - Bottom Right'], + ['Ganons Tower (Bottom) (East)']), + create_dungeon_region(player, 'Ganons Tower (Hookshot Room)', 'Ganon\'s Tower', ['Ganons Tower - DMs Room - Top Left', 'Ganons Tower - DMs Room - Top Right', + 'Ganons Tower - DMs Room - Bottom Left', 'Ganons Tower - DMs Room - Bottom Right'], + ['Ganons Tower (Map Room)', 'Ganons Tower (Double Switch Room)']), + create_dungeon_region(player, 'Ganons Tower (Map Room)', 'Ganon\'s Tower', ['Ganons Tower - Map Chest']), + create_dungeon_region(player, 'Ganons Tower (Firesnake Room)', 'Ganon\'s Tower', ['Ganons Tower - Firesnake Room'], ['Ganons Tower (Firesnake Room)']), + create_dungeon_region(player, 'Ganons Tower (Teleport Room)', 'Ganon\'s Tower', ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', + 'Ganons Tower - Randomizer Room - Bottom Left', 'Ganons Tower - Randomizer Room - Bottom Right'], + ['Ganons Tower (Bottom) (West)']), + create_dungeon_region(player, 'Ganons Tower (Bottom)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Chest', 'Ganons Tower - Big Chest', 'Ganons Tower - Big Key Room - Left', + 'Ganons Tower - Big Key Room - Right', 'Ganons Tower - Big Key Chest']), + create_dungeon_region(player, 'Ganons Tower (Top)', 'Ganon\'s Tower', None, ['Ganons Tower Torch Rooms']), + create_dungeon_region(player, 'Ganons Tower (Before Moldorm)', 'Ganon\'s Tower', ['Ganons Tower - Mini Helmasaur Room - Left', 'Ganons Tower - Mini Helmasaur Room - Right', + 'Ganons Tower - Pre-Moldorm Chest'], ['Ganons Tower Moldorm Door']), + create_dungeon_region(player, 'Ganons Tower (Moldorm)', 'Ganon\'s Tower', None, ['Ganons Tower Moldorm Gap']), + create_dungeon_region(player, 'Agahnim 2', 'Ganon\'s Tower', ['Ganons Tower - Validation Chest', 'Agahnim 2'], None), + create_cave_region(player, 'Pyramid', 'a drop\'s exit', ['Ganon'], ['Ganon Drop']), + create_cave_region(player, 'Bottom of Pyramid', 'a drop\'s exit', None, ['Pyramid Exit']), + create_dw_region(player, 'Pyramid Ledge', None, ['Pyramid Drop']), # houlihan room exits here in inverted + + # to simplify flute connections + create_cave_region(player, 'The Sky', 'A Dark Sky', None, ['DDM Landing','NEDW Landing', 'WDW Landing', 'SDW Landing', 'EDW Landing', 'DD Landing', 'DLHL Landing']) + ] + + for region_name, (room_id, shopkeeper, replaceable) in shop_table.items(): + region = world.get_region(region_name, player) + shop = Shop(region, room_id, ShopType.Shop, shopkeeper, replaceable) + region.shop = shop + world.shops.append(shop) + for index, (item, price) in enumerate(default_shop_contents[region_name]): + shop.add_inventory(index, item, price) + + region = world.get_region('Capacity Upgrade', player) + shop = Shop(region, 0x0115, ShopType.UpgradeShop, 0x04, True) + region.shop = shop + world.shops.append(shop) + shop.add_inventory(0, 'Bomb Upgrade (+5)', 100, 7) + shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7) + world.intialize_regions() + +def create_lw_region(player, name, locations=None, exits=None): + return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits) + +def create_dw_region(player, name, locations=None, exits=None): + return _create_region(player, name, RegionType.DarkWorld, 'Dark World', locations, exits) + +def create_cave_region(player, name, hint='Hyrule', locations=None, exits=None): + return _create_region(player, name, RegionType.Cave, hint, locations, exits) + +def create_dungeon_region(player, name, hint='Hyrule', locations=None, exits=None): + return _create_region(player, name, RegionType.Dungeon, hint, locations, exits) + +def _create_region(player, name, type, hint='Hyrule', locations=None, exits=None): + ret = Region(name, type, hint, player) + if locations is None: + locations = [] + if exits is None: + exits = [] + + for exit in exits: + ret.exits.append(Entrance(player, exit, ret)) + for location in locations: + address, crystal, hint_text = location_table[location] + ret.locations.append(Location(player, location, address, crystal, hint_text, ret)) + return ret + +def mark_dark_world_regions(world): + # cross world caves may have some sections marked as both in_light_world, and in_dark_work. + # That is ok. the bunny logic will check for this case and incorporate special rules. + + queue = collections.deque(region for region in world.regions if region.type == RegionType.DarkWorld) + seen = set(queue) + while queue: + current = queue.popleft() + current.is_dark_world = True + for exit in current.exits: + if exit.connected_region.type == RegionType.LightWorld: + # Don't venture into the dark world + continue + if exit.connected_region not in seen: + seen.add(exit.connected_region) + queue.append(exit.connected_region) + + queue = collections.deque(region for region in world.regions if region.type == RegionType.LightWorld) + seen = set(queue) + while queue: + current = queue.popleft() + current.is_light_world = True + for exit in current.exits: + if exit.connected_region.type == RegionType.DarkWorld: + # Don't venture into the light world + continue + if exit.connected_region not in seen: + seen.add(exit.connected_region) + queue.append(exit.connected_region) + +# (room_id, shopkeeper, replaceable) +shop_table = { + 'Cave Shop (Dark Death Mountain)': (0x0112, 0xC1, True), + 'Red Shield Shop': (0x0110, 0xC1, True), + 'Dark Lake Hylia Shop': (0x010F, 0xC1, True), + 'Dark World Lumberjack Shop': (0x010F, 0xC1, True), + 'Village of Outcasts Shop': (0x010F, 0xC1, True), + 'Dark World Potion Shop': (0x010F, 0xC1, True), + 'Light World Death Mountain Shop': (0x00FF, 0xA0, True), + 'Kakariko Shop': (0x011F, 0xA0, True), + 'Cave Shop (Lake Hylia)': (0x0112, 0xA0, True), + 'Potion Shop': (0x0109, 0xFF, False), + # Bomb Shop not currently modeled as a shop, due to special nature of items +} +# region, [item] +# slot, item, price, max=0, replacement=None, replacement_price=0 +# item = (item, price) + +_basic_shop_defaults = [('Red Potion', 150), ('Small Heart', 10), ('Bombs (10)', 50)] +_dark_world_shop_defaults = [('Red Potion', 150), ('Blue Shield', 50), ('Bombs (10)', 50)] +default_shop_contents = { + 'Cave Shop (Dark Death Mountain)': _basic_shop_defaults, + 'Red Shield Shop': [('Red Shield', 500), ('Bee', 10), ('Arrows (10)', 30)], + 'Dark Lake Hylia Shop': _dark_world_shop_defaults, + 'Dark World Lumberjack Shop': _dark_world_shop_defaults, + 'Village of Outcasts Shop': _dark_world_shop_defaults, + 'Dark World Potion Shop': _dark_world_shop_defaults, + 'Light World Death Mountain Shop': _basic_shop_defaults, + 'Kakariko Shop': _basic_shop_defaults, + 'Cave Shop (Lake Hylia)': _basic_shop_defaults, + 'Potion Shop': [('Red Potion', 120), ('Green Potion', 60), ('Blue Potion', 160)], +} + +location_table = {'Mushroom': (0x180013, False, 'in the woods'), + 'Bottle Merchant': (0x2EB18, False, 'with a merchant'), + 'Flute Spot': (0x18014A, False, 'underground'), + 'Sunken Treasure': (0x180145, False, 'underwater'), + 'Purple Chest': (0x33D68, False, 'from a box'), + 'Blind\'s Hideout - Top': (0xEB0F, False, 'in a basement'), + 'Blind\'s Hideout - Left': (0xEB12, False, 'in a basement'), + 'Blind\'s Hideout - Right': (0xEB15, False, 'in a basement'), + 'Blind\'s Hideout - Far Left': (0xEB18, False, 'in a basement'), + 'Blind\'s Hideout - Far Right': (0xEB1B, False, 'in a basement'), + 'Link\'s Uncle': (0x2DF45, False, 'with your uncle'), + 'Secret Passage': (0xE971, False, 'near your uncle'), + 'King Zora': (0xEE1C3, False, 'at a high price'), + 'Zora\'s Ledge': (0x180149, False, 'near Zora'), + 'Waterfall Fairy - Left': (0xE9B0, False, 'near a fairy'), + 'Waterfall Fairy - Right': (0xE9D1, False, 'near a fairy'), + 'King\'s Tomb': (0xE97A, False, 'alone in a cave'), + 'Floodgate Chest': (0xE98C, False, 'in the dam'), + 'Link\'s House': (0xE9BC, False, 'in your home'), + 'Kakariko Tavern': (0xE9CE, False, 'in the bar'), + 'Chicken House': (0xE9E9, False, 'near poultry'), + 'Aginah\'s Cave': (0xE9F2, False, 'with Aginah'), + 'Sahasrahla\'s Hut - Left': (0xEA82, False, 'near the elder'), + 'Sahasrahla\'s Hut - Middle': (0xEA85, False, 'near the elder'), + 'Sahasrahla\'s Hut - Right': (0xEA88, False, 'near the elder'), + 'Sahasrahla': (0x2F1FC, False, 'with the elder'), + 'Kakariko Well - Top': (0xEA8E, False, 'in a well'), + 'Kakariko Well - Left': (0xEA91, False, 'in a well'), + 'Kakariko Well - Middle': (0xEA94, False, 'in a well'), + 'Kakariko Well - Right': (0xEA97, False, 'in a well'), + 'Kakariko Well - Bottom': (0xEA9A, False, 'in a well'), + 'Blacksmith': (0x18002A, False, 'with the smith'), + 'Magic Bat': (0x180015, False, 'with the bat'), + 'Sick Kid': (0x339CF, False, 'with the sick'), + 'Hobo': (0x33E7D, False, 'with the hobo'), + 'Lost Woods Hideout': (0x180000, False, 'near a thief'), + 'Lumberjack Tree': (0x180001, False, 'in a hole'), + 'Cave 45': (0x180003, False, 'alone in a cave'), + 'Graveyard Cave': (0x180004, False, 'alone in a cave'), + 'Checkerboard Cave': (0x180005, False, 'alone in a cave'), + 'Mini Moldorm Cave - Far Left': (0xEB42, False, 'near Moldorms'), + 'Mini Moldorm Cave - Left': (0xEB45, False, 'near Moldorms'), + 'Mini Moldorm Cave - Right': (0xEB48, False, 'near Moldorms'), + 'Mini Moldorm Cave - Far Right': (0xEB4B, False, 'near Moldorms'), + 'Mini Moldorm Cave - Generous Guy': (0x180010, False, 'near Moldorms'), + 'Ice Rod Cave': (0xEB4E, False, 'in a frozen cave'), + 'Bonk Rock Cave': (0xEB3F, False, 'alone in a cave'), + 'Library': (0x180012, False, 'near books'), + 'Potion Shop': (0x180014, False, 'near potions'), + 'Lake Hylia Island': (0x180144, False, 'on an island'), + 'Maze Race': (0x180142, False, 'at the race'), + 'Desert Ledge': (0x180143, False, 'in the desert'), + 'Desert Palace - Big Chest': (0xE98F, False, 'in Desert Palace'), + 'Desert Palace - Torch': (0x180160, False, 'in Desert Palace'), + 'Desert Palace - Map Chest': (0xE9B6, False, 'in Desert Palace'), + 'Desert Palace - Compass Chest': (0xE9CB, False, 'in Desert Palace'), + 'Desert Palace - Big Key Chest': (0xE9C2, False, 'in Desert Palace'), + 'Desert Palace - Boss': (0x180151, False, 'with Lanmolas'), + 'Eastern Palace - Compass Chest': (0xE977, False, 'in Eastern Palace'), + 'Eastern Palace - Big Chest': (0xE97D, False, 'in Eastern Palace'), + 'Eastern Palace - Cannonball Chest': (0xE9B3, False, 'in Eastern Palace'), + 'Eastern Palace - Big Key Chest': (0xE9B9, False, 'in Eastern Palace'), + 'Eastern Palace - Map Chest': (0xE9F5, False, 'in Eastern Palace'), + 'Eastern Palace - Boss': (0x180150, False, 'with the Armos'), + 'Master Sword Pedestal': (0x289B0, False, 'at the pedestal'), + 'Hyrule Castle - Boomerang Chest': (0xE974, False, 'in Hyrule Castle'), + 'Hyrule Castle - Map Chest': (0xEB0C, False, 'in Hyrule Castle'), + 'Hyrule Castle - Zelda\'s Chest': (0xEB09, False, 'in Hyrule Castle'), + 'Sewers - Dark Cross': (0xE96E, False, 'in the sewers'), + 'Sewers - Secret Room - Left': (0xEB5D, False, 'in the sewers'), + 'Sewers - Secret Room - Middle': (0xEB60, False, 'in the sewers'), + 'Sewers - Secret Room - Right': (0xEB63, False, 'in the sewers'), + 'Sanctuary': (0xEA79, False, 'in Sanctuary'), + 'Castle Tower - Room 03': (0xEAB5, False, 'in Castle Tower'), + 'Castle Tower - Dark Maze': (0xEAB2, False, 'in Castle Tower'), + 'Old Man': (0xF69FA, False, 'with the old man'), + 'Spectacle Rock Cave': (0x180002, False, 'alone in a cave'), + 'Paradox Cave Lower - Far Left': (0xEB2A, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Left': (0xEB2D, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Right': (0xEB30, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Far Right': (0xEB33, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Middle': (0xEB36, False, 'in a cave with seven chests'), + 'Paradox Cave Upper - Left': (0xEB39, False, 'in a cave with seven chests'), + 'Paradox Cave Upper - Right': (0xEB3C, False, 'in a cave with seven chests'), + 'Spiral Cave': (0xE9BF, False, 'in spiral cave'), + 'Ether Tablet': (0x180016, False, 'at a monolith'), + 'Spectacle Rock': (0x180140, False, 'atop a rock'), + 'Tower of Hera - Basement Cage': (0x180162, False, 'in Tower of Hera'), + 'Tower of Hera - Map Chest': (0xE9AD, False, 'in Tower of Hera'), + 'Tower of Hera - Big Key Chest': (0xE9E6, False, 'in Tower of Hera'), + 'Tower of Hera - Compass Chest': (0xE9FB, False, 'in Tower of Hera'), + 'Tower of Hera - Big Chest': (0xE9F8, False, 'in Tower of Hera'), + 'Tower of Hera - Boss': (0x180152, False, 'with Moldorm'), + 'Pyramid': (0x180147, False, 'on the pyramid'), + 'Catfish': (0xEE185, False, 'with a catfish'), + 'Stumpy': (0x330C7, False, 'with tree boy'), + 'Digging Game': (0x180148, False, 'underground'), + 'Bombos Tablet': (0x180017, False, 'at a monolith'), + 'Hype Cave - Top': (0xEB1E, False, 'near a bat-like man'), + 'Hype Cave - Middle Right': (0xEB21, False, 'near a bat-like man'), + 'Hype Cave - Middle Left': (0xEB24, False, 'near a bat-like man'), + 'Hype Cave - Bottom': (0xEB27, False, 'near a bat-like man'), + 'Hype Cave - Generous Guy': (0x180011, False, 'with a bat-like man'), + 'Peg Cave': (0x180006, False, 'alone in a cave'), + 'Pyramid Fairy - Left': (0xE980, False, 'near a fairy'), + 'Pyramid Fairy - Right': (0xE983, False, 'near a fairy'), + 'Brewery': (0xE9EC, False, 'alone in a home'), + 'C-Shaped House': (0xE9EF, False, 'alone in a home'), + 'Chest Game': (0xEDA8, False, 'as a prize'), + 'Bumper Cave Ledge': (0x180146, False, 'on a ledge'), + 'Mire Shed - Left': (0xEA73, False, 'near sparks'), + 'Mire Shed - Right': (0xEA76, False, 'near sparks'), + 'Superbunny Cave - Top': (0xEA7C, False, 'in a connection'), + 'Superbunny Cave - Bottom': (0xEA7F, False, 'in a connection'), + 'Spike Cave': (0xEA8B, False, 'beyond spikes'), + 'Hookshot Cave - Top Right': (0xEB51, False, 'across pits'), + 'Hookshot Cave - Top Left': (0xEB54, False, 'across pits'), + 'Hookshot Cave - Bottom Right': (0xEB5A, False, 'across pits'), + 'Hookshot Cave - Bottom Left': (0xEB57, False, 'across pits'), + 'Floating Island': (0x180141, False, 'on an island'), + 'Mimic Cave': (0xE9C5, False, 'in a cave of mimicry'), + 'Swamp Palace - Entrance': (0xEA9D, False, 'in Swamp Palace'), + 'Swamp Palace - Map Chest': (0xE986, False, 'in Swamp Palace'), + 'Swamp Palace - Big Chest': (0xE989, False, 'in Swamp Palace'), + 'Swamp Palace - Compass Chest': (0xEAA0, False, 'in Swamp Palace'), + 'Swamp Palace - Big Key Chest': (0xEAA6, False, 'in Swamp Palace'), + 'Swamp Palace - West Chest': (0xEAA3, False, 'in Swamp Palace'), + 'Swamp Palace - Flooded Room - Left': (0xEAA9, False, 'in Swamp Palace'), + 'Swamp Palace - Flooded Room - Right': (0xEAAC, False, 'in Swamp Palace'), + 'Swamp Palace - Waterfall Room': (0xEAAF, False, 'in Swamp Palace'), + 'Swamp Palace - Boss': (0x180154, False, 'with Arrghus'), + 'Thieves\' Town - Big Key Chest': (0xEA04, False, 'in Thieves\' Town'), + 'Thieves\' Town - Map Chest': (0xEA01, False, 'in Thieves\' Town'), + 'Thieves\' Town - Compass Chest': (0xEA07, False, 'in Thieves\' Town'), + 'Thieves\' Town - Ambush Chest': (0xEA0A, False, 'in Thieves\' Town'), + 'Thieves\' Town - Attic': (0xEA0D, False, 'in Thieves\' Town'), + 'Thieves\' Town - Big Chest': (0xEA10, False, 'in Thieves\' Town'), + 'Thieves\' Town - Blind\'s Cell': (0xEA13, False, 'in Thieves\' Town'), + 'Thieves\' Town - Boss': (0x180156, False, 'with Blind'), + 'Skull Woods - Compass Chest': (0xE992, False, 'in Skull Woods'), + 'Skull Woods - Map Chest': (0xE99B, False, 'in Skull Woods'), + 'Skull Woods - Big Chest': (0xE998, False, 'in Skull Woods'), + 'Skull Woods - Pot Prison': (0xE9A1, False, 'in Skull Woods'), + 'Skull Woods - Pinball Room': (0xE9C8, False, 'in Skull Woods'), + 'Skull Woods - Big Key Chest': (0xE99E, False, 'in Skull Woods'), + 'Skull Woods - Bridge Room': (0xE9FE, False, 'near Mothula'), + 'Skull Woods - Boss': (0x180155, False, 'with Mothula'), + 'Ice Palace - Compass Chest': (0xE9D4, False, 'in Ice Palace'), + 'Ice Palace - Freezor Chest': (0xE995, False, 'in Ice Palace'), + 'Ice Palace - Big Chest': (0xE9AA, False, 'in Ice Palace'), + 'Ice Palace - Iced T Room': (0xE9E3, False, 'in Ice Palace'), + 'Ice Palace - Spike Room': (0xE9E0, False, 'in Ice Palace'), + 'Ice Palace - Big Key Chest': (0xE9A4, False, 'in Ice Palace'), + 'Ice Palace - Map Chest': (0xE9DD, False, 'in Ice Palace'), + 'Ice Palace - Boss': (0x180157, False, 'with Kholdstare'), + 'Misery Mire - Big Chest': (0xEA67, False, 'in Misery Mire'), + 'Misery Mire - Map Chest': (0xEA6A, False, 'in Misery Mire'), + 'Misery Mire - Main Lobby': (0xEA5E, False, 'in Misery Mire'), + 'Misery Mire - Bridge Chest': (0xEA61, False, 'in Misery Mire'), + 'Misery Mire - Spike Chest': (0xE9DA, False, 'in Misery Mire'), + 'Misery Mire - Compass Chest': (0xEA64, False, 'in Misery Mire'), + 'Misery Mire - Big Key Chest': (0xEA6D, False, 'in Misery Mire'), + 'Misery Mire - Boss': (0x180158, False, 'with Vitreous'), + 'Turtle Rock - Compass Chest': (0xEA22, False, 'in Turtle Rock'), + 'Turtle Rock - Roller Room - Left': (0xEA1C, False, 'in Turtle Rock'), + 'Turtle Rock - Roller Room - Right': (0xEA1F, False, 'in Turtle Rock'), + 'Turtle Rock - Chain Chomps': (0xEA16, False, 'in Turtle Rock'), + 'Turtle Rock - Big Key Chest': (0xEA25, False, 'in Turtle Rock'), + 'Turtle Rock - Big Chest': (0xEA19, False, 'in Turtle Rock'), + 'Turtle Rock - Crystaroller Room': (0xEA34, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Bottom Left': (0xEA31, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Bottom Right': (0xEA2E, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Top Left': (0xEA2B, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Top Right': (0xEA28, False, 'in Turtle Rock'), + 'Turtle Rock - Boss': (0x180159, False, 'with Trinexx'), + 'Palace of Darkness - Shooter Room': (0xEA5B, False, 'in Palace of Darkness'), + 'Palace of Darkness - The Arena - Bridge': (0xEA3D, False, 'in Palace of Darkness'), + 'Palace of Darkness - Stalfos Basement': (0xEA49, False, 'in Palace of Darkness'), + 'Palace of Darkness - Big Key Chest': (0xEA37, False, 'in Palace of Darkness'), + 'Palace of Darkness - The Arena - Ledge': (0xEA3A, False, 'in Palace of Darkness'), + 'Palace of Darkness - Map Chest': (0xEA52, False, 'in Palace of Darkness'), + 'Palace of Darkness - Compass Chest': (0xEA43, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Basement - Left': (0xEA4C, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Basement - Right': (0xEA4F, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Maze - Top': (0xEA55, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Maze - Bottom': (0xEA58, False, 'in Palace of Darkness'), + 'Palace of Darkness - Big Chest': (0xEA40, False, 'in Palace of Darkness'), + 'Palace of Darkness - Harmless Hellway': (0xEA46, False, 'in Palace of Darkness'), + 'Palace of Darkness - Boss': (0x180153, False, 'with Helmasaur King'), + 'Ganons Tower - Bob\'s Torch': (0x180161, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Hope Room - Left': (0xEAD9, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Hope Room - Right': (0xEADC, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Tile Room': (0xEAE2, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Compass Room - Top Left': (0xEAE5, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Compass Room - Top Right': (0xEAE8, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Compass Room - Bottom Left': (0xEAEB, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Compass Room - Bottom Right': (0xEAEE, False, 'in Ganon\'s Tower'), + 'Ganons Tower - DMs Room - Top Left': (0xEAB8, False, 'in Ganon\'s Tower'), + 'Ganons Tower - DMs Room - Top Right': (0xEABB, False, 'in Ganon\'s Tower'), + 'Ganons Tower - DMs Room - Bottom Left': (0xEABE, False, 'in Ganon\'s Tower'), + 'Ganons Tower - DMs Room - Bottom Right': (0xEAC1, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Map Chest': (0xEAD3, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Firesnake Room': (0xEAD0, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Randomizer Room - Top Left': (0xEAC4, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Randomizer Room - Top Right': (0xEAC7, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Randomizer Room - Bottom Left': (0xEACA, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Randomizer Room - Bottom Right': (0xEACD, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Bob\'s Chest': (0xEADF, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Big Chest': (0xEAD6, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Big Key Room - Left': (0xEAF4, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Big Key Room - Right': (0xEAF7, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Big Key Chest': (0xEAF1, False, 'in Ganon\'s Tower'), + 'Ganons Tower - Mini Helmasaur Room - Left': (0xEAFD, False, 'atop Ganon\'s Tower'), + 'Ganons Tower - Mini Helmasaur Room - Right': (0xEB00, False, 'atop Ganon\'s Tower'), + 'Ganons Tower - Pre-Moldorm Chest': (0xEB03, False, 'atop Ganon\'s Tower'), + 'Ganons Tower - Validation Chest': (0xEB06, False, 'atop Ganon\'s Tower'), + 'Ganon': (None, False, 'from me'), + 'Agahnim 1': (None, False, 'from Ganon\'s wizardry form'), + 'Agahnim 2': (None, False, 'from Ganon\'s wizardry form'), + 'Floodgate': (None, False, None), + 'Frog': (None, False, None), + 'Missing Smith': (None, False, None), + 'Dark Blacksmith Ruins': (None, False, None), + 'Eastern Palace - Prize': ([0x1209D, 0x53EF8, 0x53EF9, 0x180052, 0x18007C, 0xC6FE], True, 'Eastern Palace'), + 'Desert Palace - Prize': ([0x1209E, 0x53F1C, 0x53F1D, 0x180053, 0x180078, 0xC6FF], True, 'Desert Palace'), + 'Tower of Hera - Prize': ([0x120A5, 0x53F0A, 0x53F0B, 0x18005A, 0x18007A, 0xC706], True, 'Tower of Hera'), + 'Palace of Darkness - Prize': ([0x120A1, 0x53F00, 0x53F01, 0x180056, 0x18007D, 0xC702], True, 'Palace of Darkness'), + 'Swamp Palace - Prize': ([0x120A0, 0x53F6C, 0x53F6D, 0x180055, 0x180071, 0xC701], True, 'Swamp Palace'), + 'Thieves\' Town - Prize': ([0x120A6, 0x53F36, 0x53F37, 0x18005B, 0x180077, 0xC707], True, 'Thieves\' Town'), + 'Skull Woods - Prize': ([0x120A3, 0x53F12, 0x53F13, 0x180058, 0x18007B, 0xC704], True, 'Skull Woods'), + 'Ice Palace - Prize': ([0x120A4, 0x53F5A, 0x53F5B, 0x180059, 0x180073, 0xC705], True, 'Ice Palace'), + 'Misery Mire - Prize': ([0x120A2, 0x53F48, 0x53F49, 0x180057, 0x180075, 0xC703], True, 'Misery Mire'), + 'Turtle Rock - Prize': ([0x120A7, 0x53F24, 0x53F25, 0x18005C, 0x180079, 0xC708], True, 'Turtle Rock')} diff --git a/ItemList.py b/ItemList.py index 8c7f3d7177..27eb4568ff 100644 --- a/ItemList.py +++ b/ItemList.py @@ -13,7 +13,7 @@ from Items import ItemFactory #This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space. #Some basic items that various modes require are placed here, including pendants and crystals. Medallion requirements for the two relevant entrances are also decided. -alwaysitems = ['Bombos', 'Book of Mudora', 'Bow', 'Cane of Somaria', 'Ether', 'Fire Rod', 'Flippers', 'Ocarina', 'Hammer', 'Hookshot', 'Ice Rod', 'Lamp', +alwaysitems = ['Bombos', 'Book of Mudora', 'Cane of Somaria', 'Ether', 'Fire Rod', 'Flippers', 'Ocarina', 'Hammer', 'Hookshot', 'Ice Rod', 'Lamp', 'Cape', 'Magic Powder', 'Mushroom', 'Pegasus Boots', 'Quake', 'Shovel', 'Bug Catching Net', 'Cane of Byrna', 'Blue Boomerang', 'Red Boomerang'] progressivegloves = ['Progressive Glove'] * 2 basicgloves = ['Power Glove', 'Titans Mitts'] @@ -21,69 +21,25 @@ basicgloves = ['Power Glove', 'Titans Mitts'] normalbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bottle (Blue Potion)', 'Bottle (Fairy)', 'Bottle (Bee)', 'Bottle (Good Bee)'] hardbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bottle (Blue Potion)', 'Bottle (Bee)', 'Bottle (Good Bee)'] -normalbaseitems = (['Silver Arrows', 'Magic Upgrade (1/2)', 'Single Arrow', 'Sanctuary Heart Container', 'Arrows (10)', 'Bombs (3)'] + +normalbaseitems = (['Magic Upgrade (1/2)', 'Single Arrow', 'Sanctuary Heart Container', 'Arrows (10)', 'Bombs (10)'] + ['Rupees (300)'] * 4 + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 24) normalfirst15extra = ['Rupees (100)', 'Rupees (300)', 'Rupees (50)'] + ['Arrows (10)'] * 6 + ['Bombs (3)'] * 6 -normalsecond15extra = ['Bombs (3)'] * 9 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupee (1)'] + ['Bombs (10)'] +normalsecond15extra = ['Bombs (3)'] * 10 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupee (1)'] normalthird10extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 3 + ['Arrows (10)', 'Rupee (1)', 'Rupees (5)'] normalfourth5extra = ['Arrows (10)'] * 2 + ['Rupees (20)'] * 2 + ['Rupees (5)'] normalfinal25extra = ['Rupees (20)'] * 23 + ['Rupees (5)'] * 2 - -easybaseitems = (['Sanctuary Heart Container'] + ['Rupees (300)'] * 4 + ['Magic Upgrade (1/2)'] * 2 + ['Lamp'] * 2 + ['Silver Arrows'] * 2 + - ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 12) -easyextra = ['Piece of Heart'] * 12 + ['Rupees (300)'] -easylimitedextra = ['Boss Heart Container'] * 3 # collapsing down the 12 pieces of heart -easyfirst15extra = ['Rupees (100)'] + ['Arrows (10)'] * 7 + ['Bombs (3)'] * 7 -easysecond10extra = ['Bombs (3)'] * 7 + ['Rupee (1)', 'Rupees (50)', 'Bombs (10)'] -easythird5extra = ['Rupees (50)'] * 2 + ['Bombs (3)'] * 2 + ['Arrows (10)'] -easyfinal25extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 14 + ['Rupee (1)'] + ['Arrows (10)'] * 4 + ['Rupees (5)'] * 2 -easytimedotherextra = ['Red Clock'] * 5 - -hardbaseitems = ['Silver Arrows', 'Single Arrow', 'Bombs (10)'] + ['Rupees (300)'] * 4 + ['Boss Heart Container'] * 6 + ['Piece of Heart'] * 20 + ['Rupees (5)'] * 7 + ['Bombs (3)'] * 4 -hardfirst20extra = ['Rupees (100)', 'Rupees (300)', 'Rupees (50)'] + ['Bombs (3)'] * 5 + ['Rupees (5)'] * 10 + ['Arrows (10)', 'Rupee (1)'] -hardsecond10extra = ['Rupees (5)'] * 5 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupee (1)'] -hardthird10extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 3 + ['Rupees (5)'] * 3 -hardfourth10extra = ['Arrows (10)'] * 2 + ['Rupees (20)'] * 7 + ['Rupees (5)'] -hardfinal20extra = ['Rupees (20)'] * 18 + ['Rupees (5)'] * 2 - -expertbaseitems = (['Rupees (300)'] * 4 + ['Single Arrow', 'Silver Arrows', 'Boss Heart Container', 'Rupee (1)', 'Bombs (10)'] + ['Piece of Heart'] * 20 + ['Rupees (5)'] * 2 + - ['Bombs (3)'] * 9 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupees (20)'] * 2) -expertfirst15extra = ['Rupees (100)', 'Rupees (300)', 'Rupees (50)'] + ['Rupees (5)'] * 12 -expertsecond15extra = ['Rupees (5)'] * 10 + ['Rupees (20)'] * 5 -expertthird10extra = ['Rupees (50)'] * 4 + ['Rupees (5)'] * 2 + ['Arrows (10)'] * 3 + ['Rupee (1)'] -expertfourth5extra = ['Rupees (5)'] * 5 -expertfinal25extra = ['Rupees (20)'] * 23 + ['Rupees (5)'] * 2 - -insanebaseitems = ['Rupees (300)'] * 4 + ['Single Arrow', 'Bombs (10)', 'Rupee (1)'] + ['Rupees (5)'] * 24 + ['Bombs (3)'] * 9 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupees (20)'] * 5 -insanefirst15extra = ['Rupees (100)', 'Rupees (300)', 'Rupees (50)'] + ['Rupees (5)'] * 12 -insanesecond15extra = ['Rupees (5)'] * 10 + ['Rupees (20)'] * 5 -insanethird10extra = ['Rupees (50)'] * 4 + ['Rupees (5)'] * 2 + ['Arrows (10)'] * 3 + ['Rupee (1)'] -insanefourth5extra = ['Rupees (5)'] * 5 -insanefinal25extra = ['Rupees (20)'] * 23 + ['Rupees (5)'] * 2 - Difficulty = namedtuple('Difficulty', ['baseitems', 'bottles', 'bottle_count', 'same_bottle', 'progressiveshield', 'basicshield', 'progressivearmor', 'basicarmor', 'swordless', - 'progressivesword', 'basicsword', 'timedohko', 'timedother', - 'triforcehunt', 'triforce_pieces_required', 'retro', 'conditional_extras', + 'progressivesword', 'basicsword', 'basicbow', 'timedohko', 'timedother', + 'triforcehunt', 'triforce_pieces_required', 'retro', 'extras', 'progressive_sword_limit', 'progressive_shield_limit', - 'progressive_armor_limit', 'progressive_bottle_limit']) + 'progressive_armor_limit', 'progressive_bottle_limit', + 'progressive_bow_limit', 'heart_piece_limit', 'boss_heart_container_limit']) total_items_to_place = 153 -def easy_conditional_extras(timer, _goal, _mode, pool, placed_items): - extraitems = total_items_to_place - len(pool) - len(placed_items) - if extraitems < len(easyextra): - return easylimitedextra - if timer in ['timed', 'timed-countdown']: - return easytimedotherextra - return [] - -def no_conditional_extras(*_args): - return [] - - difficulties = { 'normal': Difficulty( baseitems = normalbaseitems, @@ -97,149 +53,141 @@ difficulties = { swordless = ['Rupees (20)'] * 4, progressivesword = ['Progressive Sword'] * 3, basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'], + basicbow = ['Bow', 'Silver Arrows'], timedohko = ['Green Clock'] * 25, timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10, triforcehunt = ['Triforce Piece'] * 30, triforce_pieces_required = 20, retro = ['Small Key (Universal)'] * 17 + ['Rupees (20)'] * 10, - conditional_extras = no_conditional_extras, extras = [normalfirst15extra, normalsecond15extra, normalthird10extra, normalfourth5extra, normalfinal25extra], progressive_sword_limit = 4, progressive_shield_limit = 3, progressive_armor_limit = 2, + progressive_bow_limit = 2, progressive_bottle_limit = 4, - ), - 'easy': Difficulty( - baseitems = easybaseitems, - bottles = normalbottles, - bottle_count = 8, - same_bottle = False, - progressiveshield = ['Progressive Shield'] * 6, - basicshield = ['Blue Shield', 'Red Shield', 'Mirror Shield'] * 2, - progressivearmor = ['Progressive Armor'] * 4, - basicarmor = ['Blue Mail', 'Red Mail'] * 2, - swordless = ['Rupees (20)'] * 8, - progressivesword = ['Progressive Sword'] * 7, - basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'] *2 + ['Fighter Sword'], - timedohko = ['Green Clock'] * 25, - timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 5, # +5 more Red Clocks if there is room - triforcehunt = ['Triforce Piece'] * 30, - triforce_pieces_required = 20, - retro = ['Small Key (Universal)'] * 27, - conditional_extras = easy_conditional_extras, - extras = [easyextra, easyfirst15extra, easysecond10extra, easythird5extra, easyfinal25extra], - progressive_sword_limit = 4, - progressive_shield_limit = 3, - progressive_armor_limit = 2, - progressive_bottle_limit = 4, + boss_heart_container_limit = 255, + heart_piece_limit = 255, ), 'hard': Difficulty( - baseitems = hardbaseitems, + baseitems = normalbaseitems, bottles = hardbottles, bottle_count = 4, same_bottle = False, progressiveshield = ['Progressive Shield'] * 3, basicshield = ['Blue Shield', 'Red Shield', 'Red Shield'], progressivearmor = ['Progressive Armor'] * 2, - basicarmor = ['Progressive Armor'] * 2, #only the first one will upgrade, making this equivalent to two blue mail + basicarmor = ['Progressive Armor'] * 2, # neither will count swordless = ['Rupees (20)'] * 4, progressivesword = ['Progressive Sword'] * 3, basicsword = ['Master Sword', 'Master Sword', 'Tempered Sword'], - timedohko = ['Green Clock'] * 20, + basicbow = ['Bow'] * 2, + timedohko = ['Green Clock'] * 25, timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10, triforcehunt = ['Triforce Piece'] * 30, triforce_pieces_required = 20, retro = ['Small Key (Universal)'] * 12 + ['Rupees (5)'] * 15, - conditional_extras = no_conditional_extras, - extras = [hardfirst20extra, hardsecond10extra, hardthird10extra, hardfourth10extra, hardfinal20extra], + extras = [normalfirst15extra, normalsecond15extra, normalthird10extra, normalfourth5extra, normalfinal25extra], progressive_sword_limit = 3, progressive_shield_limit = 2, - progressive_armor_limit = 1, + progressive_armor_limit = 0, + progressive_bow_limit = 1, progressive_bottle_limit = 4, + boss_heart_container_limit = 6, + heart_piece_limit = 16, ), 'expert': Difficulty( - baseitems = expertbaseitems, + baseitems = normalbaseitems, bottles = hardbottles, bottle_count = 4, same_bottle = False, progressiveshield = ['Progressive Shield'] * 3, basicshield = ['Progressive Shield'] * 3, #only the first one will upgrade, making this equivalent to two blue shields - progressivearmor = [], - basicarmor = [], + progressivearmor = ['Progressive Armor'] * 2, # neither will count + basicarmor = ['Progressive Armor'] * 2, # neither will count swordless = ['Rupees (20)'] * 4, progressivesword = ['Progressive Sword'] * 3, basicsword = ['Fighter Sword', 'Master Sword', 'Master Sword'], + basicbow = ['Bow'] * 2, timedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5, timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10, triforcehunt = ['Triforce Piece'] * 30, triforce_pieces_required = 20, retro = ['Small Key (Universal)'] * 12 + ['Rupees (5)'] * 15, - conditional_extras = no_conditional_extras, - extras = [expertfirst15extra, expertsecond15extra, expertthird10extra, expertfourth5extra, expertfinal25extra], + extras = [normalfirst15extra, normalsecond15extra, normalthird10extra, normalfourth5extra, normalfinal25extra], progressive_sword_limit = 2, progressive_shield_limit = 1, progressive_armor_limit = 0, + progressive_bow_limit = 1, progressive_bottle_limit = 4, - ), - 'insane': Difficulty( - baseitems = insanebaseitems, - bottles = hardbottles, - bottle_count = 4, - same_bottle = False, - progressiveshield = [], - basicshield = [], - progressivearmor = [], - basicarmor = [], - swordless = ['Rupees (20)'] * 3 + ['Silver Arrows'], - progressivesword = ['Progressive Sword'] * 3, - basicsword = ['Fighter Sword', 'Master Sword', 'Master Sword'], - timedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5, - timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10, - triforcehunt = ['Triforce Piece'] * 30, - triforce_pieces_required = 20, - retro = ['Small Key (Universal)'] * 12 + ['Rupees (5)'] * 15, - conditional_extras = no_conditional_extras, - extras = [insanefirst15extra, insanesecond15extra, insanethird10extra, insanefourth5extra, insanefinal25extra], - progressive_sword_limit = 2, - progressive_shield_limit = 0, - progressive_armor_limit = 0, - progressive_bottle_limit = 4, + boss_heart_container_limit = 2, + heart_piece_limit = 8, ), } -def generate_itempool(world): - if (world.difficulty not in ['easy', 'normal', 'hard', 'expert', 'insane'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'] - or world.mode not in ['open', 'standard', 'swordless'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']): +def generate_itempool(world, player): + if (world.difficulty not in ['normal', 'hard', 'expert'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'] + or world.mode not in ['open', 'standard', 'swordless', 'inverted'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']): raise NotImplementedError('Not supported yet') if world.timer in ['ohko', 'timed-ohko']: world.can_take_damage = False - world.push_item('Ganon', ItemFactory('Triforce'), False) - world.get_location('Ganon').event = True - world.push_item('Agahnim 1', ItemFactory('Beat Agahnim 1'), False) - world.get_location('Agahnim 1').event = True - world.push_item('Agahnim 2', ItemFactory('Beat Agahnim 2'), False) - world.get_location('Agahnim 2').event = True - world.push_item('Dark Blacksmith Ruins', ItemFactory('Pick Up Purple Chest'), False) - world.get_location('Dark Blacksmith Ruins').event = True - world.push_item('Frog', ItemFactory('Get Frog'), False) - world.get_location('Frog').event = True - world.push_item('Missing Smith', ItemFactory('Return Smith'), False) - world.get_location('Missing Smith').event = True - world.push_item('Floodgate', ItemFactory('Open Floodgate'), False) - world.get_location('Floodgate').event = True + if world.goal in ['pedestal', 'triforcehunt']: + world.push_item(world.get_location('Ganon', player), ItemFactory('Nothing', player), False) + else: + world.push_item(world.get_location('Ganon', player), ItemFactory('Triforce', player), False) + + if world.goal in ['triforcehunt']: + if world.mode == 'inverted': + region = world.get_region('Light World',player) + else: + region = world.get_region('Hyrule Castle Courtyard', player) + + loc = Location(player, "Murahdahla", parent=region) + loc.access_rule = lambda state: state.item_count('Triforce Piece', player) + state.item_count('Power Star', player) > state.world.treasure_hunt_count + region.locations.append(loc) + world.dynamic_locations.append(loc) + + world.clear_location_cache() + + world.push_item(loc, ItemFactory('Triforce', player), False) + loc.event = True + loc.locked = True + + world.get_location('Ganon', player).event = True + world.get_location('Ganon', player).locked = True + world.push_item(world.get_location('Agahnim 1', player), ItemFactory('Beat Agahnim 1', player), False) + world.get_location('Agahnim 1', player).event = True + world.get_location('Agahnim 1', player).locked = True + world.push_item(world.get_location('Agahnim 2', player), ItemFactory('Beat Agahnim 2', player), False) + world.get_location('Agahnim 2', player).event = True + world.get_location('Agahnim 2', player).locked = True + world.push_item(world.get_location('Dark Blacksmith Ruins', player), ItemFactory('Pick Up Purple Chest', player), False) + world.get_location('Dark Blacksmith Ruins', player).event = True + world.get_location('Dark Blacksmith Ruins', player).locked = True + world.push_item(world.get_location('Frog', player), ItemFactory('Get Frog', player), False) + world.get_location('Frog', player).event = True + world.get_location('Frog', player).locked = True + world.push_item(world.get_location('Missing Smith', player), ItemFactory('Return Smith', player), False) + world.get_location('Missing Smith', player).event = True + world.get_location('Missing Smith', player).locked = True + world.push_item(world.get_location('Floodgate', player), ItemFactory('Open Floodgate', player), False) + world.get_location('Floodgate', player).event = True + world.get_location('Floodgate', player).locked = True # set up item pool if world.custom: - (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = make_custom_item_pool(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode, world.retro, world.customitemarray) + (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = make_custom_item_pool(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode, world.swords, world.retro, world.customitemarray) world.rupoor_cost = min(world.customitemarray[67], 9999) else: - (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = get_pool_core(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode, world.retro) - world.itempool = ItemFactory(pool) + (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) = get_pool_core(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode, world.swords, world.retro) + world.itempool += ItemFactory(pool, player) + for item in precollected_items: + world.push_precollected(ItemFactory(item, player)) for (location, item) in placed_items: - world.push_item(location, ItemFactory(item), False) - world.get_location(location).event = True + world.push_item(world.get_location(location, player), ItemFactory(item, player), False) + world.get_location(location, player).event = True + world.get_location(location, player).locked = True world.lamps_needed_for_dark_rooms = lamps_needed_for_dark_rooms if clock_mode is not None: world.clock_mode = clock_mode @@ -249,30 +197,30 @@ def generate_itempool(world): world.treasure_hunt_icon = treasure_hunt_icon if world.keysanity: - world.itempool.extend(get_dungeon_item_pool(world)) + world.itempool.extend([item for item in get_dungeon_item_pool(world) if item.player == player]) # logic has some branches where having 4 hearts is one possible requirement (of several alternatives) # rather than making all hearts/heart pieces progression items (which slows down generation considerably) # We mark one random heart container as an advancement item (or 4 heart pieces in expert mode) - if world.difficulty in ['easy', 'normal', 'hard'] and not (world.custom and world.customitemarray[30] == 0): - [item for item in world.itempool if item.name == 'Boss Heart Container'][0].advancement = True + if world.difficulty in ['normal', 'hard'] and not (world.custom and world.customitemarray[30] == 0): + [item for item in world.itempool if item.name == 'Boss Heart Container' and item.player == player][0].advancement = True elif world.difficulty in ['expert'] and not (world.custom and world.customitemarray[29] < 4): - adv_heart_pieces = [item for item in world.itempool if item.name == 'Piece of Heart'][0:4] + adv_heart_pieces = [item for item in world.itempool if item.name == 'Piece of Heart' and item.player == player][0:4] for hp in adv_heart_pieces: hp.advancement = True # shuffle medallions mm_medallion = ['Ether', 'Quake', 'Bombos'][random.randint(0, 2)] tr_medallion = ['Ether', 'Quake', 'Bombos'][random.randint(0, 2)] - world.required_medallions = (mm_medallion, tr_medallion) + world.required_medallions[player] = (mm_medallion, tr_medallion) - place_bosses(world) - set_up_shops(world) + place_bosses(world, player) + set_up_shops(world, player) if world.retro: - set_up_take_anys(world) + set_up_take_anys(world, player) - create_dynamic_shop_locations(world) + create_dynamic_shop_locations(world, player) take_any_locations = [ 'Snitch Lady (East)', 'Snitch Lady (West)', 'Bush Covered House', 'Light World Bomb Hut', @@ -284,39 +232,42 @@ take_any_locations = [ 'Palace of Darkness Hint', 'East Dark World Hint', 'Archery Game', 'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Spike Cave', 'Fortune Teller (Dark)', 'Dark Sanctuary Hint', 'Dark Desert Hint'] -def set_up_take_anys(world): +def set_up_take_anys(world, player): + if world.mode == 'inverted' and 'Dark Sanctuary Hint' in take_any_locations: + take_any_locations.remove('Dark Sanctuary Hint') + regions = random.sample(take_any_locations, 5) - old_man_take_any = Region("Old Man Sword Cave", RegionType.Cave, 'the sword cave') + old_man_take_any = Region("Old Man Sword Cave", RegionType.Cave, 'the sword cave', player) world.regions.append(old_man_take_any) world.dynamic_regions.append(old_man_take_any) reg = regions.pop() - entrance = world.get_region(reg).entrances[0] - connect_entrance(world, entrance, old_man_take_any) + entrance = world.get_region(reg, player).entrances[0] + connect_entrance(world, entrance, old_man_take_any, player) entrance.target = 0x58 old_man_take_any.shop = Shop(old_man_take_any, 0x0112, ShopType.TakeAny, 0xE2, True) world.shops.append(old_man_take_any.shop) old_man_take_any.shop.active = True - swords = [item for item in world.itempool if item.type == 'Sword'] + swords = [item for item in world.itempool if item.type == 'Sword' and item.player == player] if swords: sword = random.choice(swords) world.itempool.remove(sword) - world.itempool.append(ItemFactory('Rupees (20)')) + world.itempool.append(ItemFactory('Rupees (20)', player)) old_man_take_any.shop.add_inventory(0, sword.name, 0, 0, create_location=True) else: old_man_take_any.shop.add_inventory(0, 'Rupees (300)', 0, 0) for num in range(4): - take_any = Region("Take-Any #{}".format(num+1), RegionType.Cave, 'a cave of choice') + take_any = Region("Take-Any #{}".format(num+1), RegionType.Cave, 'a cave of choice', player) world.regions.append(take_any) world.dynamic_regions.append(take_any) target, room_id = random.choice([(0x58, 0x0112), (0x60, 0x010F), (0x46, 0x011F)]) reg = regions.pop() - entrance = world.get_region(reg).entrances[0] - connect_entrance(world, entrance, take_any) + entrance = world.get_region(reg, player).entrances[0] + connect_entrance(world, entrance, take_any, player) entrance.target = target take_any.shop = Shop(take_any, room_id, ShopType.TakeAny, 0xE3, True) world.shops.append(take_any.shop) @@ -326,50 +277,53 @@ def set_up_take_anys(world): world.intialize_regions() -def create_dynamic_shop_locations(world): +def create_dynamic_shop_locations(world, player): for shop in world.shops: - for i, item in enumerate(shop.inventory): - if item is None: - continue - if item['create_location']: - loc = Location("{} Item {}".format(shop.region.name, i+1), parent=shop.region) - shop.region.locations.append(loc) - world.dynamic_locations.append(loc) + if shop.region.player == player: + for i, item in enumerate(shop.inventory): + if item is None: + continue + if item['create_location']: + loc = Location(player, "{} Item {}".format(shop.region.name, i+1), parent=shop.region) + shop.region.locations.append(loc) + world.dynamic_locations.append(loc) - world.clear_location_cache() + world.clear_location_cache() - world.push_item(loc, ItemFactory(item['item']), False) - loc.event = True + world.push_item(loc, ItemFactory(item['item'], player), False) + loc.event = True + loc.locked = True def fill_prizes(world, attempts=15): - crystals = ItemFactory(['Red Pendant', 'Blue Pendant', 'Green Pendant', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 7', 'Crystal 5', 'Crystal 6']) - crystal_locations = [world.get_location('Turtle Rock - Prize'), world.get_location('Eastern Palace - Prize'), world.get_location('Desert Palace - Prize'), world.get_location('Tower of Hera - Prize'), world.get_location('Palace of Darkness - Prize'), - world.get_location('Thieves\' Town - Prize'), world.get_location('Skull Woods - Prize'), world.get_location('Swamp Palace - Prize'), world.get_location('Ice Palace - Prize'), - world.get_location('Misery Mire - Prize')] - placed_prizes = [loc.item.name for loc in crystal_locations if loc.item is not None] - unplaced_prizes = [crystal for crystal in crystals if crystal.name not in placed_prizes] - empty_crystal_locations = [loc for loc in crystal_locations if loc.item is None] + all_state = world.get_all_state(keys=True) + for player in range(1, world.players + 1): + crystals = ItemFactory(['Red Pendant', 'Blue Pendant', 'Green Pendant', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 7', 'Crystal 5', 'Crystal 6'], 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 is not None] + unplaced_prizes = [crystal for crystal in crystals if crystal.name not in placed_prizes] + empty_crystal_locations = [loc for loc in crystal_locations if loc.item is None] - while attempts: - attempts -= 1 - try: - prizepool = list(unplaced_prizes) - prize_locs = list(empty_crystal_locations) - random.shuffle(prizepool) - random.shuffle(prize_locs) - fill_restrictive(world, world.get_all_state(keys=True), prize_locs, prizepool) - except FillError: - logging.getLogger('').info("Failed to place dungeon prizes. Will retry %s more times", attempts) - for location in empty_crystal_locations: - location.item = None - continue - break - else: - raise FillError('Unable to place dungeon prizes') + for attempt in range(attempts): + try: + prizepool = list(unplaced_prizes) + prize_locs = list(empty_crystal_locations) + random.shuffle(prizepool) + random.shuffle(prize_locs) + fill_restrictive(world, all_state, prize_locs, prizepool) + except FillError as e: + logging.getLogger('').info("Failed to place dungeon prizes (%s). Will retry %s more times", e, attempts) + for location in empty_crystal_locations: + location.item = None + continue + break + else: + raise FillError('Unable to place dungeon prizes') -def set_up_shops(world): +def set_up_shops(world, player): # Changes to basic Shops # TODO: move hard+ mode changes for sheilds here, utilizing the new shops @@ -377,13 +331,13 @@ def set_up_shops(world): shop.active = True if world.retro: - rss = world.get_region('Red Shield Shop').shop + rss = world.get_region('Red Shield Shop', player).shop rss.active = True rss.add_inventory(2, 'Single Arrow', 80) # Randomized changes to Shops if world.retro: - for shop in random.sample([s for s in world.shops if s.replaceable], 5): + for shop in random.sample([s for s in world.shops if s.replaceable and s.region.player == player], 5): shop.active = True shop.add_inventory(0, 'Single Arrow', 80) shop.add_inventory(1, 'Small Key (Universal)', 100) @@ -391,9 +345,10 @@ def set_up_shops(world): #special shop types -def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro): +def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, swords, retro): pool = [] placed_items = [] + precollected_items = [] clock_mode = None treasure_hunt_count = None treasure_hunt_icon = None @@ -409,8 +364,6 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro): pool.extend(basicgloves) lamps_needed_for_dark_rooms = 1 - if difficulty == 'easy': - lamps_needed_for_dark_rooms = 3 # insanity shuffle doesn't have fake LW/DW logic so for now guaranteed Mirror and Moon Pearl at the start if shuffle == 'insanity_legacy': @@ -446,15 +399,43 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro): else: pool.extend(diff.basicarmor) - if mode == 'swordless': - pool.extend(diff.swordless) - elif mode == 'standard': + if swords != 'swordless': if want_progressives(): - placed_items.append(('Link\'s Uncle', 'Progressive Sword')) - pool.extend(diff.progressivesword) + pool.extend(['Progressive Bow'] * 2) + else: + pool.extend(diff.basicbow) + + if swords == 'swordless': + pool.extend(diff.swordless) + if want_progressives(): + pool.extend(['Progressive Bow'] * 2) + else: + pool.extend(['Bow', 'Silver Arrows']) + elif swords == 'assured': + precollected_items.append('Fighter Sword') + if want_progressives(): + pool.extend(diff.progressivesword) + pool.extend(['Rupees (100)']) else: - placed_items.append(('Link\'s Uncle', 'Fighter Sword')) pool.extend(diff.basicsword) + pool.extend(['Rupees (100)']) + elif swords == 'vanilla': + swords_to_use = [] + if want_progressives(): + swords_to_use.extend(diff.progressivesword) + swords_to_use.extend(['Progressive Sword']) + else: + swords_to_use.extend(diff.basicsword) + swords_to_use.extend(['Fighter Sword']) + random.shuffle(swords_to_use) + + placed_items.append(('Link\'s Uncle', swords_to_use.pop())) + placed_items.append(('Blacksmith', swords_to_use.pop())) + placed_items.append(('Pyramid Fairy - Left', swords_to_use.pop())) + if goal != 'pedestal': + placed_items.append(('Master Sword Pedestal', swords_to_use.pop())) + else: + placed_items.append(('Master Sword Pedestal', 'Triforce')) else: if want_progressives(): pool.extend(diff.progressivesword) @@ -479,16 +460,12 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro): treasure_hunt_count = diff.triforce_pieces_required treasure_hunt_icon = 'Triforce Piece' - cond_extras = diff.conditional_extras(timer, goal, mode, pool, placed_items) - pool.extend(cond_extras) - extraitems -= len(cond_extras) - for extra in diff.extras: if extraitems > 0: pool.extend(extra) extraitems -= len(extra) - if goal == 'pedestal': + if goal == 'pedestal' and swords != 'vanilla': placed_items.append(('Master Sword Pedestal', 'Triforce')) if retro: pool = [item.replace('Single Arrow','Rupees (5)') for item in pool] @@ -501,11 +478,12 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro): placed_items.append((key_location, 'Small Key (Universal)')) else: pool.extend(['Small Key (Universal)']) - return (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) + return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) -def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, retro, customitemarray): +def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, swords, retro, customitemarray): pool = [] placed_items = [] + precollected_items = [] clock_mode = None treasure_hunt_count = None treasure_hunt_icon = None @@ -587,8 +565,6 @@ def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, r diff = difficulties[difficulty] lamps_needed_for_dark_rooms = 1 - if difficulty == 'easy': - lamps_needed_for_dark_rooms = customitemarray[12] # expert+ difficulties produce the same contents for # all bottles, since only one bottle is available @@ -620,14 +596,6 @@ def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, r itemtotal = itemtotal + 1 if mode == 'standard': - if progressive == 'off': - placed_items.append(('Link\'s Uncle', 'Fighter Sword')) - pool.extend(['Fighter Sword'] * max((customitemarray[32] - 1), 0)) - pool.extend(['Progressive Sword'] * customitemarray[36]) - else: - placed_items.append(('Link\'s Uncle', 'Progressive Sword')) - pool.extend(['Fighter Sword'] * customitemarray[32]) - pool.extend(['Progressive Sword'] * max((customitemarray[36] - 1), 0)) if retro: key_location = random.choice(['Secret Passage', 'Hyrule Castle - Boomerang Chest', 'Hyrule Castle - Map Chest', 'Hyrule Castle - Zelda\'s Chest', 'Sewers - Dark Cross']) placed_items.append((key_location, 'Small Key (Universal)')) @@ -635,10 +603,11 @@ def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, r else: pool.extend(['Small Key (Universal)'] * customitemarray[68]) else: - pool.extend(['Fighter Sword'] * customitemarray[32]) - pool.extend(['Progressive Sword'] * customitemarray[36]) pool.extend(['Small Key (Universal)'] * customitemarray[68]) + pool.extend(['Fighter Sword'] * customitemarray[32]) + pool.extend(['Progressive Sword'] * customitemarray[36]) + if shuffle == 'insanity_legacy': placed_items.append(('Link\'s House', 'Magic Mirror')) placed_items.append(('Sanctuary', 'Moon Pearl')) @@ -653,28 +622,31 @@ def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, r if itemtotal < total_items_to_place: pool.extend(['Nothing'] * (total_items_to_place - itemtotal)) - return (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) + return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms) # A quick test to ensure all combinations generate the correct amount of items. def test(): - for difficulty in ['easy', 'normal', 'hard', 'expert', 'insane']: + for difficulty in ['normal', 'hard', 'expert']: for goal in ['ganon', 'triforcehunt', 'pedestal']: for timer in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown']: - for mode in ['open', 'standard', 'swordless']: - for progressive in ['on', 'off']: - for shuffle in ['full', 'insane']: - for retro in [True, False]: - out = get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, retro) - count = len(out[0]) + len(out[1]) + for mode in ['open', 'standard', 'inverted']: + for swords in ['random', 'assured', 'swordless', 'vanilla']: + for progressive in ['on', 'off']: + for shuffle in ['full', 'insanity_legacy']: + for retro in [True, False]: + out = get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, swords, retro) + count = len(out[0]) + len(out[1]) - correct_count = total_items_to_place - if goal in ['pedestal']: - # pedestal goals generate one extra item - correct_count += 1 - if retro: - correct_count += 28 - - assert count == correct_count, "expected {0} items but found {1} items for {2}".format(correct_count, count, (progressive, shuffle, difficulty, timer, goal, mode, retro)) + correct_count = total_items_to_place + if goal == 'pedestal' and swords != 'vanilla': + # pedestal goals generate one extra item + correct_count += 1 + if retro: + correct_count += 28 + try: + assert count == correct_count, "expected {0} items but found {1} items for {2}".format(correct_count, count, (progressive, shuffle, difficulty, timer, goal, mode, swords, retro)) + except AssertionError as e: + print(e) if __name__ == '__main__': test() diff --git a/Items.py b/Items.py index 2e0d85061b..f9a7d88481 100644 --- a/Items.py +++ b/Items.py @@ -3,7 +3,7 @@ import logging from BaseClasses import Item -def ItemFactory(items): +def ItemFactory(items, player): ret = [] singleton = False if isinstance(items, str): @@ -12,7 +12,7 @@ def ItemFactory(items): for item in items: if item in item_table: advancement, priority, type, code, pedestal_hint, pedestal_credit, sickkid_credit, zora_credit, witch_credit, fluteboy_credit, hint_text = item_table[item] - ret.append(Item(item, advancement, priority, type, code, pedestal_hint, pedestal_credit, sickkid_credit, zora_credit, witch_credit, fluteboy_credit, hint_text)) + ret.append(Item(item, advancement, priority, type, code, pedestal_hint, pedestal_credit, sickkid_credit, zora_credit, witch_credit, fluteboy_credit, hint_text, player)) else: logging.getLogger('').warning('Unknown Item: %s', item) return None @@ -24,6 +24,7 @@ def ItemFactory(items): # Format: Name: (Advancement, Priority, Type, ItemCode, Pedestal Hint Text, Pedestal Credit Text, Sick Kid Credit Text, Zora Credit Text, Witch Credit Text, Flute Boy Credit Text, Hint Text) item_table = {'Bow': (True, False, None, 0x0B, 'You have\nchosen the\narcher class.', 'the stick and twine', 'arrow-slinging kid', 'arrow sling for sale', 'witch and robin hood', 'archer boy shoots again', 'the Bow'), + 'Progressive Bow': (True, False, None, 0x64, 'You have\nchosen the\narcher class.', 'the stick and twine', 'arrow-slinging kid', 'arrow sling for sale', 'witch and robin hood', 'archer boy shoots again', 'a Bow'), 'Book of Mudora': (True, False, None, 0x1D, 'This is a\nparadox?!', 'and the story book', 'the scholarly kid', 'moon runes for sale', 'drugs for literacy', 'book-worm boy can read again', 'the Book'), 'Hammer': (True, False, None, 0x09, 'stop\nhammer time!', 'and m c hammer', 'hammer-smashing kid', 'm c hammer for sale', 'stop... hammer time', 'stop, hammer time', 'the hammer'), 'Hookshot': (True, False, None, 0x0A, 'BOING!!!\nBOING!!!\nBOING!!!', 'and the tickle beam', 'tickle-monster kid', 'tickle beam for sale', 'witch and tickle boy', 'beam boy tickles again', 'the Hookshot'), diff --git a/Main.py b/Main.py index c118299d09..9442c8abc0 100644 --- a/Main.py +++ b/Main.py @@ -3,44 +3,28 @@ import copy from itertools import zip_longest import json import logging +import os import random import time from BaseClasses import World, CollectionState, Item, Region, Location, Shop from Regions import create_regions, mark_light_world_regions -from EntranceShuffle import link_entrances -from Rom import patch_rom, Sprite, LocalRom, JsonRom +from InvertedRegions import create_inverted_regions, mark_dark_world_regions +from EntranceShuffle import link_entrances, link_inverted_entrances +from Rom import patch_rom, get_enemizer_patch, apply_rom_settings, Sprite, LocalRom, JsonRom from Rules import set_rules from Dungeons import create_dungeons, fill_dungeons, fill_dungeons_restrictive -from Fill import distribute_items_cutoff, distribute_items_staleness, distribute_items_restrictive, flood_items +from Fill import distribute_items_cutoff, distribute_items_staleness, distribute_items_restrictive, flood_items, balance_multiworld_progression from ItemList import generate_itempool, difficulties, fill_prizes from Utils import output_path -__version__ = '0.6.2' - -logic_hash = [134, 166, 181, 191, 228, 89, 188, 200, 5, 157, 217, 139, 180, 198, 106, 104, - 88, 223, 138, 28, 54, 18, 216, 129, 248, 19, 109, 220, 159, 75, 238, 57, - 231, 183, 143, 167, 114, 176, 82, 169, 179, 94, 115, 193, 252, 222, 52, 245, - 33, 208, 39, 122, 177, 136, 29, 161, 210, 165, 6, 125, 146, 212, 101, 185, - 65, 247, 253, 85, 171, 147, 71, 148, 203, 202, 230, 1, 13, 64, 254, 141, - 32, 93, 152, 4, 92, 16, 195, 204, 246, 201, 11, 7, 189, 97, 9, 91, - 237, 215, 163, 131, 142, 34, 111, 196, 120, 127, 168, 211, 227, 61, 187, 110, - 190, 162, 59, 80, 225, 186, 37, 154, 76, 72, 27, 17, 79, 206, 207, 243, - 184, 197, 153, 48, 119, 99, 2, 151, 51, 67, 121, 175, 38, 224, 87, 242, - 45, 22, 155, 244, 209, 117, 214, 213, 194, 126, 236, 73, 133, 70, 49, 140, - 229, 108, 156, 124, 105, 226, 44, 23, 112, 102, 173, 219, 14, 116, 58, 103, - 55, 10, 95, 251, 84, 118, 160, 78, 63, 250, 31, 41, 35, 255, 170, 25, - 66, 172, 98, 249, 68, 8, 113, 21, 46, 24, 137, 149, 81, 130, 42, 164, - 50, 12, 158, 15, 47, 182, 30, 40, 36, 83, 77, 205, 20, 241, 3, 132, - 0, 60, 96, 62, 74, 178, 53, 56, 135, 174, 145, 86, 107, 233, 218, 221, - 43, 150, 100, 69, 235, 26, 234, 192, 199, 144, 232, 128, 239, 123, 240, 90] - +__version__ = '0.6.3-pre' def main(args, seed=None): start = time.clock() # initialize the world - world = World(args.shuffle, args.logic, args.mode, args.difficulty, args.timer, args.progressive, args.goal, args.algorithm, not args.nodungeonitems, args.beatableonly, args.shuffleganon, args.quickswap, args.fastmenu, args.disablemusic, args.keysanity, args.retro, args.custom, args.customitemarray, args.shufflebosses, args.hints) + world = World(args.multi, args.shuffle, args.logic, args.mode, args.swords, args.difficulty, args.item_functionality, args.timer, args.progressive, args.goal, args.algorithm, not args.nodungeonitems, args.accessibility, args.shuffleganon, args.quickswap, args.fastmenu, args.disablemusic, args.keysanity, args.retro, args.custom, args.customitemarray, args.shufflebosses, args.hints) logger = logging.getLogger('') if seed is None: random.seed(None) @@ -49,26 +33,46 @@ def main(args, seed=None): world.seed = int(seed) random.seed(world.seed) + world.crystals_needed_for_ganon = random.randint(0, 7) if args.crystals_ganon == 'random' else int(args.crystals_ganon) + world.crystals_needed_for_gt = random.randint(0, 7) if args.crystals_gt == 'random' else int(args.crystals_gt) + + world.rom_seeds = {player: random.randint(0, 999999999) for player in range(1, world.players + 1)} + logger.info('ALttP Entrance Randomizer Version %s - Seed: %s\n\n', __version__, world.seed) world.difficulty_requirements = difficulties[world.difficulty] - create_regions(world) - - create_dungeons(world) + if world.mode != 'inverted': + for player in range(1, world.players + 1): + create_regions(world, player) + create_dungeons(world, player) + else: + for player in range(1, world.players + 1): + create_inverted_regions(world, player) + create_dungeons(world, player) logger.info('Shuffling the World about.') - link_entrances(world) - mark_light_world_regions(world) + if world.mode != 'inverted': + for player in range(1, world.players + 1): + link_entrances(world, player) + + mark_light_world_regions(world) + else: + for player in range(1, world.players + 1): + link_inverted_entrances(world, player) + + mark_dark_world_regions(world) logger.info('Generating Item Pool.') - generate_itempool(world) + for player in range(1, world.players + 1): + generate_itempool(world, player) logger.info('Calculating Access Rules.') - set_rules(world) + for player in range(1, world.players + 1): + set_rules(world, player) logger.info('Placing Dungeon Prizes.') @@ -102,9 +106,9 @@ def main(args, seed=None): elif args.algorithm == 'balanced': distribute_items_restrictive(world, gt_filler(world)) - logger.info('Calculating playthrough.') - - create_playthrough(world) + if world.players > 1: + logger.info('Balancing multiworld progression.') + balance_multiworld_progression(world) logger.info('Patching ROM.') @@ -116,22 +120,57 @@ def main(args, seed=None): else: sprite = None - outfilebase = 'ER_%s_%s-%s-%s%s_%s-%s%s%s%s%s_%s' % (world.logic, world.difficulty, world.mode, world.goal, "" if world.timer in ['none', 'display'] else "-" + world.timer, world.shuffle, world.algorithm, "-keysanity" if world.keysanity else "", "-retro" if world.retro else "", "-prog_" + world.progressive if world.progressive in ['off', 'random'] else "", "-nohints" if not world.hints else "", world.seed) + outfilebase = 'ER_%s_%s-%s-%s-%s%s_%s-%s%s%s%s%s_%s' % (world.logic, world.difficulty, world.difficulty_adjustments, world.mode, world.goal, "" if world.timer in ['none', 'display'] else "-" + world.timer, world.shuffle, world.algorithm, "-keysanity" if world.keysanity else "", "-retro" if world.retro else "", "-prog_" + world.progressive if world.progressive in ['off', 'random'] else "", "-nohints" if not world.hints else "", world.seed) + use_enemizer = args.enemizercli and (args.shufflebosses != 'none' or args.shuffleenemies or args.enemy_health != 'default' or args.enemy_health != 'default' or args.enemy_damage or args.shufflepalette or args.shufflepots) + + jsonout = {} if not args.suppress_rom: - if args.jsonout: - rom = JsonRom() + if world.players > 1: + raise NotImplementedError("Multiworld rom writes have not been implemented") else: - rom = LocalRom(args.rom) - patch_rom(world, rom, bytearray(logic_hash), args.heartbeep, args.heartcolor, sprite) - if args.jsonout: - print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()})) - else: - rom.write_to_file(args.jsonout or output_path('%s.sfc' % outfilebase)) + player = 1 + + local_rom = None + if args.jsonout: + rom = JsonRom() + else: + if use_enemizer: + local_rom = LocalRom(args.rom) + rom = JsonRom() + else: + rom = LocalRom(args.rom) + + patch_rom(world, player, rom) + + enemizer_patch = [] + if use_enemizer: + enemizer_patch = get_enemizer_patch(world, player, rom, args.rom, args.enemizercli, args.shuffleenemies, args.enemy_health, args.enemy_damage, args.shufflepalette, args.shufflepots) + + if args.jsonout: + jsonout['patch'] = rom.patches + if use_enemizer: + jsonout['enemizer' % player] = enemizer_patch + else: + if use_enemizer: + local_rom.patch_enemizer(rom.patches, os.path.join(os.path.dirname(args.enemizercli), "enemizerBasePatch.json"), enemizer_patch) + rom = local_rom + + apply_rom_settings(rom, args.heartbeep, args.heartcolor, world.quickswap, world.fastmenu, world.disable_music, sprite) + rom.write_to_file(output_path('%s.sfc' % outfilebase)) if args.create_spoiler and not args.jsonout: world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) + if not args.skip_playthrough: + logger.info('Calculating playthrough.') + create_playthrough(world) + + if args.jsonout: + print(json.dumps({**jsonout, 'spoiler': world.spoiler.to_json()})) + elif args.create_spoiler and not args.skip_playthrough: + world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) + logger.info('Done. Enjoy.') logger.debug('Total Time: %s', time.clock() - start) @@ -144,10 +183,12 @@ def gt_filler(world): def copy_world(world): # ToDo: Not good yet - ret = World(world.shuffle, world.logic, world.mode, world.difficulty, world.timer, world.progressive, world.goal, world.algorithm, world.place_dungeon_items, world.check_beatable_only, world.shuffle_ganon, world.quickswap, world.fastmenu, world.disable_music, world.keysanity, world.retro, world.custom, world.customitemarray, world.boss_shuffle, world.hints) - ret.required_medallions = list(world.required_medallions) - ret.swamp_patch_required = world.swamp_patch_required - ret.ganon_at_pyramid = world.ganon_at_pyramid + ret = World(world.players, world.shuffle, world.logic, world.mode, world.swords, world.difficulty, world.difficulty_adjustments, world.timer, world.progressive, world.goal, world.algorithm, world.place_dungeon_items, world.accessibility, world.shuffle_ganon, world.quickswap, world.fastmenu, world.disable_music, world.keysanity, world.retro, world.custom, world.customitemarray, world.boss_shuffle, world.hints) + ret.required_medallions = world.required_medallions.copy() + ret.swamp_patch_required = world.swamp_patch_required.copy() + ret.ganon_at_pyramid = world.ganon_at_pyramid.copy() + ret.powder_patch_required = world.powder_patch_required.copy() + ret.ganonstower_vanilla = world.ganonstower_vanilla.copy() ret.treasure_hunt_count = world.treasure_hunt_count ret.treasure_hunt_icon = world.treasure_hunt_icon ret.sewer_light_cone = world.sewer_light_cone @@ -162,52 +203,67 @@ def copy_world(world): ret.difficulty_requirements = world.difficulty_requirements ret.fix_fake_world = world.fix_fake_world ret.lamps_needed_for_dark_rooms = world.lamps_needed_for_dark_rooms - create_regions(ret) - create_dungeons(ret) + ret.crystals_needed_for_ganon = world.crystals_needed_for_ganon + ret.crystals_needed_for_gt = world.crystals_needed_for_gt + + if world.mode != 'inverted': + for player in range(1, world.players + 1): + create_regions(ret, player) + create_dungeons(ret, player) + else: + for player in range(1, world.players + 1): + create_inverted_regions(ret, player) + create_dungeons(ret, player) copy_dynamic_regions_and_locations(world, ret) # copy bosses for dungeon in world.dungeons: for level, boss in dungeon.bosses.items(): - ret.get_dungeon(dungeon.name).bosses[level] = boss + ret.get_dungeon(dungeon.name, dungeon.player).bosses[level] = boss for shop in world.shops: - copied_shop = ret.get_region(shop.region.name).shop + copied_shop = ret.get_region(shop.region.name, shop.region.player).shop copied_shop.active = shop.active copied_shop.inventory = copy.copy(shop.inventory) # connect copied world for region in world.regions: - copied_region = ret.get_region(region.name) + copied_region = ret.get_region(region.name, region.player) copied_region.is_light_world = region.is_light_world copied_region.is_dark_world = region.is_dark_world for entrance in region.entrances: - ret.get_entrance(entrance.name).connect(copied_region) + ret.get_entrance(entrance.name, entrance.player).connect(copied_region) # fill locations for location in world.get_locations(): if location.item is not None: - item = Item(location.item.name, location.item.advancement, location.item.priority, location.item.type) - ret.get_location(location.name).item = item - item.location = ret.get_location(location.name) + item = Item(location.item.name, location.item.advancement, location.item.priority, location.item.type, player = location.item.player) + ret.get_location(location.name, location.player).item = item + item.location = ret.get_location(location.name, location.player) if location.event: - ret.get_location(location.name).event = True + ret.get_location(location.name, location.player).event = True + if location.locked: + ret.get_location(location.name, location.player).locked = True # copy remaining itempool. No item in itempool should have an assigned location for item in world.itempool: - ret.itempool.append(Item(item.name, item.advancement, item.priority, item.type)) + ret.itempool.append(Item(item.name, item.advancement, item.priority, item.type, player = item.player)) # copy progress items in state - ret.state.prog_items = list(world.state.prog_items) + ret.state.prog_items = world.state.prog_items.copy() + ret.precollected_items = world.precollected_items.copy() + ret.state.stale = {player: True for player in range(1, world.players + 1)} - set_rules(ret) + for player in range(1, world.players + 1): + set_rules(ret, player) return ret def copy_dynamic_regions_and_locations(world, ret): for region in world.dynamic_regions: - new_reg = Region(region.name, region.type, region.hint_text) + new_reg = Region(region.name, region.type, region.hint_text, region.player) + new_reg.world = ret ret.regions.append(new_reg) ret.dynamic_regions.append(new_reg) @@ -218,9 +274,16 @@ def copy_dynamic_regions_and_locations(world, ret): ret.shops.append(new_reg.shop) for location in world.dynamic_locations: - new_loc = Location(location.name, location.address, location.crystal, location.hint_text, location.parent_region) - new_reg = ret.get_region(location.parent_region.name) + new_reg = ret.get_region(location.parent_region.name, location.parent_region.player) + new_loc = Location(location.player, location.name, location.address, location.crystal, location.hint_text, new_reg) + # todo: this is potentially dangerous. later refactor so we + # can apply dynamic region rules on top of copied world like other rules + new_loc.access_rule = location.access_rule + new_loc.always_allow = location.always_allow + new_loc.item_rule = location.item_rule new_reg.locations.append(new_loc) + + ret.clear_location_cache() def create_playthrough(world): @@ -228,12 +291,8 @@ def create_playthrough(world): old_world = world world = copy_world(world) - # in treasure hunt and pedestal goals, ganon is invincible - if world.goal in ['pedestal', 'triforcehunt']: - world.get_location('Ganon').item = None - # if we only check for beatable, we can do this sanity check first before writing down spheres - if world.check_beatable_only and not world.can_beat_game(): + if world.accessibility == 'none' and not world.can_beat_game(): raise RuntimeError('Cannot beat game. Something went terribly wrong here!') # get locations containing progress items @@ -263,8 +322,8 @@ def create_playthrough(world): logging.getLogger('').debug('Calculated sphere %i, containing %i of %i progress items.', len(collection_spheres), len(sphere), len(prog_locations)) if not sphere: - logging.getLogger('').debug('The following items could not be reached: %s', ['%s at %s' % (location.item.name, location.name) for location in sphere_candidates]) - if not world.check_beatable_only: + logging.getLogger('').debug('The following items could not be reached: %s', ['%s (Player %d) at %s (Player %d)' % (location.item.name, location.item.player, location.name, location.player) for location in sphere_candidates]) + if not world.accessibility == 'none': raise RuntimeError('Not all progression items reachable. Something went terribly wrong here.') else: break @@ -274,12 +333,11 @@ def create_playthrough(world): to_delete = [] for location in sphere: # we remove the item at location and check if game is still beatable - logging.getLogger('').debug('Checking if %s is required to beat the game.', location.item.name) + logging.getLogger('').debug('Checking if %s (Player %d) is required to beat the game.', location.item.name, location.item.player) old_item = location.item location.item = None state.remove(old_item) - ##if world.can_beat_game(state_cache[num]): - if world.can_beat_game(): + if world.can_beat_game(state_cache[num]): to_delete.append(location) else: # still required, got to keep it around @@ -315,7 +373,7 @@ def create_playthrough(world): raise RuntimeError('Not all required items reachable. Something went terribly wrong here.') # store the required locations for statistical analysis - old_world.required_locations = [location.name for sphere in collection_spheres for location in sphere] + old_world.required_locations = [(location.name, location.player) for sphere in collection_spheres for location in sphere] def flist_to_iter(node): while node: @@ -330,9 +388,15 @@ def create_playthrough(world): pathpairs = zip_longest(pathsiter, pathsiter) return list(pathpairs) - old_world.spoiler.paths = {location.name : get_path(state, location.parent_region) for sphere in collection_spheres for location in sphere} - if any(exit == 'Pyramid Fairy' for path in old_world.spoiler.paths.values() for (_, exit) in path): - old_world.spoiler.paths['Big Bomb Shop'] = get_path(state, world.get_region('Big Bomb Shop')) + old_world.spoiler.paths = dict() + for player in range(1, world.players + 1): + old_world.spoiler.paths.update({ str(location) : get_path(state, location.parent_region) for sphere in collection_spheres for location in sphere if location.player == player}) + for _, path in dict(old_world.spoiler.paths).items(): + if any(exit == 'Pyramid Fairy' for (_, exit) in path): + if world.mode != 'inverted': + old_world.spoiler.paths[str(world.get_region('Big Bomb Shop', player))] = get_path(state, world.get_region('Big Bomb Shop', player)) + else: + old_world.spoiler.paths[str(world.get_region('Inverted Big Bomb Shop', player))] = get_path(state, world.get_region('Inverted Big Bomb Shop', player)) # we can finally output our playthrough old_world.spoiler.playthrough = OrderedDict([(str(i + 1), {str(location): str(location.item) for location in sphere}) for i, sphere in enumerate(collection_spheres)]) diff --git a/Plando.py b/Plando.py index f2f6887366..290e212b54 100755 --- a/Plando.py +++ b/Plando.py @@ -19,21 +19,11 @@ from Main import create_playthrough __version__ = '0.2-dev' -logic_hash = [182, 244, 144, 92, 149, 200, 93, 183, 124, 169, 226, 46, 111, 163, 5, 193, 13, 112, 125, 101, 128, 84, 31, 67, 107, 94, 184, 100, 189, 18, 8, 171, - 142, 57, 173, 38, 37, 211, 253, 131, 98, 239, 167, 116, 32, 186, 70, 148, 66, 151, 143, 86, 59, 83, 16, 51, 240, 152, 60, 242, 190, 117, 76, 122, - 15, 221, 62, 39, 174, 177, 223, 34, 150, 50, 178, 238, 95, 219, 10, 162, 222, 0, 165, 202, 74, 36, 206, 209, 251, 105, 175, 135, 121, 88, 214, 247, - 154, 161, 71, 19, 85, 157, 40, 96, 225, 27, 230, 49, 231, 207, 64, 35, 249, 134, 132, 108, 63, 24, 4, 127, 255, 14, 145, 23, 81, 216, 113, 90, 194, - 110, 65, 229, 43, 1, 11, 168, 147, 103, 156, 77, 80, 220, 28, 227, 213, 198, 172, 79, 75, 140, 44, 146, 188, 17, 6, 102, 56, 235, 166, 89, 218, 246, - 99, 78, 187, 126, 119, 196, 69, 137, 181, 55, 20, 215, 199, 130, 9, 45, 58, 185, 91, 33, 197, 72, 115, 195, 114, 29, 30, 233, 141, 129, 155, 159, 47, - 224, 236, 21, 234, 191, 136, 104, 87, 106, 26, 73, 250, 248, 228, 48, 53, 243, 237, 241, 61, 180, 12, 208, 245, 232, 192, 2, 7, 170, 123, 176, 160, 201, - 153, 217, 252, 158, 25, 205, 22, 133, 254, 138, 203, 118, 210, 204, 82, 97, 52, 164, 68, 139, 120, 109, 54, 3, 41, 179, 212, 42] - - def main(args): start_time = time.clock() # initialize the world - world = World('vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, args.quickswap, args.fastmenu, args.disablemusic, False, False, False, None) + world = World(1, 'vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, args.quickswap, args.fastmenu, args.disablemusic, False, False, False, None, 'none', False) logger = logging.getLogger('') hasher = hashlib.md5() @@ -48,14 +38,14 @@ def main(args): world.difficulty_requirements = difficulties[world.difficulty] - create_regions(world) - create_dungeons(world) + create_regions(world, 1) + create_dungeons(world, 1) - link_entrances(world) + link_entrances(world, 1) logger.info('Calculating Access Rules.') - set_rules(world) + set_rules(world, 1) logger.info('Fill the world.') @@ -63,8 +53,8 @@ def main(args): fill_world(world, args.plando, text_patches) - if world.get_entrance('Dam').connected_region.name != 'Dam' or world.get_entrance('Swamp Palace').connected_region.name != 'Swamp Palace (Entrance)': - world.swamp_patch_required = True + if world.get_entrance('Dam', 1).connected_region.name != 'Dam' or world.get_entrance('Swamp Palace', 1).connected_region.name != 'Swamp Palace (Entrance)': + world.swamp_patch_required[1] = True logger.info('Calculating playthrough.') @@ -84,7 +74,7 @@ def main(args): sprite = None rom = LocalRom(args.rom) - patch_rom(world, rom, logic_hash, args.heartbeep, args.heartcolor, sprite) + patch_rom(world, 1, rom, args.heartbeep, args.heartcolor, sprite) for textname, texttype, text in text_patches: if texttype == 'text': @@ -174,33 +164,33 @@ def fill_world(world, plando, text_patches): continue locationstr, itemstr = line.split(':', 1) - location = world.get_location(locationstr.strip()) + location = world.get_location(locationstr.strip(), 1) if location is None: logger.warning('Unknown location: %s', locationstr) continue else: - item = ItemFactory(itemstr.strip()) + item = ItemFactory(itemstr.strip(), 1) if item is not None: world.push_item(location, item) if item.key: location.event = True elif '<=>' in line: entrance, exit = line.split('<=>', 1) - connect_two_way(world, entrance.strip(), exit.strip()) + connect_two_way(world, entrance.strip(), exit.strip(), 1) elif '=>' in line: entrance, exit = line.split('=>', 1) - connect_entrance(world, entrance.strip(), exit.strip()) + connect_entrance(world, entrance.strip(), exit.strip(), 1) elif '<=' in line: entrance, exit = line.split('<=', 1) - connect_exit(world, exit.strip(), entrance.strip()) + connect_exit(world, exit.strip(), entrance.strip(), 1) - world.required_medallions = (mm_medallion, tr_medallion) + world.required_medallions[1] = (mm_medallion, tr_medallion) # set up Agahnim Events - world.get_location('Agahnim 1').event = True - world.get_location('Agahnim 1').item = ItemFactory('Beat Agahnim 1') - world.get_location('Agahnim 2').event = True - world.get_location('Agahnim 2').item = ItemFactory('Beat Agahnim 2') + world.get_location('Agahnim 1', 1).event = True + world.get_location('Agahnim 1', 1).item = ItemFactory('Beat Agahnim 1', 1) + world.get_location('Agahnim 2', 1).event = True + world.get_location('Agahnim 2', 1).item = ItemFactory('Beat Agahnim 2', 1) def start(): diff --git a/README.md b/README.md index 8da432d650..b0628d1462 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,16 @@ Special notes: - The magic barrier to Hyrule Castle Tower can be broken with a Hammer. - The Hammer can be used to activate the Ether and Bombos tablets. +### Inverted + +This mode is similar to Open but requires the Moon Pearl in order to not transform into a bunny in the Light World and the Sanctuary spawn point is moved to the Dark Sanctuary + +Special Notes: + +- Link's House is shuffled freely. The Dark Sanctuary is shuffled within West Dark World. +- There are a number of overworld changes to account for the inability to mirror from the Light World to the Dark World. +- Legacy shuffles are not implemente for this mode. + ## Game Logic This determines the Item Requirements for each location. @@ -85,12 +95,6 @@ This is only noticeably different if the the Ganon shuffle option is enabled. ## Game Difficulty -### Easy - -This setting doubles the number of swords, shields, armors, bottles, and silver arrows in the item pool. -This setting will also triple the number of Lamps available, and all will be obtainable before dark rooms. -Within dungeons, the number of items found will be displayed on screen if there is no timer. - ### Normal This is the default setting that has an item pool most similar to the original @@ -108,11 +112,6 @@ the player from having fairies in bottles. This setting is a more extreme version of the Hard setting. Potions are further nerfed, the item pool is less helpful, and the player can find no armor, only a Master Sword, and only a single bottle. -### Insane - -This setting is a modest step up from Expert. The main difference is that the player will never find any -additional health. - ## Timer Setting ### None @@ -288,10 +287,6 @@ In further concert with the Bow changes, all arrows under pots, in chests, and e If not set, Compasses and Maps are removed from the dungeon item pools and replaced by empty chests that may end up anywhere in the world. This may lead to different amount of itempool items being placed in a dungeon than you are used to. -## Only Ensure Seed Beatable - -If set, will only ensure the goal can be achieved, but not necessarily that all locations are reachable. Currently only affects VT25, VT26 and balanced algorithms. - ## Include Ganon's Tower and Pyramid Hole in Shuffle pool If set, Ganon's Tower is included in the dungeon shuffle pool and the Pyramid Hole/Exit pair is included in the Holes shuffle pool. Ganon can not be defeated until the primary goal is fulfilled. @@ -336,7 +331,7 @@ Output a Spoiler File (default: False) Select the game logic (default: noglitches) ``` ---mode [{standard,open,swordless}] +--mode [{standard,open,swordless,inverted}] ``` Select the game mode. (default: open) @@ -348,11 +343,17 @@ Select the game mode. (default: open) Select the game completion goal. (default: ganon) ``` ---difficulty [{easy,normal,hard,expert,insane}] +--difficulty [{normal,hard,expert}] ``` Select the game difficulty. Affects available itempool. (default: normal) +``` +--item_functionality [{normal,hard,expert}] +``` + +Select limits on item functionality to increase difficulty. (default: normal) + ``` --timer [{none,display,timed,timed-ohko,ohko,timed-countdown}] ``` @@ -458,10 +459,10 @@ Select the color of Link\'s heart meter. (default: red) Use to select a different sprite sheet to use for Link. Path to a binary file of length 0x7000 containing the sprite data stored at address 0x80000 in the rom. (default: None) ``` ---beatableonly +--accessibility [{items,locations,none}] ``` -Enables the "Only Ensure Seed Beatable" option (default: False) +Sets the item/location accessibility rules. (default: items) ``` --hints diff --git a/Regions.py b/Regions.py index f95216a3d3..70ae3b0b89 100644 --- a/Regions.py +++ b/Regions.py @@ -2,10 +2,10 @@ import collections from BaseClasses import Region, Location, Entrance, RegionType, Shop, ShopType -def create_regions(world): +def create_regions(world, player): - world.regions = [ - create_lw_region('Light World', ['Mushroom', 'Bottle Merchant', 'Flute Spot', 'Sunken Treasure', 'Purple Chest'], + world.regions += [ + create_lw_region(player, 'Light World', ['Mushroom', 'Bottle Merchant', 'Flute Spot', 'Sunken Treasure', 'Purple Chest'], ["Blinds Hideout", "Hyrule Castle Secret Entrance Drop", 'Zoras River', 'Kings Grave Outer Rocks', 'Dam', 'Links House', 'Tavern North', 'Chicken House', 'Aginahs Cave', 'Sahasrahlas Hut', 'Kakariko Well Drop', 'Kakariko Well Cave', 'Blacksmiths Hut', 'Bat Cave Drop Ledge', 'Bat Cave Cave', 'Sick Kids House', 'Hobo Bridge', 'Lost Woods Hideout Drop', 'Lost Woods Hideout Stump', @@ -15,118 +15,118 @@ def create_regions(world): 'Elder House (East)', 'Elder House (West)', 'North Fairy Cave', 'North Fairy Cave Drop', 'Lost Woods Gamble', 'Snitch Lady (East)', 'Snitch Lady (West)', 'Tavern (Front)', 'Bush Covered House', 'Light World Bomb Hut', 'Kakariko Shop', 'Long Fairy Cave', 'Good Bee Cave', '20 Rupee Cave', 'Cave Shop (Lake Hylia)', 'Waterfall of Wishing', 'Hyrule Castle Main Gate', 'Bonk Fairy (Light)', '50 Rupee Cave', 'Fortune Teller (Light)', 'Lake Hylia Fairy', 'Light Hype Fairy', 'Desert Fairy', 'Lumberjack House', 'Lake Hylia Fortune Teller', 'Kakariko Gamble Game', 'Top of Pyramid']), - create_lw_region('Death Mountain Entrance', None, ['Old Man Cave (West)', 'Death Mountain Entrance Drop']), - create_lw_region('Lake Hylia Central Island', None, ['Capacity Upgrade', 'Lake Hylia Central Island Teleporter']), - create_cave_region('Blinds Hideout', 'a bounty of five items', ["Blind\'s Hideout - Top", + create_lw_region(player, 'Death Mountain Entrance', None, ['Old Man Cave (West)', 'Death Mountain Entrance Drop']), + create_lw_region(player, 'Lake Hylia Central Island', None, ['Capacity Upgrade', 'Lake Hylia Central Island Teleporter']), + create_cave_region(player, 'Blinds Hideout', 'a bounty of five items', ["Blind\'s Hideout - Top", "Blind\'s Hideout - Left", "Blind\'s Hideout - Right", "Blind\'s Hideout - Far Left", "Blind\'s Hideout - Far Right"]), - create_cave_region('Hyrule Castle Secret Entrance', 'a drop\'s exit', ['Link\'s Uncle', 'Secret Passage'], ['Hyrule Castle Secret Entrance Exit']), - create_lw_region('Zoras River', ['King Zora', 'Zora\'s Ledge']), - create_cave_region('Waterfall of Wishing', 'a cave with two chests', ['Waterfall Fairy - Left', 'Waterfall Fairy - Right']), - create_lw_region('Kings Grave Area', None, ['Kings Grave', 'Kings Grave Inner Rocks']), - create_cave_region('Kings Grave', 'a cave with a chest', ['King\'s Tomb']), - create_cave_region('North Fairy Cave', 'a drop\'s exit', None, ['North Fairy Cave Exit']), - create_cave_region('Dam', 'the dam', ['Floodgate', 'Floodgate Chest']), - create_cave_region('Links House', 'your house', ['Link\'s House'], ['Links House Exit']), - create_cave_region('Chris Houlihan Room', 'I AM ERROR', None, ['Chris Houlihan Room Exit']), - create_cave_region('Tavern', 'the tavern', ['Kakariko Tavern']), - create_cave_region('Elder House', 'a connector', None, ['Elder House Exit (East)', 'Elder House Exit (West)']), - create_cave_region('Snitch Lady (East)', 'a boring house'), - create_cave_region('Snitch Lady (West)', 'a boring house'), - create_cave_region('Bush Covered House', 'the grass man'), - create_cave_region('Tavern (Front)', 'the tavern'), - create_cave_region('Light World Bomb Hut', 'a restock room'), - create_cave_region('Kakariko Shop', 'a common shop'), - create_cave_region('Fortune Teller (Light)', 'a fortune teller'), - create_cave_region('Lake Hylia Fortune Teller', 'a fortune teller'), - create_cave_region('Lumberjack House', 'a boring house'), - create_cave_region('Bonk Fairy (Light)', 'a fairy fountain'), - create_cave_region('Bonk Fairy (Dark)', 'a fairy fountain'), - create_cave_region('Lake Hylia Healer Fairy', 'a fairy fountain'), - create_cave_region('Swamp Healer Fairy', 'a fairy fountain'), - create_cave_region('Desert Healer Fairy', 'a fairy fountain'), - create_cave_region('Dark Lake Hylia Healer Fairy', 'a fairy fountain'), - create_cave_region('Dark Lake Hylia Ledge Healer Fairy', 'a fairy fountain'), - create_cave_region('Dark Desert Healer Fairy', 'a fairy fountain'), - create_cave_region('Dark Death Mountain Healer Fairy', 'a fairy fountain'), - create_cave_region('Chicken House', 'a house with a chest', ['Chicken House']), - create_cave_region('Aginahs Cave', 'a cave with a chest', ['Aginah\'s Cave']), - create_cave_region('Sahasrahlas Hut', 'Sahasrahla', ['Sahasrahla\'s Hut - Left', 'Sahasrahla\'s Hut - Middle', 'Sahasrahla\'s Hut - Right', 'Sahasrahla']), - create_cave_region('Kakariko Well (top)', 'a drop\'s exit', ['Kakariko Well - Top', 'Kakariko Well - Left', 'Kakariko Well - Middle', + create_cave_region(player, 'Hyrule Castle Secret Entrance', 'a drop\'s exit', ['Link\'s Uncle', 'Secret Passage'], ['Hyrule Castle Secret Entrance Exit']), + create_lw_region(player, 'Zoras River', ['King Zora', 'Zora\'s Ledge']), + create_cave_region(player, 'Waterfall of Wishing', 'a cave with two chests', ['Waterfall Fairy - Left', 'Waterfall Fairy - Right']), + create_lw_region(player, 'Kings Grave Area', None, ['Kings Grave', 'Kings Grave Inner Rocks']), + create_cave_region(player, 'Kings Grave', 'a cave with a chest', ['King\'s Tomb']), + create_cave_region(player, 'North Fairy Cave', 'a drop\'s exit', None, ['North Fairy Cave Exit']), + create_cave_region(player, 'Dam', 'the dam', ['Floodgate', 'Floodgate Chest']), + create_cave_region(player, 'Links House', 'your house', ['Link\'s House'], ['Links House Exit']), + create_cave_region(player, 'Chris Houlihan Room', 'I AM ERROR', None, ['Chris Houlihan Room Exit']), + create_cave_region(player, 'Tavern', 'the tavern', ['Kakariko Tavern']), + create_cave_region(player, 'Elder House', 'a connector', None, ['Elder House Exit (East)', 'Elder House Exit (West)']), + create_cave_region(player, 'Snitch Lady (East)', 'a boring house'), + create_cave_region(player, 'Snitch Lady (West)', 'a boring house'), + create_cave_region(player, 'Bush Covered House', 'the grass man'), + create_cave_region(player, 'Tavern (Front)', 'the tavern'), + create_cave_region(player, 'Light World Bomb Hut', 'a restock room'), + create_cave_region(player, 'Kakariko Shop', 'a common shop'), + create_cave_region(player, 'Fortune Teller (Light)', 'a fortune teller'), + create_cave_region(player, 'Lake Hylia Fortune Teller', 'a fortune teller'), + create_cave_region(player, 'Lumberjack House', 'a boring house'), + create_cave_region(player, 'Bonk Fairy (Light)', 'a fairy fountain'), + create_cave_region(player, 'Bonk Fairy (Dark)', 'a fairy fountain'), + create_cave_region(player, 'Lake Hylia Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Swamp Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Desert Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Lake Hylia Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Lake Hylia Ledge Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Desert Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Dark Death Mountain Healer Fairy', 'a fairy fountain'), + create_cave_region(player, 'Chicken House', 'a house with a chest', ['Chicken House']), + create_cave_region(player, 'Aginahs Cave', 'a cave with a chest', ['Aginah\'s Cave']), + create_cave_region(player, 'Sahasrahlas Hut', 'Sahasrahla', ['Sahasrahla\'s Hut - Left', 'Sahasrahla\'s Hut - Middle', 'Sahasrahla\'s Hut - Right', 'Sahasrahla']), + create_cave_region(player, 'Kakariko Well (top)', 'a drop\'s exit', ['Kakariko Well - Top', 'Kakariko Well - Left', 'Kakariko Well - Middle', 'Kakariko Well - Right', 'Kakariko Well - Bottom'], ['Kakariko Well (top to bottom)']), - create_cave_region('Kakariko Well (bottom)', 'a drop\'s exit', None, ['Kakariko Well Exit']), - create_cave_region('Blacksmiths Hut', 'the smith', ['Blacksmith', 'Missing Smith']), - create_lw_region('Bat Cave Drop Ledge', None, ['Bat Cave Drop']), - create_cave_region('Bat Cave (right)', 'a drop\'s exit', ['Magic Bat'], ['Bat Cave Door']), - create_cave_region('Bat Cave (left)', 'a drop\'s exit', None, ['Bat Cave Exit']), - create_cave_region('Sick Kids House', 'the sick kid', ['Sick Kid']), - create_lw_region('Hobo Bridge', ['Hobo']), - create_cave_region('Lost Woods Hideout (top)', 'a drop\'s exit', ['Lost Woods Hideout'], ['Lost Woods Hideout (top to bottom)']), - create_cave_region('Lost Woods Hideout (bottom)', 'a drop\'s exit', None, ['Lost Woods Hideout Exit']), - create_cave_region('Lumberjack Tree (top)', 'a drop\'s exit', ['Lumberjack Tree'], ['Lumberjack Tree (top to bottom)']), - create_cave_region('Lumberjack Tree (bottom)', 'a drop\'s exit', None, ['Lumberjack Tree Exit']), - create_lw_region('Cave 45 Ledge', None, ['Cave 45']), - create_cave_region('Cave 45', 'a cave with an item', ['Cave 45']), - create_lw_region('Graveyard Ledge', None, ['Graveyard Cave']), - create_cave_region('Graveyard Cave', 'a cave with an item', ['Graveyard Cave']), - create_cave_region('Checkerboard Cave', 'a cave with an item', ['Checkerboard Cave']), - create_cave_region('Long Fairy Cave', 'a fairy fountain'), - create_cave_region('Mini Moldorm Cave', 'a bounty of five items', ['Mini Moldorm Cave - Far Left', 'Mini Moldorm Cave - Left', 'Mini Moldorm Cave - Right', + create_cave_region(player, 'Kakariko Well (bottom)', 'a drop\'s exit', None, ['Kakariko Well Exit']), + create_cave_region(player, 'Blacksmiths Hut', 'the smith', ['Blacksmith', 'Missing Smith']), + create_lw_region(player, 'Bat Cave Drop Ledge', None, ['Bat Cave Drop']), + create_cave_region(player, 'Bat Cave (right)', 'a drop\'s exit', ['Magic Bat'], ['Bat Cave Door']), + create_cave_region(player, 'Bat Cave (left)', 'a drop\'s exit', None, ['Bat Cave Exit']), + create_cave_region(player, 'Sick Kids House', 'the sick kid', ['Sick Kid']), + create_lw_region(player, 'Hobo Bridge', ['Hobo']), + create_cave_region(player, 'Lost Woods Hideout (top)', 'a drop\'s exit', ['Lost Woods Hideout'], ['Lost Woods Hideout (top to bottom)']), + create_cave_region(player, 'Lost Woods Hideout (bottom)', 'a drop\'s exit', None, ['Lost Woods Hideout Exit']), + create_cave_region(player, 'Lumberjack Tree (top)', 'a drop\'s exit', ['Lumberjack Tree'], ['Lumberjack Tree (top to bottom)']), + create_cave_region(player, 'Lumberjack Tree (bottom)', 'a drop\'s exit', None, ['Lumberjack Tree Exit']), + create_lw_region(player, 'Cave 45 Ledge', None, ['Cave 45']), + create_cave_region(player, 'Cave 45', 'a cave with an item', ['Cave 45']), + create_lw_region(player, 'Graveyard Ledge', None, ['Graveyard Cave']), + create_cave_region(player, 'Graveyard Cave', 'a cave with an item', ['Graveyard Cave']), + create_cave_region(player, 'Checkerboard Cave', 'a cave with an item', ['Checkerboard Cave']), + create_cave_region(player, 'Long Fairy Cave', 'a fairy fountain'), + create_cave_region(player, 'Mini Moldorm Cave', 'a bounty of five items', ['Mini Moldorm Cave - Far Left', 'Mini Moldorm Cave - Left', 'Mini Moldorm Cave - Right', 'Mini Moldorm Cave - Far Right', 'Mini Moldorm Cave - Generous Guy']), - create_cave_region('Ice Rod Cave', 'a cave with a chest', ['Ice Rod Cave']), - create_cave_region('Good Bee Cave', 'a cold bee'), - create_cave_region('20 Rupee Cave', 'a cave with some cash'), - create_cave_region('Cave Shop (Lake Hylia)', 'a common shop'), - create_cave_region('Cave Shop (Dark Death Mountain)', 'a common shop'), - create_cave_region('Bonk Rock Cave', 'a cave with a chest', ['Bonk Rock Cave']), - create_cave_region('Library', 'the library', ['Library']), - create_cave_region('Kakariko Gamble Game', 'a game of chance'), - create_cave_region('Potion Shop', 'the potion shop', ['Potion Shop']), - create_lw_region('Lake Hylia Island', ['Lake Hylia Island']), - create_cave_region('Capacity Upgrade', 'the queen of fairies'), - create_cave_region('Two Brothers House', 'a connector', None, ['Two Brothers House Exit (East)', 'Two Brothers House Exit (West)']), - create_lw_region('Maze Race Ledge', ['Maze Race'], ['Two Brothers House (West)']), - create_cave_region('50 Rupee Cave', 'a cave with some cash'), - create_lw_region('Desert Ledge', ['Desert Ledge'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)']), - create_lw_region('Desert Ledge (Northeast)', None, ['Checkerboard Cave']), - create_lw_region('Desert Palace Stairs', None, ['Desert Palace Entrance (South)']), - create_lw_region('Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)']), - create_lw_region('Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks']), - create_dungeon_region('Desert Palace Main (Outer)', 'Desert Palace', ['Desert Palace - Big Chest', 'Desert Palace - Torch', 'Desert Palace - Map Chest'], + create_cave_region(player, 'Ice Rod Cave', 'a cave with a chest', ['Ice Rod Cave']), + create_cave_region(player, 'Good Bee Cave', 'a cold bee'), + create_cave_region(player, '20 Rupee Cave', 'a cave with some cash'), + create_cave_region(player, 'Cave Shop (Lake Hylia)', 'a common shop'), + create_cave_region(player, 'Cave Shop (Dark Death Mountain)', 'a common shop'), + create_cave_region(player, 'Bonk Rock Cave', 'a cave with a chest', ['Bonk Rock Cave']), + create_cave_region(player, 'Library', 'the library', ['Library']), + create_cave_region(player, 'Kakariko Gamble Game', 'a game of chance'), + create_cave_region(player, 'Potion Shop', 'the potion shop', ['Potion Shop']), + create_lw_region(player, 'Lake Hylia Island', ['Lake Hylia Island']), + create_cave_region(player, 'Capacity Upgrade', 'the queen of fairies'), + create_cave_region(player, 'Two Brothers House', 'a connector', None, ['Two Brothers House Exit (East)', 'Two Brothers House Exit (West)']), + create_lw_region(player, 'Maze Race Ledge', ['Maze Race'], ['Two Brothers House (West)']), + create_cave_region(player, '50 Rupee Cave', 'a cave with some cash'), + create_lw_region(player, 'Desert Ledge', ['Desert Ledge'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)']), + create_lw_region(player, 'Desert Ledge (Northeast)', None, ['Checkerboard Cave']), + create_lw_region(player, 'Desert Palace Stairs', None, ['Desert Palace Entrance (South)']), + create_lw_region(player, 'Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)']), + create_lw_region(player, 'Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks']), + create_dungeon_region(player, 'Desert Palace Main (Outer)', 'Desert Palace', ['Desert Palace - Big Chest', 'Desert Palace - Torch', 'Desert Palace - Map Chest'], ['Desert Palace Pots (Outer)', 'Desert Palace Exit (West)', 'Desert Palace Exit (East)', 'Desert Palace East Wing']), - create_dungeon_region('Desert Palace Main (Inner)', 'Desert Palace', None, ['Desert Palace Exit (South)', 'Desert Palace Pots (Inner)']), - create_dungeon_region('Desert Palace East', 'Desert Palace', ['Desert Palace - Compass Chest', 'Desert Palace - Big Key Chest']), - create_dungeon_region('Desert Palace North', 'Desert Palace', ['Desert Palace - Boss', 'Desert Palace - Prize'], ['Desert Palace Exit (North)']), - create_dungeon_region('Eastern Palace', 'Eastern Palace', ['Eastern Palace - Compass Chest', 'Eastern Palace - Big Chest', 'Eastern Palace - Cannonball Chest', + create_dungeon_region(player, 'Desert Palace Main (Inner)', 'Desert Palace', None, ['Desert Palace Exit (South)', 'Desert Palace Pots (Inner)']), + create_dungeon_region(player, 'Desert Palace East', 'Desert Palace', ['Desert Palace - Compass Chest', 'Desert Palace - Big Key Chest']), + create_dungeon_region(player, 'Desert Palace North', 'Desert Palace', ['Desert Palace - Boss', 'Desert Palace - Prize'], ['Desert Palace Exit (North)']), + create_dungeon_region(player, 'Eastern Palace', 'Eastern Palace', ['Eastern Palace - Compass Chest', 'Eastern Palace - Big Chest', 'Eastern Palace - Cannonball Chest', 'Eastern Palace - Big Key Chest', 'Eastern Palace - Map Chest', 'Eastern Palace - Boss', 'Eastern Palace - Prize'], ['Eastern Palace Exit']), - create_lw_region('Master Sword Meadow', ['Master Sword Pedestal']), - create_cave_region('Lost Woods Gamble', 'a game of chance'), - create_lw_region('Hyrule Castle Courtyard', None, ['Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Entrance (South)']), - create_lw_region('Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Agahnims Tower', 'Hyrule Castle Ledge Courtyard Drop']), - create_dungeon_region('Hyrule Castle', 'Hyrule Castle', ['Hyrule Castle - Boomerang Chest', 'Hyrule Castle - Map Chest', 'Hyrule Castle - Zelda\'s Chest'], + create_lw_region(player, 'Master Sword Meadow', ['Master Sword Pedestal']), + create_cave_region(player, 'Lost Woods Gamble', 'a game of chance'), + create_lw_region(player, 'Hyrule Castle Courtyard', None, ['Hyrule Castle Secret Entrance Stairs', 'Hyrule Castle Entrance (South)']), + create_lw_region(player, 'Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Agahnims Tower', 'Hyrule Castle Ledge Courtyard Drop']), + create_dungeon_region(player, 'Hyrule Castle', 'Hyrule Castle', ['Hyrule Castle - Boomerang Chest', 'Hyrule Castle - Map Chest', 'Hyrule Castle - Zelda\'s Chest'], ['Hyrule Castle Exit (East)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (South)', 'Throne Room']), - create_dungeon_region('Sewer Drop', 'a drop\'s exit', None, ['Sewer Drop']), # This exists only to be referenced for access checks - create_dungeon_region('Sewers (Dark)', 'a drop\'s exit', ['Sewers - Dark Cross'], ['Sewers Door']), - create_dungeon_region('Sewers', 'a drop\'s exit', ['Sewers - Secret Room - Left', 'Sewers - Secret Room - Middle', + create_dungeon_region(player, 'Sewer Drop', 'a drop\'s exit', None, ['Sewer Drop']), # This exists only to be referenced for access checks + create_dungeon_region(player, 'Sewers (Dark)', 'a drop\'s exit', ['Sewers - Dark Cross'], ['Sewers Door']), + create_dungeon_region(player, 'Sewers', 'a drop\'s exit', ['Sewers - Secret Room - Left', 'Sewers - Secret Room - Middle', 'Sewers - Secret Room - Right'], ['Sanctuary Push Door', 'Sewers Back Door']), - create_dungeon_region('Sanctuary', 'a drop\'s exit', ['Sanctuary'], ['Sanctuary Exit']), - create_dungeon_region('Agahnims Tower', 'Castle Tower', ['Castle Tower - Room 03', 'Castle Tower - Dark Maze'], ['Agahnim 1', 'Agahnims Tower Exit']), - create_dungeon_region('Agahnim 1', 'Castle Tower', ['Agahnim 1'], None), - create_cave_region('Old Man Cave', 'a connector', ['Old Man'], ['Old Man Cave Exit (East)', 'Old Man Cave Exit (West)']), - create_cave_region('Old Man House', 'a connector', None, ['Old Man House Exit (Bottom)', 'Old Man House Front to Back']), - create_cave_region('Old Man House Back', 'a connector', None, ['Old Man House Exit (Top)', 'Old Man House Back to Front']), - create_lw_region('Death Mountain', None, ['Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave', 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)', 'Broken Bridge (West)', 'Death Mountain Teleporter']), - create_cave_region('Death Mountain Return Cave', 'a connector', None, ['Death Mountain Return Cave Exit (West)', 'Death Mountain Return Cave Exit (East)']), - create_lw_region('Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)']), - create_cave_region('Spectacle Rock Cave (Top)', 'a connector', ['Spectacle Rock Cave'], ['Spectacle Rock Cave Drop', 'Spectacle Rock Cave Exit (Top)']), - create_cave_region('Spectacle Rock Cave (Bottom)', 'a connector', None, ['Spectacle Rock Cave Exit']), - create_cave_region('Spectacle Rock Cave (Peak)', 'a connector', None, ['Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave Exit (Peak)']), - create_lw_region('East Death Mountain (Bottom)', None, ['Broken Bridge (East)', 'Paradox Cave (Bottom)', 'Paradox Cave (Middle)', 'East Death Mountain Teleporter', 'Hookshot Fairy', 'Fairy Ascension Rocks', 'Spiral Cave (Bottom)']), - create_cave_region('Hookshot Fairy', 'fairies deep in a cave'), - create_cave_region('Paradox Cave Front', 'a connector', None, ['Paradox Cave Push Block Reverse', 'Paradox Cave Exit (Bottom)', 'Light World Death Mountain Shop']), - create_cave_region('Paradox Cave Chest Area', 'a connector', ['Paradox Cave Lower - Far Left', + create_dungeon_region(player, 'Sanctuary', 'a drop\'s exit', ['Sanctuary'], ['Sanctuary Exit']), + create_dungeon_region(player, 'Agahnims Tower', 'Castle Tower', ['Castle Tower - Room 03', 'Castle Tower - Dark Maze'], ['Agahnim 1', 'Agahnims Tower Exit']), + create_dungeon_region(player, 'Agahnim 1', 'Castle Tower', ['Agahnim 1'], None), + create_cave_region(player, 'Old Man Cave', 'a connector', ['Old Man'], ['Old Man Cave Exit (East)', 'Old Man Cave Exit (West)']), + create_cave_region(player, 'Old Man House', 'a connector', None, ['Old Man House Exit (Bottom)', 'Old Man House Front to Back']), + create_cave_region(player, 'Old Man House Back', 'a connector', None, ['Old Man House Exit (Top)', 'Old Man House Back to Front']), + create_lw_region(player, 'Death Mountain', None, ['Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave', 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)', 'Broken Bridge (West)', 'Death Mountain Teleporter']), + create_cave_region(player, 'Death Mountain Return Cave', 'a connector', None, ['Death Mountain Return Cave Exit (West)', 'Death Mountain Return Cave Exit (East)']), + create_lw_region(player, 'Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)']), + create_cave_region(player, 'Spectacle Rock Cave (Top)', 'a connector', ['Spectacle Rock Cave'], ['Spectacle Rock Cave Drop', 'Spectacle Rock Cave Exit (Top)']), + create_cave_region(player, 'Spectacle Rock Cave (Bottom)', 'a connector', None, ['Spectacle Rock Cave Exit']), + create_cave_region(player, 'Spectacle Rock Cave (Peak)', 'a connector', None, ['Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave Exit (Peak)']), + create_lw_region(player, 'East Death Mountain (Bottom)', None, ['Broken Bridge (East)', 'Paradox Cave (Bottom)', 'Paradox Cave (Middle)', 'East Death Mountain Teleporter', 'Hookshot Fairy', 'Fairy Ascension Rocks', 'Spiral Cave (Bottom)']), + create_cave_region(player, 'Hookshot Fairy', 'fairies deep in a cave'), + create_cave_region(player, 'Paradox Cave Front', 'a connector', None, ['Paradox Cave Push Block Reverse', 'Paradox Cave Exit (Bottom)', 'Light World Death Mountain Shop']), + create_cave_region(player, 'Paradox Cave Chest Area', 'a connector', ['Paradox Cave Lower - Far Left', 'Paradox Cave Lower - Left', 'Paradox Cave Lower - Right', 'Paradox Cave Lower - Far Right', @@ -134,174 +134,174 @@ def create_regions(world): 'Paradox Cave Upper - Left', 'Paradox Cave Upper - Right'], ['Paradox Cave Push Block', 'Paradox Cave Bomb Jump']), - create_cave_region('Paradox Cave', 'a connector', None, ['Paradox Cave Exit (Middle)', 'Paradox Cave Exit (Top)', 'Paradox Cave Drop']), - create_cave_region('Light World Death Mountain Shop', 'a common shop'), - create_lw_region('East Death Mountain (Top)', None, ['Paradox Cave (Top)', 'Death Mountain (Top)', 'Spiral Cave Ledge Access', 'East Death Mountain Drop', 'Turtle Rock Teleporter', 'Fairy Ascension Ledge']), - create_lw_region('Spiral Cave Ledge', None, ['Spiral Cave', 'Spiral Cave Ledge Drop']), - create_cave_region('Spiral Cave (Top)', 'a connector', ['Spiral Cave'], ['Spiral Cave (top to bottom)', 'Spiral Cave Exit (Top)']), - create_cave_region('Spiral Cave (Bottom)', 'a connector', None, ['Spiral Cave Exit']), - create_lw_region('Fairy Ascension Plateau', None, ['Fairy Ascension Drop', 'Fairy Ascension Cave (Bottom)']), - create_cave_region('Fairy Ascension Cave (Bottom)', 'a connector', None, ['Fairy Ascension Cave Climb', 'Fairy Ascension Cave Exit (Bottom)']), - create_cave_region('Fairy Ascension Cave (Drop)', 'a connector', None, ['Fairy Ascension Cave Pots']), - create_cave_region('Fairy Ascension Cave (Top)', 'a connector', None, ['Fairy Ascension Cave Exit (Top)', 'Fairy Ascension Cave Drop']), - create_lw_region('Fairy Ascension Ledge', None, ['Fairy Ascension Ledge Drop', 'Fairy Ascension Cave (Top)']), - create_lw_region('Death Mountain (Top)', ['Ether Tablet'], ['East Death Mountain (Top)', 'Tower of Hera', 'Death Mountain Drop']), - create_lw_region('Spectacle Rock', ['Spectacle Rock'], ['Spectacle Rock Drop']), - create_dungeon_region('Tower of Hera (Bottom)', 'Tower of Hera', ['Tower of Hera - Basement Cage', 'Tower of Hera - Map Chest'], ['Tower of Hera Small Key Door', 'Tower of Hera Big Key Door', 'Tower of Hera Exit']), - create_dungeon_region('Tower of Hera (Basement)', 'Tower of Hera', ['Tower of Hera - Big Key Chest']), - create_dungeon_region('Tower of Hera (Top)', 'Tower of Hera', ['Tower of Hera - Compass Chest', 'Tower of Hera - Big Chest', 'Tower of Hera - Boss', 'Tower of Hera - Prize']), + create_cave_region(player, 'Paradox Cave', 'a connector', None, ['Paradox Cave Exit (Middle)', 'Paradox Cave Exit (Top)', 'Paradox Cave Drop']), + create_cave_region(player, 'Light World Death Mountain Shop', 'a common shop'), + create_lw_region(player, 'East Death Mountain (Top)', None, ['Paradox Cave (Top)', 'Death Mountain (Top)', 'Spiral Cave Ledge Access', 'East Death Mountain Drop', 'Turtle Rock Teleporter', 'Fairy Ascension Ledge']), + create_lw_region(player, 'Spiral Cave Ledge', None, ['Spiral Cave', 'Spiral Cave Ledge Drop']), + create_cave_region(player, 'Spiral Cave (Top)', 'a connector', ['Spiral Cave'], ['Spiral Cave (top to bottom)', 'Spiral Cave Exit (Top)']), + create_cave_region(player, 'Spiral Cave (Bottom)', 'a connector', None, ['Spiral Cave Exit']), + create_lw_region(player, 'Fairy Ascension Plateau', None, ['Fairy Ascension Drop', 'Fairy Ascension Cave (Bottom)']), + create_cave_region(player, 'Fairy Ascension Cave (Bottom)', 'a connector', None, ['Fairy Ascension Cave Climb', 'Fairy Ascension Cave Exit (Bottom)']), + create_cave_region(player, 'Fairy Ascension Cave (Drop)', 'a connector', None, ['Fairy Ascension Cave Pots']), + create_cave_region(player, 'Fairy Ascension Cave (Top)', 'a connector', None, ['Fairy Ascension Cave Exit (Top)', 'Fairy Ascension Cave Drop']), + create_lw_region(player, 'Fairy Ascension Ledge', None, ['Fairy Ascension Ledge Drop', 'Fairy Ascension Cave (Top)']), + create_lw_region(player, 'Death Mountain (Top)', ['Ether Tablet'], ['East Death Mountain (Top)', 'Tower of Hera', 'Death Mountain Drop']), + create_lw_region(player, 'Spectacle Rock', ['Spectacle Rock'], ['Spectacle Rock Drop']), + create_dungeon_region(player, 'Tower of Hera (Bottom)', 'Tower of Hera', ['Tower of Hera - Basement Cage', 'Tower of Hera - Map Chest'], ['Tower of Hera Small Key Door', 'Tower of Hera Big Key Door', 'Tower of Hera Exit']), + create_dungeon_region(player, 'Tower of Hera (Basement)', 'Tower of Hera', ['Tower of Hera - Big Key Chest']), + create_dungeon_region(player, 'Tower of Hera (Top)', 'Tower of Hera', ['Tower of Hera - Compass Chest', 'Tower of Hera - Big Chest', 'Tower of Hera - Boss', 'Tower of Hera - Prize']), - create_dw_region('East Dark World', ['Pyramid'], ['Pyramid Fairy', 'South Dark World Bridge', 'Palace of Darkness', 'Dark Lake Hylia Drop (East)', 'Dark Lake Hylia Teleporter', + create_dw_region(player, 'East Dark World', ['Pyramid'], ['Pyramid Fairy', 'South Dark World Bridge', 'Palace of Darkness', 'Dark Lake Hylia Drop (East)', 'Dark Lake Hylia Teleporter', 'Hyrule Castle Ledge Mirror Spot', 'Dark Lake Hylia Fairy', 'Palace of Darkness Hint', 'East Dark World Hint', 'Pyramid Hole', 'Northeast Dark World Broken Bridge Pass']), - create_dw_region('Northeast Dark World', ['Catfish'], ['West Dark World Gap', 'Dark World Potion Shop', 'East Dark World Broken Bridge Pass']), - create_cave_region('Palace of Darkness Hint', 'a storyteller'), - create_cave_region('East Dark World Hint', 'a storyteller'), - create_dw_region('South Dark World', ['Stumpy', 'Digging Game', 'Bombos Tablet'], ['Dark Lake Hylia Drop (South)', 'Hype Cave', 'Swamp Palace', 'Village of Outcasts Heavy Rock', 'Maze Race Mirror Spot', + create_dw_region(player, 'Northeast Dark World', ['Catfish'], ['West Dark World Gap', 'Dark World Potion Shop', 'East Dark World Broken Bridge Pass']), + create_cave_region(player, 'Palace of Darkness Hint', 'a storyteller'), + create_cave_region(player, 'East Dark World Hint', 'a storyteller'), + create_dw_region(player, 'South Dark World', ['Stumpy', 'Digging Game', 'Bombos Tablet'], ['Dark Lake Hylia Drop (South)', 'Hype Cave', 'Swamp Palace', 'Village of Outcasts Heavy Rock', 'Maze Race Mirror Spot', 'Cave 45 Mirror Spot', 'East Dark World Bridge', 'Big Bomb Shop', 'Archery Game', 'Bonk Fairy (Dark)', 'Dark Lake Hylia Shop']), - create_cave_region('Big Bomb Shop', 'the bomb shop'), - create_cave_region('Archery Game', 'a game of skill'), - create_dw_region('Dark Lake Hylia', None, ['Lake Hylia Island Mirror Spot', 'East Dark World Pier', 'Dark Lake Hylia Ledge']), - create_dw_region('Dark Lake Hylia Central Island', None, ['Ice Palace', 'Lake Hylia Central Island Mirror Spot']), - create_dw_region('Dark Lake Hylia Ledge', None, ['Dark Lake Hylia Ledge Drop', 'Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Spike Cave']), - create_cave_region('Dark Lake Hylia Ledge Hint', 'a storyteller'), - create_cave_region('Dark Lake Hylia Ledge Spike Cave', 'a spiky hint'), - create_cave_region('Hype Cave', 'a bounty of five items', ['Hype Cave - Top', 'Hype Cave - Middle Right', 'Hype Cave - Middle Left', + create_cave_region(player, 'Big Bomb Shop', 'the bomb shop'), + create_cave_region(player, 'Archery Game', 'a game of skill'), + create_dw_region(player, 'Dark Lake Hylia', None, ['Lake Hylia Island Mirror Spot', 'East Dark World Pier', 'Dark Lake Hylia Ledge']), + create_dw_region(player, 'Dark Lake Hylia Central Island', None, ['Ice Palace', 'Lake Hylia Central Island Mirror Spot']), + create_dw_region(player, 'Dark Lake Hylia Ledge', None, ['Dark Lake Hylia Ledge Drop', 'Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Spike Cave']), + create_cave_region(player, 'Dark Lake Hylia Ledge Hint', 'a storyteller'), + create_cave_region(player, 'Dark Lake Hylia Ledge Spike Cave', 'a spiky hint'), + create_cave_region(player, 'Hype Cave', 'a bounty of five items', ['Hype Cave - Top', 'Hype Cave - Middle Right', 'Hype Cave - Middle Left', 'Hype Cave - Bottom', 'Hype Cave - Generous Guy']), - create_dw_region('West Dark World', ['Frog'], ['Village of Outcasts Drop', 'East Dark World River Pier', 'Brewery', 'C-Shaped House', 'Chest Game', 'Thieves Town', 'Graveyard Ledge Mirror Spot', 'Kings Grave Mirror Spot', 'Bumper Cave Entrance Rock', + create_dw_region(player, 'West Dark World', ['Frog'], ['Village of Outcasts Drop', 'East Dark World River Pier', 'Brewery', 'C-Shaped House', 'Chest Game', 'Thieves Town', 'Graveyard Ledge Mirror Spot', 'Kings Grave Mirror Spot', 'Bumper Cave Entrance Rock', 'Skull Woods Forest', 'Village of Outcasts Pegs', 'Village of Outcasts Eastern Rocks', 'Red Shield Shop', 'Dark Sanctuary Hint', 'Fortune Teller (Dark)', 'Dark World Lumberjack Shop']), - create_dw_region('Dark Grassy Lawn', None, ['Grassy Lawn Pegs', 'Dark World Shop']), - create_dw_region('Hammer Peg Area', ['Dark Blacksmith Ruins'], ['Bat Cave Drop Ledge Mirror Spot', 'Dark World Hammer Peg Cave', 'Peg Area Rocks']), - create_dw_region('Bumper Cave Entrance', None, ['Bumper Cave (Bottom)', 'Bumper Cave Entrance Mirror Spot', 'Bumper Cave Entrance Drop']), - create_cave_region('Fortune Teller (Dark)', 'a fortune teller'), - create_cave_region('Village of Outcasts Shop', 'a common shop'), - create_cave_region('Dark Lake Hylia Shop', 'a common shop'), - create_cave_region('Dark World Lumberjack Shop', 'a common shop'), - create_cave_region('Dark World Potion Shop', 'a common shop'), - create_cave_region('Dark World Hammer Peg Cave', 'a cave with an item', ['Peg Cave']), - create_cave_region('Pyramid Fairy', 'a cave with two chests', ['Pyramid Fairy - Left', 'Pyramid Fairy - Right']), - create_cave_region('Brewery', 'a house with a chest', ['Brewery']), - create_cave_region('C-Shaped House', 'a house with a chest', ['C-Shaped House']), - create_cave_region('Chest Game', 'a game of 16 chests', ['Chest Game']), - create_cave_region('Red Shield Shop', 'the rare shop'), - create_cave_region('Dark Sanctuary Hint', 'a storyteller'), - create_cave_region('Bumper Cave', 'a connector', None, ['Bumper Cave Exit (Bottom)', 'Bumper Cave Exit (Top)']), - create_dw_region('Bumper Cave Ledge', ['Bumper Cave Ledge'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)', 'Bumper Cave Ledge Mirror Spot']), - create_dw_region('Skull Woods Forest', None, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', + create_dw_region(player, 'Dark Grassy Lawn', None, ['Grassy Lawn Pegs', 'Dark World Shop']), + create_dw_region(player, 'Hammer Peg Area', ['Dark Blacksmith Ruins'], ['Bat Cave Drop Ledge Mirror Spot', 'Dark World Hammer Peg Cave', 'Peg Area Rocks']), + create_dw_region(player, 'Bumper Cave Entrance', None, ['Bumper Cave (Bottom)', 'Bumper Cave Entrance Mirror Spot', 'Bumper Cave Entrance Drop']), + create_cave_region(player, 'Fortune Teller (Dark)', 'a fortune teller'), + create_cave_region(player, 'Village of Outcasts Shop', 'a common shop'), + create_cave_region(player, 'Dark Lake Hylia Shop', 'a common shop'), + create_cave_region(player, 'Dark World Lumberjack Shop', 'a common shop'), + create_cave_region(player, 'Dark World Potion Shop', 'a common shop'), + create_cave_region(player, 'Dark World Hammer Peg Cave', 'a cave with an item', ['Peg Cave']), + create_cave_region(player, 'Pyramid Fairy', 'a cave with two chests', ['Pyramid Fairy - Left', 'Pyramid Fairy - Right']), + create_cave_region(player, 'Brewery', 'a house with a chest', ['Brewery']), + create_cave_region(player, 'C-Shaped House', 'a house with a chest', ['C-Shaped House']), + create_cave_region(player, 'Chest Game', 'a game of 16 chests', ['Chest Game']), + create_cave_region(player, 'Red Shield Shop', 'the rare shop'), + create_cave_region(player, 'Dark Sanctuary Hint', 'a storyteller'), + create_cave_region(player, 'Bumper Cave', 'a connector', None, ['Bumper Cave Exit (Bottom)', 'Bumper Cave Exit (Top)']), + create_dw_region(player, 'Bumper Cave Ledge', ['Bumper Cave Ledge'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)', 'Bumper Cave Ledge Mirror Spot']), + create_dw_region(player, 'Skull Woods Forest', None, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', 'Skull Woods First Section Door', 'Skull Woods Second Section Door (East)']), - create_dw_region('Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section']), - create_dw_region('Dark Desert', None, ['Misery Mire', 'Mire Shed', 'Desert Ledge (Northeast) Mirror Spot', 'Desert Ledge Mirror Spot', 'Desert Palace Stairs Mirror Spot', + create_dw_region(player, 'Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section']), + create_dw_region(player, 'Dark Desert', None, ['Misery Mire', 'Mire Shed', 'Desert Ledge (Northeast) Mirror Spot', 'Desert Ledge Mirror Spot', 'Desert Palace Stairs Mirror Spot', 'Desert Palace Entrance (North) Mirror Spot', 'Dark Desert Hint', 'Dark Desert Fairy']), - create_cave_region('Mire Shed', 'a cave with two chests', ['Mire Shed - Left', 'Mire Shed - Right']), - create_cave_region('Dark Desert Hint', 'a storyteller'), - create_dw_region('Dark Death Mountain (West Bottom)', None, ['Spike Cave', 'Spectacle Rock Mirror Spot', 'Dark Death Mountain Fairy']), - create_dw_region('Dark Death Mountain (Top)', None, ['Dark Death Mountain Drop (East)', 'Dark Death Mountain Drop (West)', 'Ganons Tower', 'Superbunny Cave (Top)', + create_cave_region(player, 'Mire Shed', 'a cave with two chests', ['Mire Shed - Left', 'Mire Shed - Right']), + create_cave_region(player, 'Dark Desert Hint', 'a storyteller'), + create_dw_region(player, 'Dark Death Mountain (West Bottom)', None, ['Spike Cave', 'Spectacle Rock Mirror Spot', 'Dark Death Mountain Fairy']), + create_dw_region(player, 'Dark Death Mountain (Top)', None, ['Dark Death Mountain Drop (East)', 'Dark Death Mountain Drop (West)', 'Ganons Tower', 'Superbunny Cave (Top)', 'Hookshot Cave', 'East Death Mountain (Top) Mirror Spot', 'Turtle Rock']), - create_dw_region('Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)', 'Mimic Cave Mirror Spot', 'Spiral Cave Mirror Spot']), - create_dw_region('Dark Death Mountain Isolated Ledge', None, ['Isolated Ledge Mirror Spot', 'Turtle Rock Isolated Ledge Entrance']), - create_dw_region('Dark Death Mountain (East Bottom)', None, ['Superbunny Cave (Bottom)', 'Cave Shop (Dark Death Mountain)', 'Fairy Ascension Mirror Spot']), - create_cave_region('Superbunny Cave', 'a connector', ['Superbunny Cave - Top', 'Superbunny Cave - Bottom'], + create_dw_region(player, 'Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)', 'Mimic Cave Mirror Spot', 'Spiral Cave Mirror Spot']), + create_dw_region(player, 'Dark Death Mountain Isolated Ledge', None, ['Isolated Ledge Mirror Spot', 'Turtle Rock Isolated Ledge Entrance']), + create_dw_region(player, 'Dark Death Mountain (East Bottom)', None, ['Superbunny Cave (Bottom)', 'Cave Shop (Dark Death Mountain)', 'Fairy Ascension Mirror Spot']), + create_cave_region(player, 'Superbunny Cave', 'a connector', ['Superbunny Cave - Top', 'Superbunny Cave - Bottom'], ['Superbunny Cave Exit (Top)', 'Superbunny Cave Exit (Bottom)']), - create_cave_region('Spike Cave', 'Spike Cave', ['Spike Cave']), - create_cave_region('Hookshot Cave', 'a connector', ['Hookshot Cave - Top Right', 'Hookshot Cave - Top Left', 'Hookshot Cave - Bottom Right', 'Hookshot Cave - Bottom Left'], + create_cave_region(player, 'Spike Cave', 'Spike Cave', ['Spike Cave']), + create_cave_region(player, 'Hookshot Cave', 'a connector', ['Hookshot Cave - Top Right', 'Hookshot Cave - Top Left', 'Hookshot Cave - Bottom Right', 'Hookshot Cave - Bottom Left'], ['Hookshot Cave Exit (South)', 'Hookshot Cave Exit (North)']), - create_dw_region('Death Mountain Floating Island (Dark World)', None, ['Floating Island Drop', 'Hookshot Cave Back Entrance', 'Floating Island Mirror Spot']), - create_lw_region('Death Mountain Floating Island (Light World)', ['Floating Island']), - create_dw_region('Turtle Rock (Top)', None, ['Turtle Rock Drop']), - create_lw_region('Mimic Cave Ledge', None, ['Mimic Cave']), - create_cave_region('Mimic Cave', 'Mimic Cave', ['Mimic Cave']), + create_dw_region(player, 'Death Mountain Floating Island (Dark World)', None, ['Floating Island Drop', 'Hookshot Cave Back Entrance', 'Floating Island Mirror Spot']), + create_lw_region(player, 'Death Mountain Floating Island (Light World)', ['Floating Island']), + create_dw_region(player, 'Turtle Rock (Top)', None, ['Turtle Rock Drop']), + create_lw_region(player, 'Mimic Cave Ledge', None, ['Mimic Cave']), + create_cave_region(player, 'Mimic Cave', 'Mimic Cave', ['Mimic Cave']), - create_dungeon_region('Swamp Palace (Entrance)', 'Swamp Palace', None, ['Swamp Palace Moat', 'Swamp Palace Exit']), - create_dungeon_region('Swamp Palace (First Room)', 'Swamp Palace', ['Swamp Palace - Entrance'], ['Swamp Palace Small Key Door']), - create_dungeon_region('Swamp Palace (Starting Area)', 'Swamp Palace', ['Swamp Palace - Map Chest'], ['Swamp Palace (Center)']), - create_dungeon_region('Swamp Palace (Center)', 'Swamp Palace', ['Swamp Palace - Big Chest', 'Swamp Palace - Compass Chest', + create_dungeon_region(player, 'Swamp Palace (Entrance)', 'Swamp Palace', None, ['Swamp Palace Moat', 'Swamp Palace Exit']), + create_dungeon_region(player, 'Swamp Palace (First Room)', 'Swamp Palace', ['Swamp Palace - Entrance'], ['Swamp Palace Small Key Door']), + create_dungeon_region(player, 'Swamp Palace (Starting Area)', 'Swamp Palace', ['Swamp Palace - Map Chest'], ['Swamp Palace (Center)']), + create_dungeon_region(player, 'Swamp Palace (Center)', 'Swamp Palace', ['Swamp Palace - Big Chest', 'Swamp Palace - Compass Chest', 'Swamp Palace - Big Key Chest', 'Swamp Palace - West Chest'], ['Swamp Palace (North)']), - create_dungeon_region('Swamp Palace (North)', 'Swamp Palace', ['Swamp Palace - Flooded Room - Left', 'Swamp Palace - Flooded Room - Right', + create_dungeon_region(player, 'Swamp Palace (North)', 'Swamp Palace', ['Swamp Palace - Flooded Room - Left', 'Swamp Palace - Flooded Room - Right', 'Swamp Palace - Waterfall Room', 'Swamp Palace - Boss', 'Swamp Palace - Prize']), - create_dungeon_region('Thieves Town (Entrance)', 'Thieves\' Town', ['Thieves\' Town - Big Key Chest', + create_dungeon_region(player, 'Thieves Town (Entrance)', 'Thieves\' Town', ['Thieves\' Town - Big Key Chest', 'Thieves\' Town - Map Chest', 'Thieves\' Town - Compass Chest', 'Thieves\' Town - Ambush Chest'], ['Thieves Town Big Key Door', 'Thieves Town Exit']), - create_dungeon_region('Thieves Town (Deep)', 'Thieves\' Town', ['Thieves\' Town - Attic', + create_dungeon_region(player, 'Thieves Town (Deep)', 'Thieves\' Town', ['Thieves\' Town - Attic', 'Thieves\' Town - Big Chest', 'Thieves\' Town - Blind\'s Cell'], ['Blind Fight']), - create_dungeon_region('Blind Fight', 'Thieves\' Town', ['Thieves\' Town - Boss', 'Thieves\' Town - Prize']), - create_dungeon_region('Skull Woods First Section', 'Skull Woods', ['Skull Woods - Map Chest'], ['Skull Woods First Section Exit', 'Skull Woods First Section Bomb Jump', 'Skull Woods First Section South Door', 'Skull Woods First Section West Door']), - create_dungeon_region('Skull Woods First Section (Right)', 'Skull Woods', ['Skull Woods - Pinball Room'], ['Skull Woods First Section (Right) North Door']), - create_dungeon_region('Skull Woods First Section (Left)', 'Skull Woods', ['Skull Woods - Compass Chest', 'Skull Woods - Pot Prison'], ['Skull Woods First Section (Left) Door to Exit', 'Skull Woods First Section (Left) Door to Right']), - create_dungeon_region('Skull Woods First Section (Top)', 'Skull Woods', ['Skull Woods - Big Chest'], ['Skull Woods First Section (Top) One-Way Path']), - create_dungeon_region('Skull Woods Second Section (Drop)', 'Skull Woods', None, ['Skull Woods Second Section (Drop)']), - create_dungeon_region('Skull Woods Second Section', 'Skull Woods', ['Skull Woods - Big Key Chest'], ['Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)']), - create_dungeon_region('Skull Woods Final Section (Entrance)', 'Skull Woods', ['Skull Woods - Bridge Room'], ['Skull Woods Torch Room', 'Skull Woods Final Section Exit']), - create_dungeon_region('Skull Woods Final Section (Mothula)', 'Skull Woods', ['Skull Woods - Boss', 'Skull Woods - Prize']), - create_dungeon_region('Ice Palace (Entrance)', 'Ice Palace', None, ['Ice Palace Entrance Room', 'Ice Palace Exit']), - create_dungeon_region('Ice Palace (Main)', 'Ice Palace', ['Ice Palace - Compass Chest', 'Ice Palace - Freezor Chest', + create_dungeon_region(player, 'Blind Fight', 'Thieves\' Town', ['Thieves\' Town - Boss', 'Thieves\' Town - Prize']), + create_dungeon_region(player, 'Skull Woods First Section', 'Skull Woods', ['Skull Woods - Map Chest'], ['Skull Woods First Section Exit', 'Skull Woods First Section Bomb Jump', 'Skull Woods First Section South Door', 'Skull Woods First Section West Door']), + create_dungeon_region(player, 'Skull Woods First Section (Right)', 'Skull Woods', ['Skull Woods - Pinball Room'], ['Skull Woods First Section (Right) North Door']), + create_dungeon_region(player, 'Skull Woods First Section (Left)', 'Skull Woods', ['Skull Woods - Compass Chest', 'Skull Woods - Pot Prison'], ['Skull Woods First Section (Left) Door to Exit', 'Skull Woods First Section (Left) Door to Right']), + create_dungeon_region(player, 'Skull Woods First Section (Top)', 'Skull Woods', ['Skull Woods - Big Chest'], ['Skull Woods First Section (Top) One-Way Path']), + create_dungeon_region(player, 'Skull Woods Second Section (Drop)', 'Skull Woods', None, ['Skull Woods Second Section (Drop)']), + create_dungeon_region(player, 'Skull Woods Second Section', 'Skull Woods', ['Skull Woods - Big Key Chest'], ['Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)']), + create_dungeon_region(player, 'Skull Woods Final Section (Entrance)', 'Skull Woods', ['Skull Woods - Bridge Room'], ['Skull Woods Torch Room', 'Skull Woods Final Section Exit']), + create_dungeon_region(player, 'Skull Woods Final Section (Mothula)', 'Skull Woods', ['Skull Woods - Boss', 'Skull Woods - Prize']), + create_dungeon_region(player, 'Ice Palace (Entrance)', 'Ice Palace', None, ['Ice Palace Entrance Room', 'Ice Palace Exit']), + create_dungeon_region(player, 'Ice Palace (Main)', 'Ice Palace', ['Ice Palace - Compass Chest', 'Ice Palace - Freezor Chest', 'Ice Palace - Big Chest', 'Ice Palace - Iced T Room'], ['Ice Palace (East)', 'Ice Palace (Kholdstare)']), - create_dungeon_region('Ice Palace (East)', 'Ice Palace', ['Ice Palace - Spike Room'], ['Ice Palace (East Top)']), - create_dungeon_region('Ice Palace (East Top)', 'Ice Palace', ['Ice Palace - Big Key Chest', 'Ice Palace - Map Chest']), - create_dungeon_region('Ice Palace (Kholdstare)', 'Ice Palace', ['Ice Palace - Boss', 'Ice Palace - Prize']), - create_dungeon_region('Misery Mire (Entrance)', 'Misery Mire', None, ['Misery Mire Entrance Gap', 'Misery Mire Exit']), - create_dungeon_region('Misery Mire (Main)', 'Misery Mire', ['Misery Mire - Big Chest', 'Misery Mire - Map Chest', 'Misery Mire - Main Lobby', + create_dungeon_region(player, 'Ice Palace (East)', 'Ice Palace', ['Ice Palace - Spike Room'], ['Ice Palace (East Top)']), + create_dungeon_region(player, 'Ice Palace (East Top)', 'Ice Palace', ['Ice Palace - Big Key Chest', 'Ice Palace - Map Chest']), + create_dungeon_region(player, 'Ice Palace (Kholdstare)', 'Ice Palace', ['Ice Palace - Boss', 'Ice Palace - Prize']), + create_dungeon_region(player, 'Misery Mire (Entrance)', 'Misery Mire', None, ['Misery Mire Entrance Gap', 'Misery Mire Exit']), + create_dungeon_region(player, 'Misery Mire (Main)', 'Misery Mire', ['Misery Mire - Big Chest', 'Misery Mire - Map Chest', 'Misery Mire - Main Lobby', 'Misery Mire - Bridge Chest', 'Misery Mire - Spike Chest'], ['Misery Mire (West)', 'Misery Mire Big Key Door']), - create_dungeon_region('Misery Mire (West)', 'Misery Mire', ['Misery Mire - Compass Chest', 'Misery Mire - Big Key Chest']), - create_dungeon_region('Misery Mire (Final Area)', 'Misery Mire', None, ['Misery Mire (Vitreous)']), - create_dungeon_region('Misery Mire (Vitreous)', 'Misery Mire', ['Misery Mire - Boss', 'Misery Mire - Prize']), - create_dungeon_region('Turtle Rock (Entrance)', 'Turtle Rock', None, ['Turtle Rock Entrance Gap', 'Turtle Rock Exit (Front)']), - create_dungeon_region('Turtle Rock (First Section)', 'Turtle Rock', ['Turtle Rock - Compass Chest', 'Turtle Rock - Roller Room - Left', + create_dungeon_region(player, 'Misery Mire (West)', 'Misery Mire', ['Misery Mire - Compass Chest', 'Misery Mire - Big Key Chest']), + create_dungeon_region(player, 'Misery Mire (Final Area)', 'Misery Mire', None, ['Misery Mire (Vitreous)']), + create_dungeon_region(player, 'Misery Mire (Vitreous)', 'Misery Mire', ['Misery Mire - Boss', 'Misery Mire - Prize']), + create_dungeon_region(player, 'Turtle Rock (Entrance)', 'Turtle Rock', None, ['Turtle Rock Entrance Gap', 'Turtle Rock Exit (Front)']), + create_dungeon_region(player, 'Turtle Rock (First Section)', 'Turtle Rock', ['Turtle Rock - Compass Chest', 'Turtle Rock - Roller Room - Left', 'Turtle Rock - Roller Room - Right'], ['Turtle Rock Pokey Room', 'Turtle Rock Entrance Gap Reverse']), - create_dungeon_region('Turtle Rock (Chain Chomp Room)', 'Turtle Rock', ['Turtle Rock - Chain Chomps'], ['Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)']), - create_dungeon_region('Turtle Rock (Second Section)', 'Turtle Rock', ['Turtle Rock - Big Key Chest'], ['Turtle Rock Ledge Exit (West)', 'Turtle Rock Chain Chomp Staircase', 'Turtle Rock Big Key Door']), - create_dungeon_region('Turtle Rock (Big Chest)', 'Turtle Rock', ['Turtle Rock - Big Chest'], ['Turtle Rock (Big Chest) (North)', 'Turtle Rock Ledge Exit (East)']), - create_dungeon_region('Turtle Rock (Crystaroller Room)', 'Turtle Rock', ['Turtle Rock - Crystaroller Room'], ['Turtle Rock Dark Room Staircase', 'Turtle Rock Big Key Door Reverse']), - create_dungeon_region('Turtle Rock (Dark Room)', 'Turtle Rock', None, ['Turtle Rock (Dark Room) (North)', 'Turtle Rock (Dark Room) (South)']), - create_dungeon_region('Turtle Rock (Eye Bridge)', 'Turtle Rock', ['Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', + create_dungeon_region(player, 'Turtle Rock (Chain Chomp Room)', 'Turtle Rock', ['Turtle Rock - Chain Chomps'], ['Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)']), + create_dungeon_region(player, 'Turtle Rock (Second Section)', 'Turtle Rock', ['Turtle Rock - Big Key Chest'], ['Turtle Rock Ledge Exit (West)', 'Turtle Rock Chain Chomp Staircase', 'Turtle Rock Big Key Door']), + create_dungeon_region(player, 'Turtle Rock (Big Chest)', 'Turtle Rock', ['Turtle Rock - Big Chest'], ['Turtle Rock (Big Chest) (North)', 'Turtle Rock Ledge Exit (East)']), + create_dungeon_region(player, 'Turtle Rock (Crystaroller Room)', 'Turtle Rock', ['Turtle Rock - Crystaroller Room'], ['Turtle Rock Dark Room Staircase', 'Turtle Rock Big Key Door Reverse']), + create_dungeon_region(player, 'Turtle Rock (Dark Room)', 'Turtle Rock', None, ['Turtle Rock (Dark Room) (North)', 'Turtle Rock (Dark Room) (South)']), + create_dungeon_region(player, 'Turtle Rock (Eye Bridge)', 'Turtle Rock', ['Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'], ['Turtle Rock Dark Room (South)', 'Turtle Rock (Trinexx)', 'Turtle Rock Isolated Ledge Exit']), - create_dungeon_region('Turtle Rock (Trinexx)', 'Turtle Rock', ['Turtle Rock - Boss', 'Turtle Rock - Prize']), - create_dungeon_region('Palace of Darkness (Entrance)', 'Palace of Darkness', ['Palace of Darkness - Shooter Room'], ['Palace of Darkness Bridge Room', 'Palace of Darkness Bonk Wall', 'Palace of Darkness Exit']), - create_dungeon_region('Palace of Darkness (Center)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Bridge', 'Palace of Darkness - Stalfos Basement'], + create_dungeon_region(player, 'Turtle Rock (Trinexx)', 'Turtle Rock', ['Turtle Rock - Boss', 'Turtle Rock - Prize']), + create_dungeon_region(player, 'Palace of Darkness (Entrance)', 'Palace of Darkness', ['Palace of Darkness - Shooter Room'], ['Palace of Darkness Bridge Room', 'Palace of Darkness Bonk Wall', 'Palace of Darkness Exit']), + create_dungeon_region(player, 'Palace of Darkness (Center)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Bridge', 'Palace of Darkness - Stalfos Basement'], ['Palace of Darkness Big Key Chest Staircase', 'Palace of Darkness (North)', 'Palace of Darkness Big Key Door']), - create_dungeon_region('Palace of Darkness (Big Key Chest)', 'Palace of Darkness', ['Palace of Darkness - Big Key Chest']), - create_dungeon_region('Palace of Darkness (Bonk Section)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Ledge', 'Palace of Darkness - Map Chest'], ['Palace of Darkness Hammer Peg Drop']), - create_dungeon_region('Palace of Darkness (North)', 'Palace of Darkness', ['Palace of Darkness - Compass Chest', 'Palace of Darkness - Dark Basement - Left', 'Palace of Darkness - Dark Basement - Right'], + create_dungeon_region(player, 'Palace of Darkness (Big Key Chest)', 'Palace of Darkness', ['Palace of Darkness - Big Key Chest']), + create_dungeon_region(player, 'Palace of Darkness (Bonk Section)', 'Palace of Darkness', ['Palace of Darkness - The Arena - Ledge', 'Palace of Darkness - Map Chest'], ['Palace of Darkness Hammer Peg Drop']), + create_dungeon_region(player, 'Palace of Darkness (North)', 'Palace of Darkness', ['Palace of Darkness - Compass Chest', 'Palace of Darkness - Dark Basement - Left', 'Palace of Darkness - Dark Basement - Right'], ['Palace of Darkness Spike Statue Room Door', 'Palace of Darkness Maze Door']), - create_dungeon_region('Palace of Darkness (Maze)', 'Palace of Darkness', ['Palace of Darkness - Dark Maze - Top', 'Palace of Darkness - Dark Maze - Bottom', 'Palace of Darkness - Big Chest']), - create_dungeon_region('Palace of Darkness (Harmless Hellway)', 'Palace of Darkness', ['Palace of Darkness - Harmless Hellway']), - create_dungeon_region('Palace of Darkness (Final Section)', 'Palace of Darkness', ['Palace of Darkness - Boss', 'Palace of Darkness - Prize']), - create_dungeon_region('Ganons Tower (Entrance)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Torch', 'Ganons Tower - Hope Room - Left', 'Ganons Tower - Hope Room - Right'], + create_dungeon_region(player, 'Palace of Darkness (Maze)', 'Palace of Darkness', ['Palace of Darkness - Dark Maze - Top', 'Palace of Darkness - Dark Maze - Bottom', 'Palace of Darkness - Big Chest']), + create_dungeon_region(player, 'Palace of Darkness (Harmless Hellway)', 'Palace of Darkness', ['Palace of Darkness - Harmless Hellway']), + create_dungeon_region(player, 'Palace of Darkness (Final Section)', 'Palace of Darkness', ['Palace of Darkness - Boss', 'Palace of Darkness - Prize']), + create_dungeon_region(player, 'Ganons Tower (Entrance)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Torch', 'Ganons Tower - Hope Room - Left', 'Ganons Tower - Hope Room - Right'], ['Ganons Tower (Tile Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower Big Key Door', 'Ganons Tower Exit']), - create_dungeon_region('Ganons Tower (Tile Room)', 'Ganon\'s Tower', ['Ganons Tower - Tile Room'], ['Ganons Tower (Tile Room) Key Door']), - create_dungeon_region('Ganons Tower (Compass Room)', 'Ganon\'s Tower', ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', + create_dungeon_region(player, 'Ganons Tower (Tile Room)', 'Ganon\'s Tower', ['Ganons Tower - Tile Room'], ['Ganons Tower (Tile Room) Key Door']), + create_dungeon_region(player, 'Ganons Tower (Compass Room)', 'Ganon\'s Tower', ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', 'Ganons Tower - Compass Room - Bottom Left', 'Ganons Tower - Compass Room - Bottom Right'], ['Ganons Tower (Bottom) (East)']), - create_dungeon_region('Ganons Tower (Hookshot Room)', 'Ganon\'s Tower', ['Ganons Tower - DMs Room - Top Left', 'Ganons Tower - DMs Room - Top Right', + create_dungeon_region(player, 'Ganons Tower (Hookshot Room)', 'Ganon\'s Tower', ['Ganons Tower - DMs Room - Top Left', 'Ganons Tower - DMs Room - Top Right', 'Ganons Tower - DMs Room - Bottom Left', 'Ganons Tower - DMs Room - Bottom Right'], ['Ganons Tower (Map Room)', 'Ganons Tower (Double Switch Room)']), - create_dungeon_region('Ganons Tower (Map Room)', 'Ganon\'s Tower', ['Ganons Tower - Map Chest']), - create_dungeon_region('Ganons Tower (Firesnake Room)', 'Ganon\'s Tower', ['Ganons Tower - Firesnake Room'], ['Ganons Tower (Firesnake Room)']), - create_dungeon_region('Ganons Tower (Teleport Room)', 'Ganon\'s Tower', ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', + create_dungeon_region(player, 'Ganons Tower (Map Room)', 'Ganon\'s Tower', ['Ganons Tower - Map Chest']), + create_dungeon_region(player, 'Ganons Tower (Firesnake Room)', 'Ganon\'s Tower', ['Ganons Tower - Firesnake Room'], ['Ganons Tower (Firesnake Room)']), + create_dungeon_region(player, 'Ganons Tower (Teleport Room)', 'Ganon\'s Tower', ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', 'Ganons Tower - Randomizer Room - Bottom Left', 'Ganons Tower - Randomizer Room - Bottom Right'], ['Ganons Tower (Bottom) (West)']), - create_dungeon_region('Ganons Tower (Bottom)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Chest', 'Ganons Tower - Big Chest', 'Ganons Tower - Big Key Room - Left', + create_dungeon_region(player, 'Ganons Tower (Bottom)', 'Ganon\'s Tower', ['Ganons Tower - Bob\'s Chest', 'Ganons Tower - Big Chest', 'Ganons Tower - Big Key Room - Left', 'Ganons Tower - Big Key Room - Right', 'Ganons Tower - Big Key Chest']), - create_dungeon_region('Ganons Tower (Top)', 'Ganon\'s Tower', None, ['Ganons Tower Torch Rooms']), - create_dungeon_region('Ganons Tower (Before Moldorm)', 'Ganon\'s Tower', ['Ganons Tower - Mini Helmasaur Room - Left', 'Ganons Tower - Mini Helmasaur Room - Right', + create_dungeon_region(player, 'Ganons Tower (Top)', 'Ganon\'s Tower', None, ['Ganons Tower Torch Rooms']), + create_dungeon_region(player, 'Ganons Tower (Before Moldorm)', 'Ganon\'s Tower', ['Ganons Tower - Mini Helmasaur Room - Left', 'Ganons Tower - Mini Helmasaur Room - Right', 'Ganons Tower - Pre-Moldorm Chest'], ['Ganons Tower Moldorm Door']), - create_dungeon_region('Ganons Tower (Moldorm)', 'Ganon\'s Tower', None, ['Ganons Tower Moldorm Gap']), - create_dungeon_region('Agahnim 2', 'Ganon\'s Tower', ['Ganons Tower - Validation Chest', 'Agahnim 2'], None), - create_cave_region('Pyramid', 'a drop\'s exit', ['Ganon'], ['Ganon Drop']), - create_cave_region('Bottom of Pyramid', 'a drop\'s exit', None, ['Pyramid Exit']), - create_dw_region('Pyramid Ledge', None, ['Pyramid Entrance', 'Pyramid Drop']) + create_dungeon_region(player, 'Ganons Tower (Moldorm)', 'Ganon\'s Tower', None, ['Ganons Tower Moldorm Gap']), + create_dungeon_region(player, 'Agahnim 2', 'Ganon\'s Tower', ['Ganons Tower - Validation Chest', 'Agahnim 2'], None), + create_cave_region(player, 'Pyramid', 'a drop\'s exit', ['Ganon'], ['Ganon Drop']), + create_cave_region(player, 'Bottom of Pyramid', 'a drop\'s exit', None, ['Pyramid Exit']), + create_dw_region(player, 'Pyramid Ledge', None, ['Pyramid Entrance', 'Pyramid Drop']) ] for region_name, (room_id, shopkeeper, replaceable) in shop_table.items(): - region = world.get_region(region_name) + region = world.get_region(region_name, player) shop = Shop(region, room_id, ShopType.Shop, shopkeeper, replaceable) region.shop = shop world.shops.append(shop) for index, (item, price) in enumerate(default_shop_contents[region_name]): shop.add_inventory(index, item, price) - region = world.get_region('Capacity Upgrade') + region = world.get_region('Capacity Upgrade', player) shop = Shop(region, 0x0115, ShopType.UpgradeShop, 0x04, True) region.shop = shop world.shops.append(shop) @@ -309,30 +309,30 @@ def create_regions(world): shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7) world.intialize_regions() -def create_lw_region(name, locations=None, exits=None): - return _create_region(name, RegionType.LightWorld, 'Light World', locations, exits) +def create_lw_region(player, name, locations=None, exits=None): + return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits) -def create_dw_region(name, locations=None, exits=None): - return _create_region(name, RegionType.DarkWorld, 'Dark World', locations, exits) +def create_dw_region(player, name, locations=None, exits=None): + return _create_region(player, name, RegionType.DarkWorld, 'Dark World', locations, exits) -def create_cave_region(name, hint='Hyrule', locations=None, exits=None): - return _create_region(name, RegionType.Cave, hint, locations, exits) +def create_cave_region(player, name, hint='Hyrule', locations=None, exits=None): + return _create_region(player, name, RegionType.Cave, hint, locations, exits) -def create_dungeon_region(name, hint='Hyrule', locations=None, exits=None): - return _create_region(name, RegionType.Dungeon, hint, locations, exits) +def create_dungeon_region(player, name, hint='Hyrule', locations=None, exits=None): + return _create_region(player, name, RegionType.Dungeon, hint, locations, exits) -def _create_region(name, type, hint='Hyrule', locations=None, exits=None): - ret = Region(name, type, hint) +def _create_region(player, name, type, hint='Hyrule', locations=None, exits=None): + ret = Region(name, type, hint, player) if locations is None: locations = [] if exits is None: exits = [] for exit in exits: - ret.exits.append(Entrance(exit, ret)) + ret.exits.append(Entrance(player, exit, ret)) for location in locations: address, crystal, hint_text = location_table[location] - ret.locations.append(Location(location, address, crystal, hint_text, ret)) + ret.locations.append(Location(player, location, address, crystal, hint_text, ret)) return ret def mark_light_world_regions(world): @@ -398,221 +398,221 @@ default_shop_contents = { } location_table = {'Mushroom': (0x180013, False, 'in the woods'), - 'Bottle Merchant': (0x2EB18, False, 'with a merchant'), - 'Flute Spot': (0x18014A, False, 'underground'), + 'Bottle Merchant': (0x2eb18, False, 'with a merchant'), + 'Flute Spot': (0x18014a, False, 'underground'), 'Sunken Treasure': (0x180145, False, 'underwater'), - 'Purple Chest': (0x33D68, False, 'from a box'), - 'Blind\'s Hideout - Top': (0xEB0F, False, 'in a basement'), - 'Blind\'s Hideout - Left': (0xEB12, False, 'in a basement'), - 'Blind\'s Hideout - Right': (0xEB15, False, 'in a basement'), - 'Blind\'s Hideout - Far Left': (0xEB18, False, 'in a basement'), - 'Blind\'s Hideout - Far Right': (0xEB1B, False, 'in a basement'), - 'Link\'s Uncle': (0x2DF45, False, 'with your uncle'), - 'Secret Passage': (0xE971, False, 'near your uncle'), - 'King Zora': (0xEE1C3, False, 'at a high price'), - 'Zora\'s Ledge': (0x180149, False, 'near Zora'), - 'Waterfall Fairy - Left': (0xE9B0, False, 'near a fairy'), - 'Waterfall Fairy - Right': (0xE9D1, False, 'near a fairy'), - 'King\'s Tomb': (0xE97A, False, 'alone in a cave'), - 'Floodgate Chest': (0xE98C, False, 'in the dam'), - 'Link\'s House': (0xE9BC, False, 'in your home'), - 'Kakariko Tavern': (0xE9CE, False, 'in the bar'), - 'Chicken House': (0xE9E9, False, 'near poultry'), - 'Aginah\'s Cave': (0xE9F2, False, 'with Aginah'), - 'Sahasrahla\'s Hut - Left': (0xEA82, False, 'near the elder'), - 'Sahasrahla\'s Hut - Middle': (0xEA85, False, 'near the elder'), - 'Sahasrahla\'s Hut - Right': (0xEA88, False, 'near the elder'), - 'Sahasrahla': (0x2F1FC, False, 'with the elder'), - 'Kakariko Well - Top': (0xEA8E, False, 'in a well'), - 'Kakariko Well - Left': (0xEA91, False, 'in a well'), - 'Kakariko Well - Middle': (0xEA94, False, 'in a well'), - 'Kakariko Well - Right': (0xEA97, False, 'in a well'), - 'Kakariko Well - Bottom': (0xEA9A, False, 'in a well'), - 'Blacksmith': (0x18002A, False, 'with the smith'), + 'Purple Chest': (0x33d68, False, 'from a box'), + "Blind's Hideout - Top": (0xeb0f, False, 'in a basement'), + "Blind's Hideout - Left": (0xeb12, False, 'in a basement'), + "Blind's Hideout - Right": (0xeb15, False, 'in a basement'), + "Blind's Hideout - Far Left": (0xeb18, False, 'in a basement'), + "Blind's Hideout - Far Right": (0xeb1b, False, 'in a basement'), + "Link's Uncle": (0x2df45, False, 'with your uncle'), + 'Secret Passage': (0xe971, False, 'near your uncle'), + 'King Zora': (0xee1c3, False, 'at a high price'), + "Zora's Ledge": (0x180149, False, 'near Zora'), + 'Waterfall Fairy - Left': (0xe9b0, False, 'near a fairy'), + 'Waterfall Fairy - Right': (0xe9d1, False, 'near a fairy'), + "King's Tomb": (0xe97a, False, 'alone in a cave'), + 'Floodgate Chest': (0xe98c, False, 'in the dam'), + "Link's House": (0xe9bc, False, 'in your home'), + 'Kakariko Tavern': (0xe9ce, False, 'in the bar'), + 'Chicken House': (0xe9e9, False, 'near poultry'), + "Aginah's Cave": (0xe9f2, False, 'with Aginah'), + "Sahasrahla's Hut - Left": (0xea82, False, 'near the elder'), + "Sahasrahla's Hut - Middle": (0xea85, False, 'near the elder'), + "Sahasrahla's Hut - Right": (0xea88, False, 'near the elder'), + 'Sahasrahla': (0x2f1fc, False, 'with the elder'), + 'Kakariko Well - Top': (0xea8e, False, 'in a well'), + 'Kakariko Well - Left': (0xea91, False, 'in a well'), + 'Kakariko Well - Middle': (0xea94, False, 'in a well'), + 'Kakariko Well - Right': (0xea97, False, 'in a well'), + 'Kakariko Well - Bottom': (0xea9a, False, 'in a well'), + 'Blacksmith': (0x18002a, False, 'with the smith'), 'Magic Bat': (0x180015, False, 'with the bat'), - 'Sick Kid': (0x339CF, False, 'with the sick'), - 'Hobo': (0x33E7D, False, 'with the hobo'), + 'Sick Kid': (0x339cf, False, 'with the sick'), + 'Hobo': (0x33e7d, False, 'with the hobo'), 'Lost Woods Hideout': (0x180000, False, 'near a thief'), 'Lumberjack Tree': (0x180001, False, 'in a hole'), 'Cave 45': (0x180003, False, 'alone in a cave'), 'Graveyard Cave': (0x180004, False, 'alone in a cave'), 'Checkerboard Cave': (0x180005, False, 'alone in a cave'), - 'Mini Moldorm Cave - Far Left': (0xEB42, False, 'near Moldorms'), - 'Mini Moldorm Cave - Left': (0xEB45, False, 'near Moldorms'), - 'Mini Moldorm Cave - Right': (0xEB48, False, 'near Moldorms'), - 'Mini Moldorm Cave - Far Right': (0xEB4B, False, 'near Moldorms'), + 'Mini Moldorm Cave - Far Left': (0xeb42, False, 'near Moldorms'), + 'Mini Moldorm Cave - Left': (0xeb45, False, 'near Moldorms'), + 'Mini Moldorm Cave - Right': (0xeb48, False, 'near Moldorms'), + 'Mini Moldorm Cave - Far Right': (0xeb4b, False, 'near Moldorms'), 'Mini Moldorm Cave - Generous Guy': (0x180010, False, 'near Moldorms'), - 'Ice Rod Cave': (0xEB4E, False, 'in a frozen cave'), - 'Bonk Rock Cave': (0xEB3F, False, 'alone in a cave'), + 'Ice Rod Cave': (0xeb4e, False, 'in a frozen cave'), + 'Bonk Rock Cave': (0xeb3f, False, 'alone in a cave'), 'Library': (0x180012, False, 'near books'), 'Potion Shop': (0x180014, False, 'near potions'), 'Lake Hylia Island': (0x180144, False, 'on an island'), 'Maze Race': (0x180142, False, 'at the race'), 'Desert Ledge': (0x180143, False, 'in the desert'), - 'Desert Palace - Big Chest': (0xE98F, False, 'in Desert Palace'), + 'Desert Palace - Big Chest': (0xe98f, False, 'in Desert Palace'), 'Desert Palace - Torch': (0x180160, False, 'in Desert Palace'), - 'Desert Palace - Map Chest': (0xE9B6, False, 'in Desert Palace'), - 'Desert Palace - Compass Chest': (0xE9CB, False, 'in Desert Palace'), - 'Desert Palace - Big Key Chest': (0xE9C2, False, 'in Desert Palace'), + 'Desert Palace - Map Chest': (0xe9b6, False, 'in Desert Palace'), + 'Desert Palace - Compass Chest': (0xe9cb, False, 'in Desert Palace'), + 'Desert Palace - Big Key Chest': (0xe9c2, False, 'in Desert Palace'), 'Desert Palace - Boss': (0x180151, False, 'with Lanmolas'), - 'Eastern Palace - Compass Chest': (0xE977, False, 'in Eastern Palace'), - 'Eastern Palace - Big Chest': (0xE97D, False, 'in Eastern Palace'), - 'Eastern Palace - Cannonball Chest': (0xE9B3, False, 'in Eastern Palace'), - 'Eastern Palace - Big Key Chest': (0xE9B9, False, 'in Eastern Palace'), - 'Eastern Palace - Map Chest': (0xE9F5, False, 'in Eastern Palace'), + 'Eastern Palace - Compass Chest': (0xe977, False, 'in Eastern Palace'), + 'Eastern Palace - Big Chest': (0xe97d, False, 'in Eastern Palace'), + 'Eastern Palace - Cannonball Chest': (0xe9b3, False, 'in Eastern Palace'), + 'Eastern Palace - Big Key Chest': (0xe9b9, False, 'in Eastern Palace'), + 'Eastern Palace - Map Chest': (0xe9f5, False, 'in Eastern Palace'), 'Eastern Palace - Boss': (0x180150, False, 'with the Armos'), - 'Master Sword Pedestal': (0x289B0, False, 'at the pedestal'), - 'Hyrule Castle - Boomerang Chest': (0xE974, False, 'in Hyrule Castle'), - 'Hyrule Castle - Map Chest': (0xEB0C, False, 'in Hyrule Castle'), - 'Hyrule Castle - Zelda\'s Chest': (0xEB09, False, 'in Hyrule Castle'), - 'Sewers - Dark Cross': (0xE96E, False, 'in the sewers'), - 'Sewers - Secret Room - Left': (0xEB5D, False, 'in the sewers'), - 'Sewers - Secret Room - Middle': (0xEB60, False, 'in the sewers'), - 'Sewers - Secret Room - Right': (0xEB63, False, 'in the sewers'), - 'Sanctuary': (0xEA79, False, 'in Sanctuary'), - 'Castle Tower - Room 03': (0xEAB5, False, 'in Castle Tower'), - 'Castle Tower - Dark Maze': (0xEAB2, False, 'in Castle Tower'), - 'Old Man': (0xF69FA, False, 'with the old man'), + 'Master Sword Pedestal': (0x289b0, False, 'at the pedestal'), + 'Hyrule Castle - Boomerang Chest': (0xe974, False, 'in Hyrule Castle'), + 'Hyrule Castle - Map Chest': (0xeb0c, False, 'in Hyrule Castle'), + "Hyrule Castle - Zelda's Chest": (0xeb09, False, 'in Hyrule Castle'), + 'Sewers - Dark Cross': (0xe96e, False, 'in the sewers'), + 'Sewers - Secret Room - Left': (0xeb5d, False, 'in the sewers'), + 'Sewers - Secret Room - Middle': (0xeb60, False, 'in the sewers'), + 'Sewers - Secret Room - Right': (0xeb63, False, 'in the sewers'), + 'Sanctuary': (0xea79, False, 'in Sanctuary'), + 'Castle Tower - Room 03': (0xeab5, False, 'in Castle Tower'), + 'Castle Tower - Dark Maze': (0xeab2, False, 'in Castle Tower'), + 'Old Man': (0xf69fa, False, 'with the old man'), 'Spectacle Rock Cave': (0x180002, False, 'alone in a cave'), - 'Paradox Cave Lower - Far Left': (0xEB2A, False, 'in a cave with seven chests'), - 'Paradox Cave Lower - Left': (0xEB2D, False, 'in a cave with seven chests'), - 'Paradox Cave Lower - Right': (0xEB30, False, 'in a cave with seven chests'), - 'Paradox Cave Lower - Far Right': (0xEB33, False, 'in a cave with seven chests'), - 'Paradox Cave Lower - Middle': (0xEB36, False, 'in a cave with seven chests'), - 'Paradox Cave Upper - Left': (0xEB39, False, 'in a cave with seven chests'), - 'Paradox Cave Upper - Right': (0xEB3C, False, 'in a cave with seven chests'), - 'Spiral Cave': (0xE9BF, False, 'in spiral cave'), + 'Paradox Cave Lower - Far Left': (0xeb2a, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Left': (0xeb2d, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Right': (0xeb30, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Far Right': (0xeb33, False, 'in a cave with seven chests'), + 'Paradox Cave Lower - Middle': (0xeb36, False, 'in a cave with seven chests'), + 'Paradox Cave Upper - Left': (0xeb39, False, 'in a cave with seven chests'), + 'Paradox Cave Upper - Right': (0xeb3c, False, 'in a cave with seven chests'), + 'Spiral Cave': (0xe9bf, False, 'in spiral cave'), 'Ether Tablet': (0x180016, False, 'at a monolith'), 'Spectacle Rock': (0x180140, False, 'atop a rock'), 'Tower of Hera - Basement Cage': (0x180162, False, 'in Tower of Hera'), - 'Tower of Hera - Map Chest': (0xE9AD, False, 'in Tower of Hera'), - 'Tower of Hera - Big Key Chest': (0xE9E6, False, 'in Tower of Hera'), - 'Tower of Hera - Compass Chest': (0xE9FB, False, 'in Tower of Hera'), - 'Tower of Hera - Big Chest': (0xE9F8, False, 'in Tower of Hera'), + 'Tower of Hera - Map Chest': (0xe9ad, False, 'in Tower of Hera'), + 'Tower of Hera - Big Key Chest': (0xe9e6, False, 'in Tower of Hera'), + 'Tower of Hera - Compass Chest': (0xe9fb, False, 'in Tower of Hera'), + 'Tower of Hera - Big Chest': (0xe9f8, False, 'in Tower of Hera'), 'Tower of Hera - Boss': (0x180152, False, 'with Moldorm'), 'Pyramid': (0x180147, False, 'on the pyramid'), - 'Catfish': (0xEE185, False, 'with a catfish'), - 'Stumpy': (0x330C7, False, 'with tree boy'), + 'Catfish': (0xee185, False, 'with a catfish'), + 'Stumpy': (0x330c7, False, 'with tree boy'), 'Digging Game': (0x180148, False, 'underground'), 'Bombos Tablet': (0x180017, False, 'at a monolith'), - 'Hype Cave - Top': (0xEB1E, False, 'near a bat-like man'), - 'Hype Cave - Middle Right': (0xEB21, False, 'near a bat-like man'), - 'Hype Cave - Middle Left': (0xEB24, False, 'near a bat-like man'), - 'Hype Cave - Bottom': (0xEB27, False, 'near a bat-like man'), + 'Hype Cave - Top': (0xeb1e, False, 'near a bat-like man'), + 'Hype Cave - Middle Right': (0xeb21, False, 'near a bat-like man'), + 'Hype Cave - Middle Left': (0xeb24, False, 'near a bat-like man'), + 'Hype Cave - Bottom': (0xeb27, False, 'near a bat-like man'), 'Hype Cave - Generous Guy': (0x180011, False, 'with a bat-like man'), 'Peg Cave': (0x180006, False, 'alone in a cave'), - 'Pyramid Fairy - Left': (0xE980, False, 'near a fairy'), - 'Pyramid Fairy - Right': (0xE983, False, 'near a fairy'), - 'Brewery': (0xE9EC, False, 'alone in a home'), - 'C-Shaped House': (0xE9EF, False, 'alone in a home'), - 'Chest Game': (0xEDA8, False, 'as a prize'), + 'Pyramid Fairy - Left': (0xe980, False, 'near a fairy'), + 'Pyramid Fairy - Right': (0xe983, False, 'near a fairy'), + 'Brewery': (0xe9ec, False, 'alone in a home'), + 'C-Shaped House': (0xe9ef, False, 'alone in a home'), + 'Chest Game': (0xeda8, False, 'as a prize'), 'Bumper Cave Ledge': (0x180146, False, 'on a ledge'), - 'Mire Shed - Left': (0xEA73, False, 'near sparks'), - 'Mire Shed - Right': (0xEA76, False, 'near sparks'), - 'Superbunny Cave - Top': (0xEA7C, False, 'in a connection'), - 'Superbunny Cave - Bottom': (0xEA7F, False, 'in a connection'), - 'Spike Cave': (0xEA8B, False, 'beyond spikes'), - 'Hookshot Cave - Top Right': (0xEB51, False, 'across pits'), - 'Hookshot Cave - Top Left': (0xEB54, False, 'across pits'), - 'Hookshot Cave - Bottom Right': (0xEB5A, False, 'across pits'), - 'Hookshot Cave - Bottom Left': (0xEB57, False, 'across pits'), + 'Mire Shed - Left': (0xea73, False, 'near sparks'), + 'Mire Shed - Right': (0xea76, False, 'near sparks'), + 'Superbunny Cave - Top': (0xea7c, False, 'in a connection'), + 'Superbunny Cave - Bottom': (0xea7f, False, 'in a connection'), + 'Spike Cave': (0xea8b, False, 'beyond spikes'), + 'Hookshot Cave - Top Right': (0xeb51, False, 'across pits'), + 'Hookshot Cave - Top Left': (0xeb54, False, 'across pits'), + 'Hookshot Cave - Bottom Right': (0xeb5a, False, 'across pits'), + 'Hookshot Cave - Bottom Left': (0xeb57, False, 'across pits'), 'Floating Island': (0x180141, False, 'on an island'), - 'Mimic Cave': (0xE9C5, False, 'in a cave of mimicry'), - 'Swamp Palace - Entrance': (0xEA9D, False, 'in Swamp Palace'), - 'Swamp Palace - Map Chest': (0xE986, False, 'in Swamp Palace'), - 'Swamp Palace - Big Chest': (0xE989, False, 'in Swamp Palace'), - 'Swamp Palace - Compass Chest': (0xEAA0, False, 'in Swamp Palace'), - 'Swamp Palace - Big Key Chest': (0xEAA6, False, 'in Swamp Palace'), - 'Swamp Palace - West Chest': (0xEAA3, False, 'in Swamp Palace'), - 'Swamp Palace - Flooded Room - Left': (0xEAA9, False, 'in Swamp Palace'), - 'Swamp Palace - Flooded Room - Right': (0xEAAC, False, 'in Swamp Palace'), - 'Swamp Palace - Waterfall Room': (0xEAAF, False, 'in Swamp Palace'), + 'Mimic Cave': (0xe9c5, False, 'in a cave of mimicry'), + 'Swamp Palace - Entrance': (0xea9d, False, 'in Swamp Palace'), + 'Swamp Palace - Map Chest': (0xe986, False, 'in Swamp Palace'), + 'Swamp Palace - Big Chest': (0xe989, False, 'in Swamp Palace'), + 'Swamp Palace - Compass Chest': (0xeaa0, False, 'in Swamp Palace'), + 'Swamp Palace - Big Key Chest': (0xeaa6, False, 'in Swamp Palace'), + 'Swamp Palace - West Chest': (0xeaa3, False, 'in Swamp Palace'), + 'Swamp Palace - Flooded Room - Left': (0xeaa9, False, 'in Swamp Palace'), + 'Swamp Palace - Flooded Room - Right': (0xeaac, False, 'in Swamp Palace'), + 'Swamp Palace - Waterfall Room': (0xeaaf, False, 'in Swamp Palace'), 'Swamp Palace - Boss': (0x180154, False, 'with Arrghus'), - 'Thieves\' Town - Big Key Chest': (0xEA04, False, 'in Thieves\' Town'), - 'Thieves\' Town - Map Chest': (0xEA01, False, 'in Thieves\' Town'), - 'Thieves\' Town - Compass Chest': (0xEA07, False, 'in Thieves\' Town'), - 'Thieves\' Town - Ambush Chest': (0xEA0A, False, 'in Thieves\' Town'), - 'Thieves\' Town - Attic': (0xEA0D, False, 'in Thieves\' Town'), - 'Thieves\' Town - Big Chest': (0xEA10, False, 'in Thieves\' Town'), - 'Thieves\' Town - Blind\'s Cell': (0xEA13, False, 'in Thieves\' Town'), - 'Thieves\' Town - Boss': (0x180156, False, 'with Blind'), - 'Skull Woods - Compass Chest': (0xE992, False, 'in Skull Woods'), - 'Skull Woods - Map Chest': (0xE99B, False, 'in Skull Woods'), - 'Skull Woods - Big Chest': (0xE998, False, 'in Skull Woods'), - 'Skull Woods - Pot Prison': (0xE9A1, False, 'in Skull Woods'), - 'Skull Woods - Pinball Room': (0xE9C8, False, 'in Skull Woods'), - 'Skull Woods - Big Key Chest': (0xE99E, False, 'in Skull Woods'), - 'Skull Woods - Bridge Room': (0xE9FE, False, 'near Mothula'), + "Thieves' Town - Big Key Chest": (0xea04, False, "in Thieves' Town"), + "Thieves' Town - Map Chest": (0xea01, False, "in Thieves' Town"), + "Thieves' Town - Compass Chest": (0xea07, False, "in Thieves' Town"), + "Thieves' Town - Ambush Chest": (0xea0a, False, "in Thieves' Town"), + "Thieves' Town - Attic": (0xea0d, False, "in Thieves' Town"), + "Thieves' Town - Big Chest": (0xea10, False, "in Thieves' Town"), + "Thieves' Town - Blind's Cell": (0xea13, False, "in Thieves' Town"), + "Thieves' Town - Boss": (0x180156, False, 'with Blind'), + 'Skull Woods - Compass Chest': (0xe992, False, 'in Skull Woods'), + 'Skull Woods - Map Chest': (0xe99b, False, 'in Skull Woods'), + 'Skull Woods - Big Chest': (0xe998, False, 'in Skull Woods'), + 'Skull Woods - Pot Prison': (0xe9a1, False, 'in Skull Woods'), + 'Skull Woods - Pinball Room': (0xe9c8, False, 'in Skull Woods'), + 'Skull Woods - Big Key Chest': (0xe99e, False, 'in Skull Woods'), + 'Skull Woods - Bridge Room': (0xe9fe, False, 'near Mothula'), 'Skull Woods - Boss': (0x180155, False, 'with Mothula'), - 'Ice Palace - Compass Chest': (0xE9D4, False, 'in Ice Palace'), - 'Ice Palace - Freezor Chest': (0xE995, False, 'in Ice Palace'), - 'Ice Palace - Big Chest': (0xE9AA, False, 'in Ice Palace'), - 'Ice Palace - Iced T Room': (0xE9E3, False, 'in Ice Palace'), - 'Ice Palace - Spike Room': (0xE9E0, False, 'in Ice Palace'), - 'Ice Palace - Big Key Chest': (0xE9A4, False, 'in Ice Palace'), - 'Ice Palace - Map Chest': (0xE9DD, False, 'in Ice Palace'), + 'Ice Palace - Compass Chest': (0xe9d4, False, 'in Ice Palace'), + 'Ice Palace - Freezor Chest': (0xe995, False, 'in Ice Palace'), + 'Ice Palace - Big Chest': (0xe9aa, False, 'in Ice Palace'), + 'Ice Palace - Iced T Room': (0xe9e3, False, 'in Ice Palace'), + 'Ice Palace - Spike Room': (0xe9e0, False, 'in Ice Palace'), + 'Ice Palace - Big Key Chest': (0xe9a4, False, 'in Ice Palace'), + 'Ice Palace - Map Chest': (0xe9dd, False, 'in Ice Palace'), 'Ice Palace - Boss': (0x180157, False, 'with Kholdstare'), - 'Misery Mire - Big Chest': (0xEA67, False, 'in Misery Mire'), - 'Misery Mire - Map Chest': (0xEA6A, False, 'in Misery Mire'), - 'Misery Mire - Main Lobby': (0xEA5E, False, 'in Misery Mire'), - 'Misery Mire - Bridge Chest': (0xEA61, False, 'in Misery Mire'), - 'Misery Mire - Spike Chest': (0xE9DA, False, 'in Misery Mire'), - 'Misery Mire - Compass Chest': (0xEA64, False, 'in Misery Mire'), - 'Misery Mire - Big Key Chest': (0xEA6D, False, 'in Misery Mire'), + 'Misery Mire - Big Chest': (0xea67, False, 'in Misery Mire'), + 'Misery Mire - Map Chest': (0xea6a, False, 'in Misery Mire'), + 'Misery Mire - Main Lobby': (0xea5e, False, 'in Misery Mire'), + 'Misery Mire - Bridge Chest': (0xea61, False, 'in Misery Mire'), + 'Misery Mire - Spike Chest': (0xe9da, False, 'in Misery Mire'), + 'Misery Mire - Compass Chest': (0xea64, False, 'in Misery Mire'), + 'Misery Mire - Big Key Chest': (0xea6d, False, 'in Misery Mire'), 'Misery Mire - Boss': (0x180158, False, 'with Vitreous'), - 'Turtle Rock - Compass Chest': (0xEA22, False, 'in Turtle Rock'), - 'Turtle Rock - Roller Room - Left': (0xEA1C, False, 'in Turtle Rock'), - 'Turtle Rock - Roller Room - Right': (0xEA1F, False, 'in Turtle Rock'), - 'Turtle Rock - Chain Chomps': (0xEA16, False, 'in Turtle Rock'), - 'Turtle Rock - Big Key Chest': (0xEA25, False, 'in Turtle Rock'), - 'Turtle Rock - Big Chest': (0xEA19, False, 'in Turtle Rock'), - 'Turtle Rock - Crystaroller Room': (0xEA34, False, 'in Turtle Rock'), - 'Turtle Rock - Eye Bridge - Bottom Left': (0xEA31, False, 'in Turtle Rock'), - 'Turtle Rock - Eye Bridge - Bottom Right': (0xEA2E, False, 'in Turtle Rock'), - 'Turtle Rock - Eye Bridge - Top Left': (0xEA2B, False, 'in Turtle Rock'), - 'Turtle Rock - Eye Bridge - Top Right': (0xEA28, False, 'in Turtle Rock'), + 'Turtle Rock - Compass Chest': (0xea22, False, 'in Turtle Rock'), + 'Turtle Rock - Roller Room - Left': (0xea1c, False, 'in Turtle Rock'), + 'Turtle Rock - Roller Room - Right': (0xea1f, False, 'in Turtle Rock'), + 'Turtle Rock - Chain Chomps': (0xea16, False, 'in Turtle Rock'), + 'Turtle Rock - Big Key Chest': (0xea25, False, 'in Turtle Rock'), + 'Turtle Rock - Big Chest': (0xea19, False, 'in Turtle Rock'), + 'Turtle Rock - Crystaroller Room': (0xea34, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Bottom Left': (0xea31, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Bottom Right': (0xea2e, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Top Left': (0xea2b, False, 'in Turtle Rock'), + 'Turtle Rock - Eye Bridge - Top Right': (0xea28, False, 'in Turtle Rock'), 'Turtle Rock - Boss': (0x180159, False, 'with Trinexx'), - 'Palace of Darkness - Shooter Room': (0xEA5B, False, 'in Palace of Darkness'), - 'Palace of Darkness - The Arena - Bridge': (0xEA3D, False, 'in Palace of Darkness'), - 'Palace of Darkness - Stalfos Basement': (0xEA49, False, 'in Palace of Darkness'), - 'Palace of Darkness - Big Key Chest': (0xEA37, False, 'in Palace of Darkness'), - 'Palace of Darkness - The Arena - Ledge': (0xEA3A, False, 'in Palace of Darkness'), - 'Palace of Darkness - Map Chest': (0xEA52, False, 'in Palace of Darkness'), - 'Palace of Darkness - Compass Chest': (0xEA43, False, 'in Palace of Darkness'), - 'Palace of Darkness - Dark Basement - Left': (0xEA4C, False, 'in Palace of Darkness'), - 'Palace of Darkness - Dark Basement - Right': (0xEA4F, False, 'in Palace of Darkness'), - 'Palace of Darkness - Dark Maze - Top': (0xEA55, False, 'in Palace of Darkness'), - 'Palace of Darkness - Dark Maze - Bottom': (0xEA58, False, 'in Palace of Darkness'), - 'Palace of Darkness - Big Chest': (0xEA40, False, 'in Palace of Darkness'), - 'Palace of Darkness - Harmless Hellway': (0xEA46, False, 'in Palace of Darkness'), + 'Palace of Darkness - Shooter Room': (0xea5b, False, 'in Palace of Darkness'), + 'Palace of Darkness - The Arena - Bridge': (0xea3d, False, 'in Palace of Darkness'), + 'Palace of Darkness - Stalfos Basement': (0xea49, False, 'in Palace of Darkness'), + 'Palace of Darkness - Big Key Chest': (0xea37, False, 'in Palace of Darkness'), + 'Palace of Darkness - The Arena - Ledge': (0xea3a, False, 'in Palace of Darkness'), + 'Palace of Darkness - Map Chest': (0xea52, False, 'in Palace of Darkness'), + 'Palace of Darkness - Compass Chest': (0xea43, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Basement - Left': (0xea4c, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Basement - Right': (0xea4f, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Maze - Top': (0xea55, False, 'in Palace of Darkness'), + 'Palace of Darkness - Dark Maze - Bottom': (0xea58, False, 'in Palace of Darkness'), + 'Palace of Darkness - Big Chest': (0xea40, False, 'in Palace of Darkness'), + 'Palace of Darkness - Harmless Hellway': (0xea46, False, 'in Palace of Darkness'), 'Palace of Darkness - Boss': (0x180153, False, 'with Helmasaur King'), - 'Ganons Tower - Bob\'s Torch': (0x180161, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Hope Room - Left': (0xEAD9, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Hope Room - Right': (0xEADC, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Tile Room': (0xEAE2, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Compass Room - Top Left': (0xEAE5, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Compass Room - Top Right': (0xEAE8, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Compass Room - Bottom Left': (0xEAEB, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Compass Room - Bottom Right': (0xEAEE, False, 'in Ganon\'s Tower'), - 'Ganons Tower - DMs Room - Top Left': (0xEAB8, False, 'in Ganon\'s Tower'), - 'Ganons Tower - DMs Room - Top Right': (0xEABB, False, 'in Ganon\'s Tower'), - 'Ganons Tower - DMs Room - Bottom Left': (0xEABE, False, 'in Ganon\'s Tower'), - 'Ganons Tower - DMs Room - Bottom Right': (0xEAC1, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Map Chest': (0xEAD3, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Firesnake Room': (0xEAD0, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Randomizer Room - Top Left': (0xEAC4, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Randomizer Room - Top Right': (0xEAC7, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Randomizer Room - Bottom Left': (0xEACA, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Randomizer Room - Bottom Right': (0xEACD, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Bob\'s Chest': (0xEADF, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Big Chest': (0xEAD6, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Big Key Room - Left': (0xEAF4, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Big Key Room - Right': (0xEAF7, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Big Key Chest': (0xEAF1, False, 'in Ganon\'s Tower'), - 'Ganons Tower - Mini Helmasaur Room - Left': (0xEAFD, False, 'atop Ganon\'s Tower'), - 'Ganons Tower - Mini Helmasaur Room - Right': (0xEB00, False, 'atop Ganon\'s Tower'), - 'Ganons Tower - Pre-Moldorm Chest': (0xEB03, False, 'atop Ganon\'s Tower'), - 'Ganons Tower - Validation Chest': (0xEB06, False, 'atop Ganon\'s Tower'), + "Ganons Tower - Bob's Torch": (0x180161, False, "in Ganon's Tower"), + 'Ganons Tower - Hope Room - Left': (0xead9, False, "in Ganon's Tower"), + 'Ganons Tower - Hope Room - Right': (0xeadc, False, "in Ganon's Tower"), + 'Ganons Tower - Tile Room': (0xeae2, False, "in Ganon's Tower"), + 'Ganons Tower - Compass Room - Top Left': (0xeae5, False, "in Ganon's Tower"), + 'Ganons Tower - Compass Room - Top Right': (0xeae8, False, "in Ganon's Tower"), + 'Ganons Tower - Compass Room - Bottom Left': (0xeaeb, False, "in Ganon's Tower"), + 'Ganons Tower - Compass Room - Bottom Right': (0xeaee, False, "in Ganon's Tower"), + 'Ganons Tower - DMs Room - Top Left': (0xeab8, False, "in Ganon's Tower"), + 'Ganons Tower - DMs Room - Top Right': (0xeabb, False, "in Ganon's Tower"), + 'Ganons Tower - DMs Room - Bottom Left': (0xeabe, False, "in Ganon's Tower"), + 'Ganons Tower - DMs Room - Bottom Right': (0xeac1, False, "in Ganon's Tower"), + 'Ganons Tower - Map Chest': (0xead3, False, "in Ganon's Tower"), + 'Ganons Tower - Firesnake Room': (0xead0, False, "in Ganon's Tower"), + 'Ganons Tower - Randomizer Room - Top Left': (0xeac4, False, "in Ganon's Tower"), + 'Ganons Tower - Randomizer Room - Top Right': (0xeac7, False, "in Ganon's Tower"), + 'Ganons Tower - Randomizer Room - Bottom Left': (0xeaca, False, "in Ganon's Tower"), + 'Ganons Tower - Randomizer Room - Bottom Right': (0xeacd, False, "in Ganon's Tower"), + "Ganons Tower - Bob's Chest": (0xeadf, False, "in Ganon's Tower"), + 'Ganons Tower - Big Chest': (0xead6, False, "in Ganon's Tower"), + 'Ganons Tower - Big Key Room - Left': (0xeaf4, False, "in Ganon's Tower"), + 'Ganons Tower - Big Key Room - Right': (0xeaf7, False, "in Ganon's Tower"), + 'Ganons Tower - Big Key Chest': (0xeaf1, False, "in Ganon's Tower"), + 'Ganons Tower - Mini Helmasaur Room - Left': (0xeafd, False, "atop Ganon's Tower"), + 'Ganons Tower - Mini Helmasaur Room - Right': (0xeb00, False, "atop Ganon's Tower"), + 'Ganons Tower - Pre-Moldorm Chest': (0xeb03, False, "atop Ganon's Tower"), + 'Ganons Tower - Validation Chest': (0xeb06, False, "atop Ganon's Tower"), 'Ganon': (None, False, 'from me'), 'Agahnim 1': (None, False, 'from Ganon\'s wizardry form'), 'Agahnim 2': (None, False, 'from Ganon\'s wizardry form'), diff --git a/Rom.py b/Rom.py index 9f21eb0d74..843cabf297 100644 --- a/Rom.py +++ b/Rom.py @@ -3,16 +3,18 @@ import json import hashlib import logging import os -import struct import random +import struct +import subprocess -from BaseClasses import ShopType +from BaseClasses import ShopType, Region, Location, Item from Dungeons import dungeon_music_addresses -from Text import MultiByteTextMapper, text_addresses, Credits, TextTable +from Text import MultiByteTextMapper, CompressedTextMapper, text_addresses, Credits, TextTable from Text import Uncle_texts, Ganon1_texts, TavernMan_texts, Sahasrahla2_texts, Triforce_texts, Blind_texts, BombShop2_texts, junk_texts from Text import KingsReturn_texts, Sanctuary_texts, Kakariko_texts, Blacksmiths_texts, DeathMountain_texts, LostWoods_texts, WishingWell_texts, DesertPalace_texts, MountainTower_texts, LinksHouse_texts, Lumberjacks_texts, SickKid_texts, FluteBoy_texts, Zora_texts, MagicShop_texts, Sahasrahla_names -from Utils import local_path, int16_as_bytes, int32_as_bytes -from Items import ItemFactory +from Utils import output_path, local_path, int16_as_bytes, int32_as_bytes, snes_to_pc +from Items import ItemFactory, item_table +from EntranceShuffle import door_addresses JAP10HASH = '03a63945398191337e896e5771f77173' @@ -22,6 +24,7 @@ RANDOMIZERBASEHASH = 'cb560220b7b1b8202e92381aee19cd36' class JsonRom(object): def __init__(self): + self.name = None self.patches = {} def write_byte(self, address, value): @@ -35,6 +38,10 @@ class JsonRom(object): def write_int16(self, address, value): self.write_bytes(address, int16_as_bytes(value)) + def write_int16s(self, startaddress, values): + byte_list = [int16_as_bytes(value) for value in values] + self.patches[str(startaddress)] = [byte for bytes in byte_list for byte in bytes] + def write_int32(self, address, value): self.write_bytes(address, int32_as_bytes(value)) @@ -52,6 +59,7 @@ class JsonRom(object): class LocalRom(object): def __init__(self, file, patch=True): + self.name = None with open(file, 'rb') as stream: self.buffer = read_rom(stream) if patch: @@ -67,9 +75,17 @@ class LocalRom(object): def write_int16(self, address, value): self.write_bytes(address, int16_as_bytes(value)) + def write_int16s(self, startaddress, values): + for i, value in enumerate(values): + self.write_int16(startaddress + (i * 2), value) + def write_int32(self, address, value): self.write_bytes(address, int32_as_bytes(value)) + def write_int32s(self, startaddress, values): + for i, value in enumerate(values): + self.write_int32(startaddress + (i * 2), value) + def write_to_file(self, file): with open(file, 'wb') as outfile: outfile.write(self.buffer) @@ -82,7 +98,7 @@ class LocalRom(object): logging.getLogger('').warning('Supplied Base Rom does not match known MD5 for JAP(1.0) release. Will try to patch anyway.') # extend to 2MB - self.buffer.extend(bytearray([0x00] * (2097152 - len(self.buffer)))) + self.buffer.extend(bytearray([0x00] * (0x200000 - len(self.buffer)))) # load randomizer patches with open(local_path('data/base2current.json'), 'r') as stream: @@ -98,6 +114,24 @@ class LocalRom(object): if RANDOMIZERBASEHASH != patchedmd5.hexdigest(): raise RuntimeError('Provided Base Rom unsuitable for patching. Please provide a JAP(1.0) "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc" rom to use as a base.') + def patch_enemizer(self, rando_patch, base_enemizer_patch_path, enemizer_patch): + # extend to 4MB + self.buffer.extend(bytearray([0x00] * (0x400000 - len(self.buffer)))) + + # apply randomizer patches + for address, values in rando_patch.items(): + self.write_bytes(int(address), values) + + # load base enemizer patches + with open(base_enemizer_patch_path, 'r') as f: + base_enemizer_patch = json.load(f) + for patch in base_enemizer_patch: + self.write_bytes(patch["address"], patch["patchData"]) + + # apply enemizer patches + for patch in enemizer_patch: + self.write_bytes(patch["address"], patch["patchData"]) + def write_crc(self): crc = (sum(self.buffer[:0x7FDC] + self.buffer[0x7FE0:]) + 0x01FE) & 0xFFFF inv = crc ^ 0xFFFF @@ -115,6 +149,131 @@ def read_rom(stream): buffer = buffer[0x200:] return buffer +def get_enemizer_patch(world, player, rom, baserom_path, enemizercli, shuffleenemies, enemy_health, enemy_damage, shufflepalette, shufflepots): + baserom_path = os.path.abspath(baserom_path) + basepatch_path = os.path.abspath(local_path('data/base2current.json')) + randopatch_path = os.path.abspath(output_path('enemizer_randopatch.json')) + options_path = os.path.abspath(output_path('enemizer_options.json')) + enemizer_output_path = os.path.abspath(output_path('enemizer_output.json')) + + # write options file for enemizer + options = { + 'RandomizeEnemies': shuffleenemies, + 'RandomizeEnemiesType': 3, + 'RandomizeBushEnemyChance': True, + 'RandomizeEnemyHealthRange': enemy_health != 'default', + 'RandomizeEnemyHealthType': {'default': 0, 'easy': 0, 'normal': 1, 'hard': 2, 'expert': 3}[enemy_health], + 'OHKO': False, + 'RandomizeEnemyDamage': enemy_damage != 'default', + 'AllowEnemyZeroDamage': True, + 'ShuffleEnemyDamageGroups': enemy_damage != 'default', + 'EnemyDamageChaosMode': enemy_damage == 'chaos', + 'EasyModeEscape': False, + 'EnemiesAbsorbable': False, + 'AbsorbableSpawnRate': 10, + 'AbsorbableTypes': { + 'FullMagic': True, 'SmallMagic': True, 'Bomb_1': True, 'BlueRupee': True, 'Heart': True, 'BigKey': True, 'Key': True, + 'Fairy': True, 'Arrow_10': True, 'Arrow_5': True, 'Bomb_8': True, 'Bomb_4': True, 'GreenRupee': True, 'RedRupee': True + }, + 'BossMadness': False, + 'RandomizeBosses': True, + 'RandomizeBossesType': 0, + 'RandomizeBossHealth': False, + 'RandomizeBossHealthMinAmount': 0, + 'RandomizeBossHealthMaxAmount': 300, + 'RandomizeBossDamage': False, + 'RandomizeBossDamageMinAmount': 0, + 'RandomizeBossDamageMaxAmount': 200, + 'RandomizeBossBehavior': False, + 'RandomizeDungeonPalettes': shufflepalette, + 'SetBlackoutMode': False, + 'RandomizeOverworldPalettes': shufflepalette, + 'RandomizeSpritePalettes': shufflepalette, + 'SetAdvancedSpritePalettes': False, + 'PukeMode': False, + 'NegativeMode': False, + 'GrayscaleMode': False, + 'GenerateSpoilers': False, + 'RandomizeLinkSpritePalette': False, + 'RandomizePots': shufflepots, + 'ShuffleMusic': False, + 'BootlegMagic': True, + 'CustomBosses': False, + 'AndyMode': False, + 'HeartBeepSpeed': 0, + 'AlternateGfx': False, + 'ShieldGraphics': "shield_gfx/normal.gfx", + 'SwordGraphics': "sword_gfx/normal.gfx", + 'BeeMizer': False, + 'BeesLevel': 0, + 'RandomizeTileTrapPattern': True, + 'RandomizeTileTrapFloorTile': False, + 'AllowKillableThief': shuffleenemies, + 'RandomizeSpriteOnHit': False, + 'DebugMode': False, + 'DebugForceEnemy': False, + 'DebugForceEnemyId': 0, + 'DebugForceBoss': False, + 'DebugForceBossId': 0, + 'DebugOpenShutterDoors': False, + 'DebugForceEnemyDamageZero': False, + 'DebugShowRoomIdInRupeeCounter': False, + 'UseManualBosses': True, + 'ManualBosses': { + 'EasternPalace': world.get_dungeon("Eastern Palace", player).boss.enemizer_name, + 'DesertPalace': world.get_dungeon("Desert Palace", player).boss.enemizer_name, + 'TowerOfHera': world.get_dungeon("Tower of Hera", player).boss.enemizer_name, + 'AgahnimsTower': 'Agahnim', + 'PalaceOfDarkness': world.get_dungeon("Palace of Darkness", player).boss.enemizer_name, + 'SwampPalace': world.get_dungeon("Swamp Palace", player).boss.enemizer_name, + 'SkullWoods': world.get_dungeon("Skull Woods", player).boss.enemizer_name, + 'ThievesTown': world.get_dungeon("Thieves Town", player).boss.enemizer_name, + 'IcePalace': world.get_dungeon("Ice Palace", player).boss.enemizer_name, + 'MiseryMire': world.get_dungeon("Misery Mire", player).boss.enemizer_name, + 'TurtleRock': world.get_dungeon("Turtle Rock", player).boss.enemizer_name, + 'GanonsTower4': 'Agahnim2', + 'Ganon': 'Ganon', + } + } + + if world.mode != 'inverted': + options['ManualBosses']['GanonsTower1'] = world.get_dungeon('Ganons Tower', player).bosses['bottom'].enemizer_name + options['ManualBosses']['GanonsTower2'] = world.get_dungeon('Ganons Tower', player).bosses['middle'].enemizer_name + options['ManualBosses']['GanonsTower3'] = world.get_dungeon('Ganons Tower', player).bosses['top'].enemizer_name + else: + options['ManualBosses']['GanonsTower1'] = world.get_dungeon('Inverted Ganons Tower', player).bosses['bottom'].enemizer_name + options['ManualBosses']['GanonsTower2'] = world.get_dungeon('Inverted Ganons Tower', player).bosses['middle'].enemizer_name + options['ManualBosses']['GanonsTower3'] = world.get_dungeon('Inverted Ganons Tower', player).bosses['top'].enemizer_name + + + rom.write_to_file(randopatch_path) + + with open(options_path, 'w') as f: + json.dump(options, f) + + subprocess.check_call([os.path.abspath(enemizercli), + '--rom', baserom_path, + '--seed', str(world.rom_seeds[player]), + '--base', basepatch_path, + '--randomizer', randopatch_path, + '--enemizer', options_path, + '--output', enemizer_output_path], + cwd=os.path.dirname(enemizercli), stdout=subprocess.DEVNULL) + + with open(enemizer_output_path, 'r') as f: + ret = json.load(f) + + if os.path.exists(randopatch_path): + os.remove(randopatch_path) + + if os.path.exists(options_path): + os.remove(options_path) + + if os.path.exists(enemizer_output_path): + os.remove(enemizer_output_path) + + return ret + class Sprite(object): default_palette = [255, 127, 126, 35, 183, 17, 158, 54, 165, 20, 255, 1, 120, 16, 157, 89, 71, 54, 104, 59, 74, 10, 239, 18, 92, 42, 113, 21, 24, 122, @@ -273,15 +432,26 @@ class Sprite(object): # split into palettes of 15 colors return array_chunk(palette_as_colors, 15) -def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): +def patch_rom(world, player, rom): + random.seed(world.rom_seeds[player]) + + # progressive bow silver arrow hint hack + prog_bow_locs = world.find_items('Progressive Bow', player) + if len(prog_bow_locs) > 1: + # only pick a distingushed bow if we have at least two + distinguished_prog_bow_loc = random.choice(prog_bow_locs) + distinguished_prog_bow_loc.item.code = 0x65 + # patch items for location in world.get_locations(): - itemid = location.item.code if location.item is not None else 0x5A - - if itemid is None or location.address is None: + if location.player != player: + continue + + itemid = location.item.code if location.item is not None else 0x5A + + if location.address is None: continue - locationaddress = location.address if not location.crystal: # Keys in their native dungeon should use the orignal item code for keys if location.parent_region.dungeon: @@ -291,10 +461,10 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): itemid = 0x32 if location.item.type == "SmallKey": itemid = 0x24 - rom.write_byte(locationaddress, itemid) + rom.write_byte(location.address, itemid) else: # crystals - for address, value in zip(locationaddress, itemid): + for address, value in zip(location.address, itemid): rom.write_byte(address, value) # patch music @@ -312,7 +482,7 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): # patch entrance/exits/holes for region in world.regions: for exit in region.exits: - if exit.target is not None: + if exit.target is not None and exit.player == player: if isinstance(exit.addresses, tuple): offset = exit.target room_id, ow_area, vram_loc, scroll_y, scroll_x, link_y, link_x, camera_y, camera_x, unknown_1, unknown_2, door_1, door_2 = exit.addresses @@ -359,35 +529,43 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): else: # patch door table rom.write_byte(0xDBB73 + exit.addresses, exit.target) - - write_custom_shops(rom, world) + if world.mode == 'inverted': + patch_shuffled_dark_sanc(world, rom, player) + + write_custom_shops(rom, world, player) # patch medallion requirements - if world.required_medallions[0] == 'Bombos': + if world.required_medallions[player][0] == 'Bombos': rom.write_byte(0x180022, 0x00) # requirement rom.write_byte(0x4FF2, 0x31) # sprite rom.write_byte(0x50D1, 0x80) rom.write_byte(0x51B0, 0x00) - elif world.required_medallions[0] == 'Quake': + elif world.required_medallions[player][0] == 'Quake': rom.write_byte(0x180022, 0x02) # requirement rom.write_byte(0x4FF2, 0x31) # sprite rom.write_byte(0x50D1, 0x88) rom.write_byte(0x51B0, 0x00) - if world.required_medallions[1] == 'Bombos': + if world.required_medallions[player][1] == 'Bombos': rom.write_byte(0x180023, 0x00) # requirement rom.write_byte(0x5020, 0x31) # sprite rom.write_byte(0x50FF, 0x90) rom.write_byte(0x51DE, 0x00) - elif world.required_medallions[1] == 'Ether': + elif world.required_medallions[player][1] == 'Ether': rom.write_byte(0x180023, 0x01) # requirement rom.write_byte(0x5020, 0x31) # sprite rom.write_byte(0x50FF, 0x98) rom.write_byte(0x51DE, 0x00) # set open mode: - if world.mode in ['open', 'swordless']: + if world.mode in ['open', 'inverted']: rom.write_byte(0x180032, 0x01) # open mode + if world.mode == 'inverted': + set_inverted_mode(world, rom) + elif world.mode == 'standard': + rom.write_byte(0x180032, 0x00) # standard mode + uncle_location = world.get_location('Link\'s Uncle', player) + if uncle_location.item is None or uncle_location.item.name not in ['Master Sword', 'Tempered Sword', 'Fighter Sword', 'Golden Sword', 'Progressive Sword']: # disable sword sprite from uncle rom.write_bytes(0x6D263, [0x00, 0x00, 0xf6, 0xff, 0x00, 0x0E]) rom.write_bytes(0x6D26B, [0x00, 0x00, 0xf6, 0xff, 0x00, 0x0E]) @@ -399,8 +577,6 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_bytes(0x6D2EB, [0x00, 0x00, 0xf7, 0xff, 0x02, 0x0E]) rom.write_bytes(0x6D31B, [0x00, 0x00, 0xe4, 0xff, 0x08, 0x0E]) rom.write_bytes(0x6D323, [0x00, 0x00, 0xe4, 0xff, 0x08, 0x0E]) - else: - rom.write_byte(0x180032, 0x00) # standard mode # set light cones rom.write_byte(0x180038, 0x01 if world.sewer_light_cone else 0x00) @@ -408,12 +584,13 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_byte(0x18003A, 0x01 if world.dark_world_light_cone else 0x00) GREEN_TWENTY_RUPEES = 0x47 - TRIFORCE_PIECE = ItemFactory('Triforce Piece').code - GREEN_CLOCK = ItemFactory('Green Clock').code + TRIFORCE_PIECE = ItemFactory('Triforce Piece', player).code + GREEN_CLOCK = ItemFactory('Green Clock', player).code rom.write_byte(0x18004F, 0x01) # Byrna Invulnerability: on - # handle difficulty - if world.difficulty == 'hard': + + # handle difficulty_adjustments + if world.difficulty_adjustments == 'hard': # Powdered Fairies Prize rom.write_byte(0x36DD0, 0xD8) # One Heart # potion heal amount @@ -421,7 +598,7 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): # potion magic restore amount rom.write_byte(0x180085, 0x40) # Half Magic #Cape magic cost - rom.write_bytes(0x3ADA7, [0x02, 0x02, 0x02]) + rom.write_bytes(0x3ADA7, [0x02, 0x04, 0x08]) # Byrna Invulnerability: off rom.write_byte(0x18004F, 0x00) #Disable catching fairies @@ -431,17 +608,15 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_int16(0x180036, world.rupoor_cost) # Set stun items rom.write_byte(0x180180, 0x02) # Hookshot only - # Make silver arrows only usable against Ganon - rom.write_byte(0x180181, 0x01) - elif world.difficulty == 'expert': + elif world.difficulty_adjustments == 'expert': # Powdered Fairies Prize rom.write_byte(0x36DD0, 0xD8) # One Heart # potion heal amount - rom.write_byte(0x180084, 0x08) # One Heart + rom.write_byte(0x180084, 0x20) # 4 Hearts # potion magic restore amount rom.write_byte(0x180085, 0x20) # Quarter Magic #Cape magic cost - rom.write_bytes(0x3ADA7, [0x01, 0x01, 0x01]) + rom.write_bytes(0x3ADA7, [0x02, 0x04, 0x08]) # Byrna Invulnerability: off rom.write_byte(0x18004F, 0x00) #Disable catching fairies @@ -451,28 +626,6 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_int16(0x180036, world.rupoor_cost) # Set stun items rom.write_byte(0x180180, 0x00) # Nothing - # Make silver arrows only usable against Ganon - rom.write_byte(0x180181, 0x01) - elif world.difficulty == 'insane': - # Powdered Fairies Prize - rom.write_byte(0x36DD0, 0x79) # Bees - # potion heal amount - rom.write_byte(0x180084, 0x00) # No healing - # potion magic restore amount - rom.write_byte(0x180085, 0x00) # No healing - #Cape magic cost - rom.write_bytes(0x3ADA7, [0x01, 0x01, 0x01]) - # Byrna Invulnerability: off - rom.write_byte(0x18004F, 0x00) - #Disable catching fairies - rom.write_byte(0x34FD6, 0x80) - overflow_replacement = GREEN_TWENTY_RUPEES - # Rupoor negative value - rom.write_int16(0x180036, world.rupoor_cost) - # Set stun items - rom.write_byte(0x180180, 0x00) # Nothing - # Make silver arrows only usable against Ganon - rom.write_byte(0x180181, 0x01) else: # Powdered Fairies Prize rom.write_byte(0x36DD0, 0xE3) # fairy @@ -490,31 +643,31 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_int16(0x180036, world.rupoor_cost) # Set stun items rom.write_byte(0x180180, 0x03) # All standard items - # Make silver arrows freely usable - rom.write_byte(0x180181, 0x00) #Set overflow items for progressive equipment if world.timer in ['timed', 'timed-countdown', 'timed-ohko']: overflow_replacement = GREEN_CLOCK else: overflow_replacement = GREEN_TWENTY_RUPEES - if world.difficulty in ['easy']: - rom.write_byte(0x180182, 0x03) # auto equip silvers on pickup and at ganon - elif world.retro and world.difficulty in ['hard', 'expert', 'insane']: #FIXME: this is temporary for v29 baserom (perhaps no so temporary?) - rom.write_byte(0x180182, 0x03) # auto equip silvers on pickup and at ganon - else: - rom.write_byte(0x180182, 0x01) # auto equip silvers on pickup + rom.write_byte(0x180181, 0x00) # Make silver arrows freely usable + rom.write_byte(0x180182, 0x01) # auto equip silvers on pickup #Byrna residual magic cost rom.write_bytes(0x45C42, [0x04, 0x02, 0x01]) difficulty = world.difficulty_requirements + #Set overflow items for progressive equipment rom.write_bytes(0x180090, [difficulty.progressive_sword_limit, overflow_replacement, difficulty.progressive_shield_limit, overflow_replacement, difficulty.progressive_armor_limit, overflow_replacement, - difficulty.progressive_bottle_limit, overflow_replacement]) + difficulty.progressive_bottle_limit, overflow_replacement, + difficulty.progressive_bow_limit, overflow_replacement]) + + if difficulty.progressive_bow_limit < 2 and world.swords == 'swordless': + rom.write_bytes(0x180098, [2, overflow_replacement]) + rom.write_byte(0x180181, 0x01) # Make silver arrows work only on ganon # set up game internal RNG seed for i in range(1024): @@ -531,7 +684,19 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3] - if world.difficulty in ['hard', 'expert', 'insane']: + + def chunk(l,n): + return [l[i:i+n] for i in range(0, len(l), n)] + + # randomize last 7 slots + prizes [-7:] = random.sample(prizes, 7) + + #shuffle order of 7 main packs + packs = chunk(prizes[:56], 8) + random.shuffle(packs) + prizes[:56] = [drop for pack in packs for drop in pack] + + if world.difficulty_adjustments in ['hard', 'expert']: prize_replacements = {0xE0: 0xDF, # Fairy -> heart 0xE3: 0xD8} # Big magic -> small magic prizes = [prize_replacements.get(prize, prize) for prize in prizes] @@ -543,7 +708,6 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): prizes = [prize_replacements.get(prize, prize) for prize in prizes] dig_prizes = [prize_replacements.get(prize, prize) for prize in dig_prizes] rom.write_bytes(0x180100, dig_prizes) - random.shuffle(prizes) # write tree pull prizes rom.write_byte(0xEFBD4, prizes.pop()) @@ -563,28 +727,6 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): # fill enemy prize packs rom.write_bytes(0x37A78, prizes) - # prize pack drop chances - if world.difficulty in ['hard', 'expert', 'insane']: - droprates = [0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04] # 50%, 25%, 3* 12.5%, 2* 6.25% - else: - droprates = [0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01] # 50% - - random.shuffle(droprates) - rom.write_bytes(0x37A62, droprates) - - vanilla_prize_pack_assignment = [131, 150, 132, 128, 128, 128, 128, 128, 2, 0, 2, 128, 160, 131, 151, 128, 128, 148, 145, 7, 0, 128, 0, 128, 146, 150, 128, 160, 0, 0, 0, 128, 4, 128, - 130, 6, 6, 0, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 128, 128, 144, 128, 145, 145, - 145, 151, 145, 149, 149, 147, 151, 20, 145, 146, 129, 130, 130, 128, 133, 128, 128, 128, 4, 4, 128, 145, 128, 128, 128, 128, 128, 128, 128, 128, 0, 128, - 128, 130, 138, 128, 128, 128, 128, 146, 145, 128, 130, 129, 129, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 151, 128, 128, 128, 128, 194, - 128, 21, 21, 23, 6, 0, 128, 0, 192, 19, 64, 0, 2, 6, 16, 20, 0, 0, 64, 0, 0, 0, 0, 19, 70, 17, 128, 128, 0, 0, 0, 16, 0, 0, 0, 22, 22, 22, 129, 135, 130, - 0, 128, 128, 0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 23, 0, 18, 0, 0, 0, 0, 0, 16, 23, 0, 64, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0] - - # shuffle enemies to prize packs - for i in range(243): - if vanilla_prize_pack_assignment[i] & 0x0F != 0x00: - rom.write_byte(0x6B632 + i, (vanilla_prize_pack_assignment[i] & 0xF0) | random.randint(1, 7)) - # set bonk prizes bonk_prizes = [0x79, 0xE3, 0x79, 0xAC, 0xAC, 0xE0, 0xDC, 0xAC, 0xE3, 0xE3, 0xDA, 0xE3, 0xDA, 0xD8, 0xAC, 0xAC, 0xE3, 0xD8, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xDC, 0xDB, 0xE3, 0xDA, 0x79, 0x79, 0xE3, 0xE3, 0xDA, 0x79, 0xAC, 0xAC, 0x79, 0xE3, 0x79, 0xAC, 0xAC, 0xE0, 0xDC, 0xE3, 0x79, 0xDE, 0xE3, 0xAC, 0xDB, 0x79, 0xE3, 0xD8, 0xAC, 0x79, 0xE3, 0xDB, 0xDB, 0xE3, 0xE3, 0x79, 0xD8, 0xDD] @@ -598,26 +740,19 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_byte(address, prize) # Fill in item substitutions table - if world.difficulty in ['easy']: - rom.write_bytes(0x184000, [ - # original_item, limit, replacement_item, filler - 0x12, 0x01, 0x35, 0xFF, # lamp -> 5 rupees - 0x58, 0x01, 0x43, 0xFF, # silver arrows -> 1 arrow - 0x51, 0x06, 0x52, 0xFF, # 6 +5 bomb upgrades -> +10 bomb upgrade - 0x53, 0x06, 0x54, 0xFF, # 6 +5 arrow upgrades -> +10 arrow upgrade - 0xFF, 0xFF, 0xFF, 0xFF, # end of table sentinel - ]) - else: - rom.write_bytes(0x184000, [ - # original_item, limit, replacement_item, filler - 0x12, 0x01, 0x35, 0xFF, # lamp -> 5 rupees - 0x51, 0x06, 0x52, 0xFF, # 6 +5 bomb upgrades -> +10 bomb upgrade - 0x53, 0x06, 0x54, 0xFF, # 6 +5 arrow upgrades -> +10 arrow upgrade - 0xFF, 0xFF, 0xFF, 0xFF, # end of table sentinel - ]) + rom.write_bytes(0x184000, [ + # original_item, limit, replacement_item, filler + 0x12, 0x01, 0x35, 0xFF, # lamp -> 5 rupees + 0x51, 0x06, 0x52, 0xFF, # 6 +5 bomb upgrades -> +10 bomb upgrade + 0x53, 0x06, 0x54, 0xFF, # 6 +5 arrow upgrades -> +10 arrow upgrade + 0x58, 0x01, 0x36 if world.retro else 0x43, 0xFF, # silver arrows -> single arrow (red 20 in retro mode) + 0x3E, difficulty.boss_heart_container_limit, 0x47, 0xff, # boss heart -> green 20 + 0x17, difficulty.heart_piece_limit, 0x47, 0xff, # piece of heart -> green 20 + 0xFF, 0xFF, 0xFF, 0xFF, # end of table sentinel + ]) # set Fountain bottle exchange items - if world.difficulty in ['hard', 'expert', 'insane']: + if world.difficulty in ['hard', 'expert']: rom.write_byte(0x348FF, [0x16, 0x2B, 0x2C, 0x2D, 0x3C, 0x48][random.randint(0, 5)]) rom.write_byte(0x3493B, [0x16, 0x2B, 0x2C, 0x2D, 0x3C, 0x48][random.randint(0, 5)]) else: @@ -682,9 +817,7 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_int32(0x180200, -100 * 60 * 60 * 60) # red clock adjustment time (in frames, sint32) rom.write_int32(0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32) rom.write_int32(0x180208, 4 * 60 * 60) # green clock adjustment time (in frames, sint32) - if world.difficulty == 'easy': - rom.write_int32(0x18020C, (20 + ERtimeincrease) * 60 * 60) # starting time (in frames, sint32) - elif world.difficulty == 'normal': + if world.difficulty_adjustments == 'normal': rom.write_int32(0x18020C, (10 + ERtimeincrease) * 60 * 60) # starting time (in frames, sint32) else: rom.write_int32(0x18020C, int((5 + ERtimeincrease / 2) * 60 * 60)) # starting time (in frames, sint32) @@ -704,6 +837,7 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): # set up goals for treasure hunt rom.write_bytes(0x180165, [0x0E, 0x28] if world.treasure_hunt_icon == 'Triforce Piece' else [0x0D, 0x28]) rom.write_byte(0x180167, world.treasure_hunt_count % 256) + rom.write_byte(0x180194, 1) # Must turn in triforced pieces (instant win not enabled) # TODO: a proper race rom mode should be implemented, that changes the following flag, and rummages the table (or uses the future encryption feature, etc) rom.write_bytes(0x180213, [0x00, 0x01]) # Not a Tournament Seed @@ -711,9 +845,11 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_byte(0x180211, 0x06) #Game type, we set the Entrance and item randomization flags # assorted fixes - rom.write_byte(0x1800A2, 0x01) # remain in real dark world when dying in dark word dungion before killing aga1 + rom.write_byte(0x1800A2, 0x01) # remain in real dark world when dying in dark world dungeon before killing aga1 rom.write_byte(0x180169, 0x01 if world.lock_aga_door_in_escape else 0x00) # Lock or unlock aga tower door during escape sequence. - rom.write_byte(0x180171, 0x01 if world.ganon_at_pyramid else 0x00) # Enable respawning on pyramid after ganon death + if world.mode == 'inverted': + rom.write_byte(0x180169, 0x02) # lock aga/ganon tower door with crystals in inverted + rom.write_byte(0x180171, 0x01 if world.ganon_at_pyramid[player] else 0x00) # Enable respawning on pyramid after ganon death rom.write_byte(0x180173, 0x01) # Bob is enabled rom.write_byte(0x180168, 0x08) # Spike Cave Damage rom.write_bytes(0x18016B, [0x04, 0x02, 0x01]) #Set spike cave and MM spike room Cape usage @@ -721,6 +857,8 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_bytes(0x50563, [0x3F, 0x14]) # disable below ganon chest rom.write_byte(0x50599, 0x00) # disable below ganon chest rom.write_bytes(0xE9A5, [0x7E, 0x00, 0x24]) # disable below ganon chest + rom.write_byte(0x18008B, 0x00) # Pyramid Hole not pre-opened + rom.write_byte(0x18008C, 0x01 if world.crystals_needed_for_gt == 0 else 0x00) # Pyramid Hole pre-opened if crystal requirement is 0 rom.write_byte(0xF5D73, 0xF0) # bees are catchable rom.write_byte(0xF5F10, 0xF0) # bees are catchable rom.write_byte(0x180086, 0x00 if world.aga_randomness else 0x01) # set blue ball and ganon warp randomness @@ -735,22 +873,28 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_byte(0x18302C, 0x18) # starting max health rom.write_byte(0x18302D, 0x18) # starting current health rom.write_byte(0x183039, 0x68) # starting abilities, bit array - rom.write_byte(0x18004A, 0x00) # Inverted mode (off) + + for item in world.precollected_items: + if item.player != player: + continue + + if item.name == 'Fighter Sword': + rom.write_byte(0x183000+0x19, 0x01) + rom.write_byte(0x0271A6+0x19, 0x01) + rom.write_byte(0x180043, 0x01) # special starting sword byte + else: + raise RuntimeError("Unsupported pre-collected item: {}".format(item)) + + rom.write_byte(0x18004A, 0x00 if world.mode != 'inverted' else 0x01) # Inverted mode rom.write_byte(0x18005D, 0x00) # Hammer always breaks barrier - rom.write_byte(0x2AF79, 0xD0) # vortexes: Normal (D0=light to dark, F0=dark to light, 42 = both) - rom.write_byte(0x3A943, 0xD0) # Mirror: Normal (D0=Dark to Light, F0=light to dark, 42 = both) - rom.write_byte(0x3A96D, 0xF0) # Residual Portal: Normal (F0= Light Side, D0=Dark Side, 42 = both (Darth Vader)) + rom.write_byte(0x2AF79, 0xD0 if world.mode != 'inverted' else 0xF0) # vortexes: Normal (D0=light to dark, F0=dark to light, 42 = both) + rom.write_byte(0x3A943, 0xD0 if world.mode != 'inverted' else 0xF0) # Mirror: Normal (D0=Dark to Light, F0=light to dark, 42 = both) + rom.write_byte(0x3A96D, 0xF0 if world.mode != 'inverted' else 0xD0) # Residual Portal: Normal (F0= Light Side, D0=Dark Side, 42 = both (Darth Vader)) rom.write_byte(0x3A9A7, 0xD0) # Residual Portal: Normal (D0= Light Side, F0=Dark Side, 42 = both (Darth Vader)) rom.write_bytes(0x180080, [50, 50, 70, 70]) # values to fill for Capacity Upgrades (Bomb5, Bomb10, Arrow5, Arrow10) rom.write_byte(0x18004D, 0x00) # Escape assist (off) - rom.write_byte(0x18004E, 0x00) # escape fills - rom.write_int16(0x180183, 0) # rupee fill (for bow if rupee arrows enabled) - rom.write_bytes(0x180185, [0x00, 0x00, 0x00]) # uncle item refills - rom.write_bytes(0x180188, [0x00, 0x00, 0x00]) # zelda item refills - rom.write_bytes(0x18018B, [0x00, 0x00, 0x00]) # uncle item refills - if world.goal in ['pedestal', 'triforcehunt']: rom.write_byte(0x18003E, 0x01) # make ganon invincible @@ -761,20 +905,49 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): else: rom.write_byte(0x18003E, 0x03) # make ganon invincible until all crystals and aga 2 are collected + rom.write_byte(0x18005E, world.crystals_needed_for_gt) + rom.write_byte(0x18005F, world.crystals_needed_for_ganon) + rom.write_byte(0x18008A, 0x01 if world.mode == "standard" else 0x00) # block HC upstairs doors in rain state in standard mode + rom.write_byte(0x18016A, 0x01 if world.keysanity else 0x00) # free roaming item text boxes rom.write_byte(0x18003B, 0x01 if world.keysanity else 0x00) # maps showing crystals on overworld # compasses showing dungeon count if world.clock_mode != 'off': rom.write_byte(0x18003C, 0x00) # Currently must be off if timer is on, because they use same HUD location - elif world.difficulty == 'easy': - rom.write_byte(0x18003C, 0x02) # always on elif world.keysanity: rom.write_byte(0x18003C, 0x01) # show on pickup else: rom.write_byte(0x18003C, 0x00) rom.write_byte(0x180045, 0xFF if world.keysanity else 0x00) # free roaming items in menu + + # Map reveals + reveal_bytes = { + "Eastern Palace": 0x2000, + "Desert Palace": 0x1000, + "Tower of Hera": 0x0020, + "Palace of Darkness": 0x0200, + "Thieves Town": 0x0010, + "Skull Woods": 0x0080, + "Swamp Palace": 0x0400, + "Ice Palace": 0x0040, + "Misery Mire'": 0x0100, + "Turtle Rock": 0x0008, + } + + def get_reveal_bytes(itemName): + locations = world.find_items(itemName, player) + if len(locations) < 1: + return 0x0000 + location = locations[0] + if location.parent_region and location.parent_region.dungeon: + return reveal_bytes.get(location.parent_region.dungeon.name, 0x0000) + return 0x0000 + + rom.write_int16(0x18017A, get_reveal_bytes('Green Pendant') if world.keysanity else 0x0000) # Sahasrahla reveal + rom.write_int16(0x18017C, get_reveal_bytes('Crystal 5')|get_reveal_bytes('Crystal 6') if world.keysanity else 0x0000) # Bomb Shop Reveal + rom.write_byte(0x180172, 0x01 if world.retro else 0x00) # universal keys rom.write_byte(0x180175, 0x01 if world.retro else 0x00) # rupee bow rom.write_byte(0x180176, 0x0A if world.retro else 0x00) # wood arrow cost @@ -800,19 +973,38 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_bytes(0x6D2FB, [0x00, 0x00, 0xf7, 0xff, 0x02, 0x0E]) rom.write_bytes(0x6D313, [0x00, 0x00, 0xe4, 0xff, 0x08, 0x0E]) - # patch swamp: Need to enable permanent drain of water as dam or swamp were moved - rom.write_byte(0x18003D, 0x01 if world.swamp_patch_required else 0x00) + rom.write_byte(0x18004E, 0) # Escape Fill (nothing) + rom.write_int16(0x180183, 300) # Escape fill rupee bow + rom.write_bytes(0x180185, [0,0,0]) # Uncle respawn refills (magic, bombs, arrows) + rom.write_bytes(0x180188, [0,0,0]) # Zelda respawn refills (magic, bombs, arrows) + rom.write_bytes(0x18018B, [0,0,0]) # Mantle respawn refills (magic, bombs, arrows) + if world.mode == 'standard': + if uncle_location.item is not None and uncle_location.item.name in ['Bow', 'Progressive Bow']: + rom.write_byte(0x18004E, 1) # Escape Fill (arrows) + rom.write_int16(0x180183, 300) # Escape fill rupee bow + rom.write_bytes(0x180185, [0,0,70]) # Uncle respawn refills (magic, bombs, arrows) + rom.write_bytes(0x180188, [0,0,10]) # Zelda respawn refills (magic, bombs, arrows) + rom.write_bytes(0x18018B, [0,0,10]) # Mantle respawn refills (magic, bombs, arrows) + elif uncle_location.item is not None and uncle_location.item.name in ['Cane of Somaria', 'Cane of Byrna', 'Fire Rod']: + rom.write_byte(0x18004E, 4) # Escape Fill (magic) + rom.write_bytes(0x180185, [0x80,0,0]) # Uncle respawn refills (magic, bombs, arrows) + rom.write_bytes(0x180188, [0x20,0,0]) # Zelda respawn refills (magic, bombs, arrows) + rom.write_bytes(0x18018B, [0x20,0,0]) # Mantle respawn refills (magic, bombs, arrows) - # powder patch: remove the need to leave the scrren after powder, since it causes problems for potion shop at race game + # patch swamp: Need to enable permanent drain of water as dam or swamp were moved + rom.write_byte(0x18003D, 0x01 if world.swamp_patch_required[player] else 0x00) + + # powder patch: remove the need to leave the screen after powder, since it causes problems for potion shop at race game # temporarally we are just nopping out this check we will conver this to a rom fix soon. - rom.write_bytes(0x02F539, [0xEA, 0xEA, 0xEA, 0xEA, 0xEA] if world.powder_patch_required else [0xAD, 0xBF, 0x0A, 0xF0, 0x4F]) + rom.write_bytes(0x02F539, [0xEA, 0xEA, 0xEA, 0xEA, 0xEA] if world.powder_patch_required[player] else [0xAD, 0xBF, 0x0A, 0xF0, 0x4F]) # allow smith into multi-entrance caves in appropriate shuffles if world.shuffle in ['restricted', 'full', 'crossed', 'insanity']: rom.write_byte(0x18004C, 0x01) # set correct flag for hera basement item - if world.get_location('Tower of Hera - Basement Cage').item is not None and world.get_location('Tower of Hera - Basement Cage').item.name == 'Small Key (Tower of Hera)': + hera_basement = world.get_location('Tower of Hera - Basement Cage', player) + if hera_basement.item is not None and hera_basement.item.name == 'Small Key (Tower of Hera)' and hera_basement.item.player == player: rom.write_byte(0x4E3BB, 0xE4) else: rom.write_byte(0x4E3BB, 0xEB) @@ -827,11 +1019,14 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): rom.write_byte(0xFED31, 0x2A) # preopen bombable exit rom.write_byte(0xFEE41, 0x2A) # preopen bombable exit - write_strings(rom, world) + write_strings(rom, world, player) # set rom name # 21 bytes - rom.write_bytes(0x7FC0, bytearray('ER_062_%09d\0' % world.seed, 'utf8') + world.option_identifier.to_bytes(4, 'big')) + from Main import __version__ + rom.name = bytearray('ER_{0}_{1:09}\0'.format(__version__[0:7],world.seed), 'utf8') + assert len(rom.name) <= 21 + rom.write_bytes(0x7FC0, rom.name) # Write title screen Code hashint = int(rom.get_hash(), 16) @@ -844,12 +1039,10 @@ def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): ] rom.write_bytes(0x180215, code) - apply_rom_settings(rom, beep, color, world.quickswap, world.fastmenu, world.disable_music, sprite) - return rom -def write_custom_shops(rom, world): - shops = [shop for shop in world.shops if shop.replaceable and shop.active] +def write_custom_shops(rom, world, player): + shops = [shop for shop in world.shops if shop.replaceable and shop.active and shop.region.player == player] shop_data = bytearray() items_data = bytearray() @@ -870,7 +1063,7 @@ def write_custom_shops(rom, world): for item in shop.inventory: if item is None: break - item_data = [shop_id, ItemFactory(item['item']).code] + int16_as_bytes(item['price']) + [item['max'], ItemFactory(item['replacement']).code if item['replacement'] else 0xFF] + int16_as_bytes(item['replacement_price']) + item_data = [shop_id, ItemFactory(item['item'], player).code] + int16_as_bytes(item['price']) + [item['max'], ItemFactory(item['replacement'], player).code if item['replacement'] else 0xFF] + int16_as_bytes(item['replacement_price']) items_data.extend(item_data) rom.write_bytes(0x184800, shop_data) @@ -906,64 +1099,7 @@ def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, spr rom.write_byte(0x18004B, 0x01 if quickswap else 0x00) - music_volumes = [ - (0x00, [0xD373B, 0xD375B, 0xD90F8]), - (0x14, [0xDA710, 0xDA7A4, 0xDA7BB, 0xDA7D2]), - (0x3C, [0xD5954, 0xD653B, 0xDA736, 0xDA752, 0xDA772, 0xDA792]), - (0x50, [0xD5B47, 0xD5B5E]), - (0x54, [0xD4306]), - (0x64, [0xD6878, 0xD6883, 0xD6E48, 0xD6E76, 0xD6EFB, 0xD6F2D, 0xDA211, 0xDA35B, 0xDA37B, 0xDA38E, 0xDA39F, 0xDA5C3, 0xDA691, 0xDA6A8, 0xDA6DF]), - (0x78, [0xD2349, 0xD3F45, 0xD42EB, 0xD48B9, 0xD48FF, 0xD543F, 0xD5817, 0xD5957, 0xD5ACB, 0xD5AE8, 0xD5B4A, 0xDA5DE, 0xDA608, 0xDA635, - 0xDA662, 0xDA71F, 0xDA7AF, 0xDA7C6, 0xDA7DD]), - (0x82, [0xD2F00, 0xDA3D5]), - (0xA0, [0xD249C, 0xD24CD, 0xD2C09, 0xD2C53, 0xD2CAF, 0xD2CEB, 0xD2D91, 0xD2EE6, 0xD38ED, 0xD3C91, 0xD3CD3, 0xD3CE8, 0xD3F0C, - 0xD3F82, 0xD405F, 0xD4139, 0xD4198, 0xD41D5, 0xD41F6, 0xD422B, 0xD4270, 0xD42B1, 0xD4334, 0xD4371, 0xD43A6, 0xD43DB, - 0xD441E, 0xD4597, 0xD4B3C, 0xD4BAB, 0xD4C03, 0xD4C53, 0xD4C7F, 0xD4D9C, 0xD5424, 0xD65D2, 0xD664F, 0xD6698, 0xD66FF, - 0xD6985, 0xD6C5C, 0xD6C6F, 0xD6C8E, 0xD6CB4, 0xD6D7D, 0xD827D, 0xD960C, 0xD9828, 0xDA233, 0xDA3A2, 0xDA49E, 0xDA72B, - 0xDA745, 0xDA765, 0xDA785, 0xDABF6, 0xDAC0D, 0xDAEBE, 0xDAFAC]), - (0xAA, [0xD9A02, 0xD9BD6]), - (0xB4, [0xD21CD, 0xD2279, 0xD2E66, 0xD2E70, 0xD2EAB, 0xD3B97, 0xD3BAC, 0xD3BE8, 0xD3C0D, 0xD3C39, 0xD3C68, 0xD3C9F, 0xD3CBC, - 0xD401E, 0xD4290, 0xD443E, 0xD456F, 0xD47D3, 0xD4D43, 0xD4DCC, 0xD4EBA, 0xD4F0B, 0xD4FE5, 0xD5012, 0xD54BC, 0xD54D5, - 0xD54F0, 0xD5509, 0xD57D8, 0xD59B9, 0xD5A2F, 0xD5AEB, 0xD5E5E, 0xD5FE9, 0xD658F, 0xD674A, 0xD6827, 0xD69D6, 0xD69F5, - 0xD6A05, 0xD6AE9, 0xD6DCF, 0xD6E20, 0xD6ECB, 0xD71D4, 0xD71E6, 0xD7203, 0xD721E, 0xD8724, 0xD8732, 0xD9652, 0xD9698, - 0xD9CBC, 0xD9DC0, 0xD9E49, 0xDAA68, 0xDAA77, 0xDAA88, 0xDAA99, 0xDAF04]), - (0x8c, [0xD1D28, 0xD1D41, 0xD1D5C, 0xD1D77, 0xD1EEE, 0xD311D, 0xD31D1, 0xD4148, 0xD5543, 0xD5B6F, 0xD65B3, 0xD6760, 0xD6B6B, - 0xD6DF6, 0xD6E0D, 0xD73A1, 0xD814C, 0xD825D, 0xD82BE, 0xD8340, 0xD8394, 0xD842C, 0xD8796, 0xD8903, 0xD892A, 0xD91E8, - 0xD922B, 0xD92E0, 0xD937E, 0xD93C1, 0xDA958, 0xDA971, 0xDA98C, 0xDA9A7]), - (0xC8, [0xD1D92, 0xD1DBD, 0xD1DEB, 0xD1F5D, 0xD1F9F, 0xD1FBD, 0xD1FDC, 0xD1FEA, 0xD20CA, 0xD21BB, 0xD22C9, 0xD2754, 0xD284C, - 0xD2866, 0xD2887, 0xD28A0, 0xD28BA, 0xD28DB, 0xD28F4, 0xD293E, 0xD2BF3, 0xD2C1F, 0xD2C69, 0xD2CA1, 0xD2CC5, 0xD2D05, - 0xD2D73, 0xD2DAF, 0xD2E3D, 0xD2F36, 0xD2F46, 0xD2F6F, 0xD2FCF, 0xD2FDF, 0xD302B, 0xD3086, 0xD3099, 0xD30A5, 0xD30CD, - 0xD30F6, 0xD3154, 0xD3184, 0xD333A, 0xD33D9, 0xD349F, 0xD354A, 0xD35E5, 0xD3624, 0xD363C, 0xD3672, 0xD3691, 0xD36B4, - 0xD36C6, 0xD3724, 0xD3767, 0xD38CB, 0xD3B1D, 0xD3B2F, 0xD3B55, 0xD3B70, 0xD3B81, 0xD3BBF, 0xD3F65, 0xD3FA6, 0xD404F, - 0xD4087, 0xD417A, 0xD41A0, 0xD425C, 0xD4319, 0xD433C, 0xD43EF, 0xD440C, 0xD4452, 0xD4494, 0xD44B5, 0xD4512, 0xD45D1, - 0xD45EF, 0xD4682, 0xD46C3, 0xD483C, 0xD4848, 0xD4855, 0xD4862, 0xD486F, 0xD487C, 0xD4A1C, 0xD4A3B, 0xD4A60, 0xD4B27, - 0xD4C7A, 0xD4D12, 0xD4D81, 0xD4E90, 0xD4ED6, 0xD4EE2, 0xD5005, 0xD502E, 0xD503C, 0xD5081, 0xD51B1, 0xD51C7, 0xD51CF, - 0xD51EF, 0xD520C, 0xD5214, 0xD5231, 0xD5257, 0xD526D, 0xD5275, 0xD52AF, 0xD52BD, 0xD52CD, 0xD52DB, 0xD549C, 0xD5801, - 0xD58A4, 0xD5A68, 0xD5A7F, 0xD5C12, 0xD5D71, 0xD5E10, 0xD5E9A, 0xD5F8B, 0xD5FA4, 0xD651A, 0xD6542, 0xD65ED, 0xD661D, - 0xD66D7, 0xD6776, 0xD68BD, 0xD68E5, 0xD6956, 0xD6973, 0xD69A8, 0xD6A51, 0xD6A86, 0xD6B96, 0xD6C3E, 0xD6D4A, 0xD6E9C, - 0xD6F80, 0xD717E, 0xD7190, 0xD71B9, 0xD811D, 0xD8139, 0xD816B, 0xD818A, 0xD819E, 0xD81BE, 0xD829C, 0xD82E1, 0xD8306, - 0xD830E, 0xD835E, 0xD83AB, 0xD83CA, 0xD83F0, 0xD83F8, 0xD844B, 0xD8479, 0xD849E, 0xD84CB, 0xD84EB, 0xD84F3, 0xD854A, - 0xD8573, 0xD859D, 0xD85B4, 0xD85CE, 0xD862A, 0xD8681, 0xD87E3, 0xD87FF, 0xD887B, 0xD88C6, 0xD88E3, 0xD8944, 0xD897B, - 0xD8C97, 0xD8CA4, 0xD8CB3, 0xD8CC2, 0xD8CD1, 0xD8D01, 0xD917B, 0xD918C, 0xD919A, 0xD91B5, 0xD91D0, 0xD91DD, 0xD9220, - 0xD9273, 0xD9284, 0xD9292, 0xD92AD, 0xD92C8, 0xD92D5, 0xD9311, 0xD9322, 0xD9330, 0xD934B, 0xD9366, 0xD9373, 0xD93B6, - 0xD97A6, 0xD97C2, 0xD97DC, 0xD97FB, 0xD9811, 0xD98FF, 0xD996F, 0xD99A8, 0xD99D5, 0xD9A30, 0xD9A4E, 0xD9A6B, 0xD9A88, - 0xD9AF7, 0xD9B1D, 0xD9B43, 0xD9B7C, 0xD9BA9, 0xD9C84, 0xD9C8D, 0xD9CAC, 0xD9CE8, 0xD9CF3, 0xD9CFD, 0xD9D46, 0xDA35E, - 0xDA37E, 0xDA391, 0xDA478, 0xDA4C3, 0xDA4D7, 0xDA4F6, 0xDA515, 0xDA6E2, 0xDA9C2, 0xDA9ED, 0xDAA1B, 0xDAA57, 0xDABAF, - 0xDABC9, 0xDABE2, 0xDAC28, 0xDAC46, 0xDAC63, 0xDACB8, 0xDACEC, 0xDAD08, 0xDAD25, 0xDAD42, 0xDAD5F, 0xDAE17, 0xDAE34, - 0xDAE51, 0xDAF2E, 0xDAF55, 0xDAF6B, 0xDAF81, 0xDB14F, 0xDB16B, 0xDB180, 0xDB195, 0xDB1AA]), - (0xD2, [0xD2B88, 0xD364A, 0xD369F, 0xD3747]), - (0xDC, [0xD213F, 0xD2174, 0xD229E, 0xD2426, 0xD4731, 0xD4753, 0xD4774, 0xD4795, 0xD47B6, 0xD4AA5, 0xD4AE4, 0xD4B96, 0xD4CA5, - 0xD5477, 0xD5A3D, 0xD6566, 0xD672C, 0xD67C0, 0xD69B8, 0xD6AB1, 0xD6C05, 0xD6DB3, 0xD71AB, 0xD8E2D, 0xD8F0D, 0xD94E0, - 0xD9544, 0xD95A8, 0xD9982, 0xD9B56, 0xDA694, 0xDA6AB, 0xDAE88, 0xDAEC8, 0xDAEE6, 0xDB1BF]), - (0xE6, [0xD210A, 0xD22DC, 0xD2447, 0xD5A4D, 0xD5DDC, 0xDA251, 0xDA26C]), - (0xF0, [0xD945E, 0xD967D, 0xD96C2, 0xD9C95, 0xD9EE6, 0xDA5C6]), - (0xFA, [0xD2047, 0xD24C2, 0xD24EC, 0xD25A4, 0xD51A8, 0xD51E6, 0xD524E, 0xD529E, 0xD6045, 0xD81DE, 0xD821E, 0xD94AA, 0xD9A9E, - 0xD9AE4, 0xDA289]), - (0xFF, [0xD2085, 0xD21C5, 0xD5F28]) - ] - for volume, addresses in music_volumes: - for address in addresses: - rom.write_byte(address, volume if not disable_music else 0x00) + rom.write_byte(0x18021A, 1 if disable_music else 0x00) # restore Mirror sound effect volumes (for existing seeds that lack it) rom.write_byte(0xD3E04, 0xC8) @@ -1013,7 +1149,7 @@ def write_string_to_rom(rom, target, string): rom.write_bytes(address, MultiByteTextMapper.convert(string, maxbytes)) -def write_strings(rom, world): +def write_strings(rom, world, player): tt = TextTable() tt.removeUnwantedText() @@ -1022,6 +1158,17 @@ def write_strings(rom, world): tt['kakariko_flophouse_man_no_flippers'] = 'I really hate mowing my yard.\n{PAGEBREAK}\nI should move.' tt['kakariko_flophouse_man'] = 'I really hate mowing my yard.\n{PAGEBREAK}\nI should move.' + def hint_text(dest, ped_hint=False): + hint = dest.hint_text if not ped_hint else dest.pedestal_hint_text + if dest.player != player: + if ped_hint: + hint += " for p%d!" % dest.player + elif type(dest) in [Region, Location]: + hint += " in p%d's world" % dest.player + elif type(dest) is Item: + hint += " for p%d" % dest.player + return hint + # For hints, first we write hints about entrances, some from the inconvenient list others from all reasonable entrances. if world.hints: tt['sign_north_of_links_house'] = '> Randomizer The telepathic tiles can have hints!' @@ -1031,16 +1178,17 @@ def write_strings(rom, world): entrances_to_hint.update({'Ganons Tower': 'Ganon\'s Tower'}) hint_locations = HintLocations.copy() random.shuffle(hint_locations) - all_entrances = world.get_entrances() + all_entrances = [entrance for entrance in world.get_entrances() if entrance.player == player] random.shuffle(all_entrances) - hint_count = 4 + hint_count = 4 if world.shuffle != 'vanilla' else 0 for entrance in all_entrances: if entrance.name in entrances_to_hint: - this_hint = entrances_to_hint[entrance.name] + ' leads to ' + entrance.connected_region.hint_text + '.' - tt[hint_locations.pop(0)] = this_hint - entrances_to_hint.pop(entrance.name) - hint_count -= 1 - if hint_count < 1: + if hint_count > 0: + this_hint = entrances_to_hint[entrance.name] + ' leads to ' + hint_text(entrance.connected_region) + '.' + tt[hint_locations.pop(0)] = this_hint + entrances_to_hint.pop(entrance.name) + hint_count -= 1 + else: break entrances_to_hint.update(OtherEntrances) @@ -1048,57 +1196,58 @@ def write_strings(rom, world): entrances_to_hint.update(InsanityEntrances) if world.shuffle_ganon: entrances_to_hint.update({'Pyramid Ledge': 'The pyramid ledge'}) - hint_count = 4 + hint_count = 4 if world.shuffle != 'vanilla' else 0 for entrance in all_entrances: if entrance.name in entrances_to_hint: - this_hint = entrances_to_hint[entrance.name] + ' leads to ' + entrance.connected_region.hint_text + '.' - tt[hint_locations.pop(0)] = this_hint - entrances_to_hint.pop(entrance.name) - hint_count -= 1 - if hint_count < 1: + if hint_count > 0: + this_hint = entrances_to_hint[entrance.name] + ' leads to ' + hint_text(entrance.connected_region) + '.' + tt[hint_locations.pop(0)] = this_hint + entrances_to_hint.pop(entrance.name) + hint_count -= 1 + else: break # Next we write a few hints for specific inconvenient locations. We don't make many because in entrance this is highly unpredictable. locations_to_hint = InconvenientLocations.copy() random.shuffle(locations_to_hint) - hint_count = 3 - del locations_to_hint[hint_count:] + hint_count = 3 if world.shuffle != 'vanilla' else 4 + del locations_to_hint[hint_count:] for location in locations_to_hint: if location == 'Swamp Left': if random.randint(0, 1) == 0: - first_item = world.get_location('Swamp Palace - West Chest').item.hint_text - second_item = world.get_location('Swamp Palace - Big Key Chest').item.hint_text + first_item = hint_text(world.get_location('Swamp Palace - West Chest', player).item) + second_item = hint_text(world.get_location('Swamp Palace - Big Key Chest', player).item) else: - second_item = world.get_location('Swamp Palace - West Chest').item.hint_text - first_item = world.get_location('Swamp Palace - Big Key Chest').item.hint_text + second_item = hint_text(world.get_location('Swamp Palace - West Chest', player).item) + first_item = hint_text(world.get_location('Swamp Palace - Big Key Chest', player).item) this_hint = ('The westmost chests in Swamp Palace contain ' + first_item + ' and ' + second_item + '.') tt[hint_locations.pop(0)] = this_hint elif location == 'Mire Left': if random.randint(0, 1) == 0: - first_item = world.get_location('Misery Mire - Compass Chest').item.hint_text - second_item = world.get_location('Misery Mire - Big Key Chest').item.hint_text + first_item = hint_text(world.get_location('Misery Mire - Compass Chest', player).item) + second_item = hint_text(world.get_location('Misery Mire - Big Key Chest', player).item) else: - second_item = world.get_location('Misery Mire - Compass Chest').item.hint_text - first_item = world.get_location('Misery Mire - Big Key Chest').item.hint_text + second_item = hint_text(world.get_location('Misery Mire - Compass Chest', player).item) + first_item = hint_text(world.get_location('Misery Mire - Big Key Chest', player).item) this_hint = ('The westmost chests in Misery Mire contain ' + first_item + ' and ' + second_item + '.') tt[hint_locations.pop(0)] = this_hint elif location == 'Tower of Hera - Big Key Chest': - this_hint = 'Waiting in the Tower of Hera basement leads to ' + world.get_location(location).item.hint_text + '.' + this_hint = 'Waiting in the Tower of Hera basement leads to ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint elif location == 'Ganons Tower - Big Chest': - this_hint = 'The big chest in Ganon\'s Tower contains ' + world.get_location(location).item.hint_text + '.' + this_hint = 'The big chest in Ganon\'s Tower contains ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint elif location == 'Thieves\' Town - Big Chest': - this_hint = 'The big chest in Thieves\' Town contains ' + world.get_location(location).item.hint_text + '.' + this_hint = 'The big chest in Thieves\' Town contains ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint elif location == 'Ice Palace - Big Chest': - this_hint = 'The big chest in Ice Palace contains ' + world.get_location(location).item.hint_text + '.' + this_hint = 'The big chest in Ice Palace contains ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint elif location == 'Eastern Palace - Big Key Chest': - this_hint = 'The antifairy guarded chest in Eastern Palace contains ' + world.get_location(location).item.hint_text + '.' + this_hint = 'The antifairy guarded chest in Eastern Palace contains ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint else: - this_hint = location + ' leads to ' + world.get_location(location).item.hint_text + '.' + this_hint = location + ' leads to ' + hint_text(world.get_location(location, player).item) + '.' tt[hint_locations.pop(0)] = this_hint # Lastly we write hints to show where certain interesting items are. It is done the way it is to re-use the silver code and also to give one hint per each type of item regardless of how many exist. This supports many settings well. @@ -1106,17 +1255,15 @@ def write_strings(rom, world): if world.keysanity: items_to_hint.extend(KeysanityItems) random.shuffle(items_to_hint) - hint_count = 5 - while(hint_count > 0): + hint_count = 5 if world.shuffle != 'vanilla' else 7 + while hint_count > 0: this_item = items_to_hint.pop(0) - this_location = world.find_items(this_item) + this_location = world.find_items(this_item, player) random.shuffle(this_location) if this_location: - this_hint = this_location[0].item.hint_text + ' can be found ' + this_location[0].hint_text + '.' + this_hint = this_location[0].item.hint_text + ' can be found ' + hint_text(this_location[0]) + '.' tt[hint_locations.pop(0)] = this_hint hint_count -= 1 - else: - continue # All remaining hint slots are filled with junk hints. It is done this way to ensure the same junk hint isn't selected twice. junk_hints = junk_texts.copy() @@ -1124,19 +1271,43 @@ def write_strings(rom, world): for location in hint_locations: tt[location] = junk_hints.pop(0) - # We still need the older hints of course. Those are done here. - silverarrows = world.find_items('Silver Arrows') - random.shuffle(silverarrows) - silverarrow_hint = (' %s?' % silverarrows[0].hint_text.replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!' - tt['ganon_phase_3'] = 'Did you find the silver arrows%s' % silverarrow_hint + # We still need the older hints of course. Those are done here. - crystal5 = world.find_items('Crystal 5')[0] - crystal6 = world.find_items('Crystal 6')[0] + + silverarrows = world.find_items('Silver Arrows', player) + random.shuffle(silverarrows) + silverarrow_hint = (' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!' + tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint + tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint + + prog_bow_locs = world.find_items('Progressive Bow', player) + distinguished_prog_bow_loc = next((location for location in prog_bow_locs if location.item.code == 0x65), None) + if distinguished_prog_bow_loc: + prog_bow_locs.remove(distinguished_prog_bow_loc) + silverarrow_hint = (' %s?' % hint_text(distinguished_prog_bow_loc).replace('Ganon\'s', 'my')) + tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint + + if any(prog_bow_locs): + silverarrow_hint = (' %s?' % hint_text(random.choice(prog_bow_locs)).replace('Ganon\'s', 'my')) + tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint + + + silverarrow_hint = (' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!' + + + crystal5 = world.find_items('Crystal 5', player)[0] + crystal6 = world.find_items('Crystal 6', player)[0] tt['bomb_shop'] = 'Big Bomb?\nMy supply is blocked until you clear %s and %s.' % (crystal5.hint_text, crystal6.hint_text) - greenpendant = world.find_items('Green Pendant')[0] + greenpendant = world.find_items('Green Pendant', player)[0] tt['sahasrahla_bring_courage'] = 'I lost my family heirloom in %s' % greenpendant.hint_text + tt['sign_ganons_tower'] = ('You need %d crystal to enter.' if world.crystals_needed_for_gt == 1 else 'You need %d crystals to enter.') % world.crystals_needed_for_gt + tt['sign_ganon'] = ('You need %d crystal to beat Ganon.' if world.crystals_needed_for_ganon == 1 else 'You need %d crystals to beat Ganon.') % world.crystals_needed_for_ganon + + if world.goal in ['dungeons']: + tt['sign_ganon'] = 'You need to complete all the dungeons.' + tt['uncle_leaving_text'] = Uncle_texts[random.randint(0, len(Uncle_texts) - 1)] tt['end_triforce'] = "{NOBORDER}\n" + Triforce_texts[random.randint(0, len(Triforce_texts) - 1)] tt['bomb_shop_big_bomb'] = BombShop2_texts[random.randint(0, len(BombShop2_texts) - 1)] @@ -1145,41 +1316,60 @@ def write_strings(rom, world): tt['sahasrahla_quest_have_master_sword'] = Sahasrahla2_texts[random.randint(0, len(Sahasrahla2_texts) - 1)] tt['blind_by_the_light'] = Blind_texts[random.randint(0, len(Blind_texts) - 1)] - if world.goal in ['pedestal', 'triforcehunt']: - tt['ganon_fall_in_alt'] = 'Why are you even here?\n You can\'t even hurt me!' + if world.goal in ['triforcehunt']: + tt['ganon_fall_in_alt'] = 'Why are you even here?\n You can\'t even hurt me! Get the Triforce Pieces.' tt['ganon_phase_3_alt'] = 'Seriously? Go Away, I will not Die.' + tt['sign_ganon'] = 'Go find the Triforce pieces... Ganon is invincible!' + tt['murahdahla'] = "Hello @. I\nam Murahdahla, brother of\nSahasrahla and Aginah. Behold the power of\ninvisibility.\n\n\n\n… … …\n\nWait! you can see me? I knew I should have\nhidden in a hollow tree. If you bring\n%d triforce pieces, I can reassemble it." % world.treasure_hunt_count + elif world.goal in ['pedestal']: + tt['ganon_fall_in_alt'] = 'Why are you even here?\n You can\'t even hurt me! Your goal is at the pedestal.' + tt['ganon_phase_3_alt'] = 'Seriously? Go Away, I will not Die.' + tt['sign_ganon'] = 'You need to get to the pedestal... Ganon is invincible!' else: tt['ganon_fall_in'] = Ganon1_texts[random.randint(0, len(Ganon1_texts) - 1)] tt['ganon_fall_in_alt'] = 'You cannot defeat me until you finish your goal!' tt['ganon_phase_3_alt'] = 'Got wax in\nyour ears?\nI can not die!' + tt['kakariko_tavern_fisherman'] = TavernMan_texts[random.randint(0, len(TavernMan_texts) - 1)] - pedestalitem = world.get_location('Master Sword Pedestal').item - pedestal_text = 'Some Hot Air' if pedestalitem is None else pedestalitem.pedestal_hint_text if pedestalitem.pedestal_hint_text is not None else 'Unknown Item' + pedestalitem = world.get_location('Master Sword Pedestal', player).item + pedestal_text = 'Some Hot Air' if pedestalitem is None else hint_text(pedestalitem, True) if pedestalitem.pedestal_hint_text is not None else 'Unknown Item' tt['mastersword_pedestal_translated'] = pedestal_text pedestal_credit_text = 'and the Hot Air' if pedestalitem is None else pedestalitem.pedestal_credit_text if pedestalitem.pedestal_credit_text is not None else 'and the Unknown Item' - etheritem = world.get_location('Ether Tablet').item - ether_text = 'Some Hot Air' if etheritem is None else etheritem.pedestal_hint_text if etheritem.pedestal_hint_text is not None else 'Unknown Item' + etheritem = world.get_location('Ether Tablet', player).item + ether_text = 'Some Hot Air' if etheritem is None else hint_text(etheritem, True) if etheritem.pedestal_hint_text is not None else 'Unknown Item' tt['tablet_ether_book'] = ether_text - bombositem = world.get_location('Bombos Tablet').item - bombos_text = 'Some Hot Air' if bombositem is None else bombositem.pedestal_hint_text if bombositem.pedestal_hint_text is not None else 'Unknown Item' + bombositem = world.get_location('Bombos Tablet', player).item + bombos_text = 'Some Hot Air' if bombositem is None else hint_text(bombositem, True) if bombositem.pedestal_hint_text is not None else 'Unknown Item' tt['tablet_bombos_book'] = bombos_text + # inverted spawn menu changes + if world.mode == 'inverted': + tt['menu_start_2'] = "{MENU}\n{SPEED0}\n≥@'s house\n Dark Chapel\n{CHOICE3}" + tt['menu_start_3'] = "{MENU}\n{SPEED0}\n≥@'s house\n Dark Chapel\n Mountain Cave\n{CHOICE2}" + tt['intro_main'] = CompressedTextMapper.convert( + "{INTRO}\n Episode III\n{PAUSE3}\n A Link to\n the Past\n" + + "{PAUSE3}\nInverted\n Randomizer\n{PAUSE3}\nAfter mostly disregarding what happened in the first two games.\n" + + "{PAUSE3}\nLink has been transported to the Dark World\n{PAUSE3}\nWhile he was slumbering\n" + + "{PAUSE3}\nWhatever will happen?\n{PAUSE3}\n{CHANGEPIC}\nGanon has moved around all the items in Hyrule.\n" + + "{PAUSE7}\nYou will have to find all the items necessary to beat Ganon.\n" + + "{PAUSE7}\nThis is your chance to be a hero.\n{PAUSE3}\n{CHANGEPIC}\n" + + "You must get the 7 crystals to beat Ganon.\n{PAUSE9}\n{CHANGEPIC}", False) rom.write_bytes(0xE0000, tt.getBytes()) credits = Credits() - sickkiditem = world.get_location('Sick Kid').item + sickkiditem = world.get_location('Sick Kid', player).item sickkiditem_text = random.choice(SickKid_texts) if sickkiditem is None or sickkiditem.sickkid_credit_text is None else sickkiditem.sickkid_credit_text - zoraitem = world.get_location('King Zora').item + zoraitem = world.get_location('King Zora', player).item zoraitem_text = random.choice(Zora_texts) if zoraitem is None or zoraitem.zora_credit_text is None else zoraitem.zora_credit_text - magicshopitem = world.get_location('Potion Shop').item + magicshopitem = world.get_location('Potion Shop', player).item magicshopitem_text = random.choice(MagicShop_texts) if magicshopitem is None or magicshopitem.magicshop_credit_text is None else magicshopitem.magicshop_credit_text - fluteboyitem = world.get_location('Flute Spot').item + fluteboyitem = world.get_location('Flute Spot', player).item fluteboyitem_text = random.choice(FluteBoy_texts) if fluteboyitem is None or fluteboyitem.fluteboy_credit_text is None else fluteboyitem.fluteboy_credit_text credits.update_credits_line('castle', 0, random.choice(KingsReturn_texts)) @@ -1204,6 +1394,219 @@ def write_strings(rom, world): rom.write_bytes(0x181500, data) rom.write_bytes(0x76CC0, [byte for p in pointers for byte in [p & 0xFF, p >> 8 & 0xFF]]) +def set_inverted_mode(world, rom): + rom.write_byte(snes_to_pc(0x0283E0), 0xF0) # residual portals + rom.write_byte(snes_to_pc(0x02B34D), 0xF0) + rom.write_byte(snes_to_pc(0x06DB78), 0x8B) + rom.write_byte(snes_to_pc(0x05AF79), 0xF0) + rom.write_byte(snes_to_pc(0x0DB3C5), 0xC6) + rom.write_byte(snes_to_pc(0x07A3F4), 0xF0) # duck + rom.write_int16s(snes_to_pc(0x02E849), [0x0043, 0x0056, 0x0058, 0x006C, 0x006F, 0x0070, 0x007B, 0x007F, 0x001B]) # dw flute + rom.write_int16(snes_to_pc(0x02E8D5), 0x07C8) + rom.write_int16(snes_to_pc(0x02E8F7), 0x01F8) + rom.write_byte(snes_to_pc(0x08D40C), 0xD0) # morph proof + # the following bytes should only be written in vanilla + # or they'll overwrite the randomizer's shuffles + if world.shuffle == 'vanilla': + rom.write_byte(0x15B8C, 0x6C) + rom.write_byte(0xDBB73 + 0x00, 0x53) # switch bomb shop and links house + rom.write_byte(0xDBB73 + 0x52, 0x01) + rom.write_byte(0xDBB73 + 0x23, 0x37) # switch AT and GT + rom.write_byte(0xDBB73 + 0x36, 0x24) + rom.write_int16(0x15AEE + 2*0x38, 0x00E0) + rom.write_int16(0x15AEE + 2*0x25, 0x000C) + rom.write_byte(0xDBB73 + 0x15, 0x06) # bumper and old man cave + rom.write_int16(0x15AEE + 2*0x17, 0x00F0) + rom.write_byte(0xDBB73 + 0x05, 0x16) + rom.write_int16(0x15AEE + 2*0x07, 0x00FB) + rom.write_byte(0xDBB73 + 0x2D, 0x17) + rom.write_int16(0x15AEE + 2*0x2F, 0x00EB) + rom.write_byte(0xDBB73 + 0x06, 0x2E) + rom.write_int16(0x15AEE + 2*0x08, 0x00E6) + rom.write_byte(0xDBB73 + 0x16, 0x5E) + rom.write_byte(0xDBB73 + 0x6F, 0x07) # DDM fairy to old man cave + rom.write_int16(0x15AEE + 2*0x18, 0x00F1) + rom.write_byte(0x15B8C + 0x18, 0x43) + rom.write_int16(0x15BDB + 2 * 0x18, 0x1400) + rom.write_int16(0x15C79 + 2 * 0x18, 0x0294) + rom.write_int16(0x15D17 + 2 * 0x18, 0x0600) + rom.write_int16(0x15DB5 + 2 * 0x18, 0x02E8) + rom.write_int16(0x15E53 + 2 * 0x18, 0x0678) + rom.write_int16(0x15EF1 + 2 * 0x18, 0x0303) + rom.write_int16(0x15F8F + 2 * 0x18, 0x0685) + rom.write_byte(0x1602D + 0x18, 0x0A) + rom.write_byte(0x1607C + 0x18, 0xF6) + rom.write_int16(0x160CB + 2 * 0x18, 0x0000) + rom.write_int16(0x16169 + 2 * 0x18, 0x0000) + rom.write_int16(0x15AEE + 2 * 0x3D, 0x0003) # pyramid exit and houlihan + rom.write_byte(0x15B8C + 0x3D, 0x5B) + rom.write_int16(0x15BDB + 2 * 0x3D, 0x0B0E) + rom.write_int16(0x15C79 + 2 * 0x3D, 0x075A) + rom.write_int16(0x15D17 + 2 * 0x3D, 0x0674) + rom.write_int16(0x15DB5 + 2 * 0x3D, 0x07A8) + rom.write_int16(0x15E53 + 2 * 0x3D, 0x06E8) + rom.write_int16(0x15EF1 + 2 * 0x3D, 0x07C7) + rom.write_int16(0x15F8F + 2 * 0x3D, 0x06F3) + rom.write_byte(0x1602D + 0x3D, 0x06) + rom.write_byte(0x1607C + 0x3D, 0xFA) + rom.write_int16(0x160CB + 2 * 0x3D, 0x0000) + rom.write_int16(0x16169 + 2 * 0x3D, 0x0000) + rom.write_int16(snes_to_pc(0x02D8D4), 0x112) # change sactuary spawn point to dark sanc + rom.write_bytes(snes_to_pc(0x02D8E8), [0x22, 0x22, 0x22, 0x23, 0x04, 0x04, 0x04, 0x05]) + rom.write_int16(snes_to_pc(0x02D91A), 0x0400) + rom.write_int16(snes_to_pc(0x02D928), 0x222E) + rom.write_int16(snes_to_pc(0x02D936), 0x229A) + rom.write_int16(snes_to_pc(0x02D944), 0x0480) + rom.write_int16(snes_to_pc(0x02D952), 0x00A5) + rom.write_int16(snes_to_pc(0x02D960), 0x007F) + rom.write_byte(snes_to_pc(0x02D96D), 0x14) + rom.write_byte(snes_to_pc(0x02D974), 0x00) + rom.write_byte(snes_to_pc(0x02D97B), 0xFF) + rom.write_byte(snes_to_pc(0x02D982), 0x00) + rom.write_byte(snes_to_pc(0x02D989), 0x02) + rom.write_byte(snes_to_pc(0x02D990), 0x00) + rom.write_int16(snes_to_pc(0x02D998), 0x0000) + rom.write_int16(snes_to_pc(0x02D9A6), 0x005A) + rom.write_byte(snes_to_pc(0x02D9B3), 0x12) + # keep the old man spawn point at old man house unless shuffle is vanilla + if world.shuffle == 'vanilla': + rom.write_bytes(snes_to_pc(0x308350), [0x00, 0x00, 0x01]) + rom.write_int16(snes_to_pc(0x02D8DE), 0x00F1) + rom.write_bytes(snes_to_pc(0x02D910), [0x1F, 0x1E, 0x1F, 0x1F, 0x03, 0x02, 0x03, 0x03]) + rom.write_int16(snes_to_pc(0x02D924), 0x0300) + rom.write_int16(snes_to_pc(0x02D932), 0x1F10) + rom.write_int16(snes_to_pc(0x02D940), 0x1FC0) + rom.write_int16(snes_to_pc(0x02D94E), 0x0378) + rom.write_int16(snes_to_pc(0x02D95C), 0x0187) + rom.write_int16(snes_to_pc(0x02D96A), 0x017F) + rom.write_byte(snes_to_pc(0x02D972), 0x06) + rom.write_byte(snes_to_pc(0x02D979), 0x00) + rom.write_byte(snes_to_pc(0x02D980), 0xFF) + rom.write_byte(snes_to_pc(0x02D987), 0x00) + rom.write_byte(snes_to_pc(0x02D98E), 0x22) + rom.write_byte(snes_to_pc(0x02D995), 0x12) + rom.write_int16(snes_to_pc(0x02D9A2), 0x0000) + rom.write_int16(snes_to_pc(0x02D9B0), 0x0007) + rom.write_byte(snes_to_pc(0x02D9B8), 0x12) + rom.write_bytes(0x180247, [0x00, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00]) + rom.write_int16(0x15AEE + 2 * 0x06, 0x0020) # post aga hyrule castle spawn + rom.write_byte(0x15B8C + 0x06, 0x1B) + rom.write_int16(0x15BDB + 2 * 0x06, 0x00AE) + rom.write_int16(0x15C79 + 2 * 0x06, 0x0610) + rom.write_int16(0x15D17 + 2 * 0x06, 0x077E) + rom.write_int16(0x15DB5 + 2 * 0x06, 0x0672) + rom.write_int16(0x15E53 + 2 * 0x06, 0x07F8) + rom.write_int16(0x15EF1 + 2 * 0x06, 0x067D) + rom.write_int16(0x15F8F + 2 * 0x06, 0x0803) + rom.write_byte(0x1602D + 0x06, 0x00) + rom.write_byte(0x1607C + 0x06, 0xF2) + rom.write_int16(0x160CB + 2 * 0x06, 0x0000) + rom.write_int16(0x16169 + 2 * 0x06, 0x0000) + rom.write_int16(snes_to_pc(0x02E87B), 0x00AE) # move flute splot 9 + rom.write_int16(snes_to_pc(0x02E89D), 0x0610) + rom.write_int16(snes_to_pc(0x02E8BF), 0x077E) + rom.write_int16(snes_to_pc(0x02E8E1), 0x0672) + rom.write_int16(snes_to_pc(0x02E903), 0x07F8) + rom.write_int16(snes_to_pc(0x02E925), 0x067D) + rom.write_int16(snes_to_pc(0x02E947), 0x0803) + rom.write_int16(snes_to_pc(0x02E969), 0x0000) + rom.write_int16(snes_to_pc(0x02E98B), 0xFFF2) + rom.write_byte(snes_to_pc(0x1AF696), 0xF0) # bat sprite retreat + rom.write_byte(snes_to_pc(0x1AF6B2), 0x33) + rom.write_bytes(snes_to_pc(0x1AF730), [0x6A, 0x9E, 0x0C, 0x00, 0x7A, 0x9E, 0x0C, + 0x00, 0x8A, 0x9E, 0x0C, 0x00, 0x6A, 0xAE, + 0x0C, 0x00, 0x7A, 0xAE, 0x0C, 0x00, 0x8A, + 0xAE, 0x0C, 0x00, 0x67, 0x97, 0x0C, 0x00, + 0x8D, 0x97, 0x0C, 0x00]) + rom.write_int16s(snes_to_pc(0x0FF1C8), [0x190F, 0x190F, 0x190F, 0x194C, 0x190F, + 0x194B, 0x190F, 0x195C, 0x594B, 0x194C, + 0x19EE, 0x19EE, 0x194B, 0x19EE, 0x19EE, + 0x19EE, 0x594B, 0x190F, 0x595C, 0x190F, + 0x190F, 0x195B, 0x190F, 0x190F, 0x19EE, + 0x19EE, 0x195C, 0x19EE, 0x19EE, 0x19EE, + 0x19EE, 0x595C, 0x595B, 0x190F, 0x190F, + 0x190F]) + rom.write_int16s(snes_to_pc(0x0FA480), [0x190F, 0x196B, 0x9D04, 0x9D04, 0x196B, + 0x190F, 0x9D04, 0x9D04]) + rom.write_int16s(snes_to_pc(0x1bb810), [0x00BE, 0x00C0, 0x013E]) + rom.write_int16s(snes_to_pc(0x1bb836), [0x001B, 0x001B, 0x001B]) + rom.write_int16(snes_to_pc(0x308300), 0x0140) + rom.write_int16(snes_to_pc(0x308320), 0x001B) + if world.shuffle == 'vanilla': + rom.write_byte(snes_to_pc(0x308340), 0x7B) + rom.write_int16(snes_to_pc(0x1af504), 0x148B) + rom.write_int16(snes_to_pc(0x1af50c), 0x149B) + rom.write_int16(snes_to_pc(0x1af514), 0x14A4) + rom.write_int16(snes_to_pc(0x1af51c), 0x1489) + rom.write_int16(snes_to_pc(0x1af524), 0x14AC) + rom.write_int16(snes_to_pc(0x1af52c), 0x54AC) + rom.write_int16(snes_to_pc(0x1af534), 0x148C) + rom.write_int16(snes_to_pc(0x1af53c), 0x548C) + rom.write_int16(snes_to_pc(0x1af544), 0x1484) + rom.write_int16(snes_to_pc(0x1af54c), 0x5484) + rom.write_int16(snes_to_pc(0x1af554), 0x14A2) + rom.write_int16(snes_to_pc(0x1af55c), 0x54A2) + rom.write_int16(snes_to_pc(0x1af564), 0x14A0) + rom.write_int16(snes_to_pc(0x1af56c), 0x54A0) + rom.write_int16(snes_to_pc(0x1af574), 0x148E) + rom.write_int16(snes_to_pc(0x1af57c), 0x548E) + rom.write_int16(snes_to_pc(0x1af584), 0x14AE) + rom.write_int16(snes_to_pc(0x1af58c), 0x54AE) + rom.write_byte(snes_to_pc(0x00DB9D), 0x1A) # castle hole graphics + rom.write_byte(snes_to_pc(0x00DC09), 0x1A) + rom.write_byte(snes_to_pc(0x00D009), 0x31) + rom.write_byte(snes_to_pc(0x00D0e8), 0xE0) + rom.write_byte(snes_to_pc(0x00D1c7), 0x00) + rom.write_int16(snes_to_pc(0x1BE8DA), 0x39AD) + rom.write_byte(0xF6E58, 0x80) # no whirlpool under castle gate + rom.write_bytes(0x0086E, [0x5C, 0x00, 0xA0, 0xA1]) # TR tail + rom.write_bytes(snes_to_pc(0x1BC67A), [0x2E, 0x0B, 0x82]) # add warps under rocks + rom.write_bytes(snes_to_pc(0x1BC81E), [0x94, 0x1D, 0x82]) + rom.write_bytes(snes_to_pc(0x1BC655), [0x4A, 0x1D, 0x82]) + rom.write_bytes(snes_to_pc(0x1BC80D), [0xB2, 0x0B, 0x82]) + rom.write_bytes(snes_to_pc(0x1BC3DF), [0xD8, 0xD1]) + rom.write_bytes(snes_to_pc(0x1BD1D8), [0xA8, 0x02, 0x82, 0xFF, 0xFF]) + rom.write_bytes(snes_to_pc(0x1BC85A), [0x50, 0x0F, 0x82]) + rom.write_int16(0xDB96F + 2 * 0x35, 0x001B) # move pyramid exit door + rom.write_int16(0xDBA71 + 2 * 0x35, 0x06A4) + if world.shuffle == 'vanilla': + rom.write_byte(0xDBB73 + 0x35, 0x36) + rom.write_byte(snes_to_pc(0x09D436), 0xF3) # remove castle gate warp + if world.shuffle == 'vanilla': + rom.write_int16(0x15AEE + 2 * 0x37, 0x0010) # pyramid exit to new hc area + rom.write_byte(0x15B8C + 0x37, 0x1B) + rom.write_int16(0x15BDB + 2 * 0x37, 0x0418) + rom.write_int16(0x15C79 + 2 * 0x37, 0x0679) + rom.write_int16(0x15D17 + 2 * 0x37, 0x06B4) + rom.write_int16(0x15DB5 + 2 * 0x37, 0x06C6) + rom.write_int16(0x15E53 + 2 * 0x37, 0x0738) + rom.write_int16(0x15EF1 + 2 * 0x37, 0x06E6) + rom.write_int16(0x15F8F + 2 * 0x37, 0x0733) + rom.write_byte(0x1602D + 0x37, 0x07) + rom.write_byte(0x1607C + 0x37, 0xF9) + rom.write_int16(0x160CB + 2 * 0x37, 0x0000) + rom.write_int16(0x16169 + 2 * 0x37, 0x0000) + rom.write_bytes(snes_to_pc(0x1BC387), [0xDD, 0xD1]) + rom.write_bytes(snes_to_pc(0x1BD1DD), [0xA4, 0x06, 0x82, 0x9E, 0x06, 0x82, 0xFF, 0xFF]) + rom.write_byte(0x180089, 0x01) # open TR after exit + rom.write_byte(snes_to_pc(0x0ABFBB), 0x90) + rom.write_byte(snes_to_pc(0x0280A6), 0xD0) + rom.write_bytes(snes_to_pc(0x06B2AB), [0xF0, 0xE1, 0x05]) + +def patch_shuffled_dark_sanc(world, rom, player): + dark_sanc_entrance = str(world.get_region('Inverted Dark Sanctuary', player).entrances[0].name) + room_id, ow_area, vram_loc, scroll_y, scroll_x, link_y, link_x, camera_y, camera_x, unknown_1, unknown_2, door_1, door_2 = door_addresses[dark_sanc_entrance][1] + if dark_sanc_entrance == 'Skull Woods Final Section': + link_y = 0x00F8 + door_index = door_addresses[str(dark_sanc_entrance)][0] + + rom.write_byte(0x180241, 0x01) + rom.write_byte(0x180248, door_index + 1) + rom.write_int16(0x180250, room_id) + rom.write_byte(0x180252, ow_area) + rom.write_int16s(0x180253, [vram_loc, scroll_y, scroll_x, link_y, link_x, camera_y, camera_x]) + rom.write_bytes(0x180262, [unknown_1, unknown_2, 0x00]) + InconvenientEntrances = {'Turtle Rock': 'Turtle Rock Main', 'Misery Mire': 'Misery Mire', 'Ice Palace': 'Ice Palace', @@ -1334,114 +1737,114 @@ InsanityEntrances = {'Sanctuary': 'Sanctuary', 'Hookshot Cave Back Entrance': 'The stairs on the floating island' } -HintLocations = ['telepathic_tile_eastern_palace', - 'telepathic_tile_tower_of_hera_floor_4', - 'telepathic_tile_spectacle_rock', - 'telepathic_tile_swamp_entrance', - 'telepathic_tile_thieves_town_upstairs', - 'telepathic_tile_misery_mire', - 'telepathic_tile_palace_of_darkness', - 'telepathic_tile_desert_bonk_torch_room', - 'telepathic_tile_castle_tower', - 'telepathic_tile_ice_large_room', - 'telepathic_tile_turtle_rock', - 'telepathic_tile_ice_entrace', - 'telepathic_tile_ice_stalfos_knights_room', - 'telepathic_tile_tower_of_hera_entrance', - 'telepathic_tile_south_east_darkworld_cave', - 'dark_palace_tree_dude', - 'dark_sanctuary_hint_0', - 'dark_sanctuary_hint_1', - 'dark_sanctuary_yes', - 'dark_sanctuary_hint_2'] - -InconvenientLocations = ['Spike Cave', - 'Sahasrahla', - 'Purple Chest', - 'Swamp Left', - 'Mire Left', - 'Tower of Hera - Big Key Chest', - 'Eastern Palace - Big Key Chest', - 'Thieves\' Town - Big Chest', - 'Ice Palace - Big Chest', - 'Ganons Tower - Big Chest', - 'Magic Bat'] -RelevantItems = ['Bow', - 'Book of Mudora', - 'Hammer', - 'Hookshot', - 'Magic Mirror', - 'Ocarina', - 'Pegasus Boots', - 'Power Glove', - 'Cape', - 'Mushroom', - 'Shovel', - 'Lamp', - 'Magic Powder', - 'Moon Pearl', - 'Cane of Somaria', - 'Fire Rod', - 'Flippers', - 'Ice Rod', - 'Titans Mitts', - 'Ether', - 'Bombos', - 'Quake', - 'Bottle', - 'Bottle (Red Potion)', - 'Bottle (Green Potion)', - 'Bottle (Blue Potion)', - 'Bottle (Fairy)', - 'Bottle (Bee)', - 'Bottle (Good Bee)', - 'Master Sword', - 'Tempered Sword', - 'Fighter Sword', - 'Golden Sword', - 'Progressive Sword', - 'Progressive Glove', - 'Master Sword', - 'Power Star', - 'Triforce Piece', - 'Single Arrow', - 'Blue Mail', - 'Red Mail', - 'Progressive Armor', - 'Blue Boomerang', - 'Red Boomerang', - 'Blue Shield', - 'Red Shield', - 'Mirror Shield', - 'Progressive Shield', - 'Bug Catching Net', - 'Cane of Byrna', - 'Magic Upgrade (1/2)', - 'Magic Upgrade (1/4)' - ] - -KeysanityItems = ['Small Key (Eastern Palace)', - 'Big Key (Eastern Palace)', - 'Small Key (Escape)', - 'Small Key (Desert Palace)', - 'Big Key (Desert Palace)', - 'Small Key (Tower of Hera)', - 'Big Key (Tower of Hera)', - 'Small Key (Agahnims Tower)', - 'Small Key (Palace of Darkness)', - 'Big Key (Palace of Darkness)', - 'Small Key (Thieves Town)', - 'Big Key (Thieves Town)', - 'Small Key (Swamp Palace)', - 'Big Key (Swamp Palace)', - 'Small Key (Skull Woods)', - 'Big Key (Skull Woods)', - 'Small Key (Ice Palace)', - 'Big Key (Ice Palace)', - 'Small Key (Misery Mire)', - 'Big Key (Misery Mire)', - 'Small Key (Turtle Rock)', - 'Big Key (Turtle Rock)', - 'Small Key (Ganons Tower)', - 'Big Key (Ganons Tower)' - ] +HintLocations = ['telepathic_tile_eastern_palace', + 'telepathic_tile_tower_of_hera_floor_4', + 'telepathic_tile_spectacle_rock', + 'telepathic_tile_swamp_entrance', + 'telepathic_tile_thieves_town_upstairs', + 'telepathic_tile_misery_mire', + 'telepathic_tile_palace_of_darkness', + 'telepathic_tile_desert_bonk_torch_room', + 'telepathic_tile_castle_tower', + 'telepathic_tile_ice_large_room', + 'telepathic_tile_turtle_rock', + 'telepathic_tile_ice_entrace', + 'telepathic_tile_ice_stalfos_knights_room', + 'telepathic_tile_tower_of_hera_entrance', + 'telepathic_tile_south_east_darkworld_cave', + 'dark_palace_tree_dude', + 'dark_sanctuary_hint_0', + 'dark_sanctuary_hint_1', + 'dark_sanctuary_yes', + 'dark_sanctuary_hint_2'] + +InconvenientLocations = ['Spike Cave', + 'Sahasrahla', + 'Purple Chest', + 'Swamp Left', + 'Mire Left', + 'Tower of Hera - Big Key Chest', + 'Eastern Palace - Big Key Chest', + 'Thieves\' Town - Big Chest', + 'Ice Palace - Big Chest', + 'Ganons Tower - Big Chest', + 'Magic Bat'] +RelevantItems = ['Bow', + 'Book of Mudora', + 'Hammer', + 'Hookshot', + 'Magic Mirror', + 'Ocarina', + 'Pegasus Boots', + 'Power Glove', + 'Cape', + 'Mushroom', + 'Shovel', + 'Lamp', + 'Magic Powder', + 'Moon Pearl', + 'Cane of Somaria', + 'Fire Rod', + 'Flippers', + 'Ice Rod', + 'Titans Mitts', + 'Ether', + 'Bombos', + 'Quake', + 'Bottle', + 'Bottle (Red Potion)', + 'Bottle (Green Potion)', + 'Bottle (Blue Potion)', + 'Bottle (Fairy)', + 'Bottle (Bee)', + 'Bottle (Good Bee)', + 'Master Sword', + 'Tempered Sword', + 'Fighter Sword', + 'Golden Sword', + 'Progressive Sword', + 'Progressive Glove', + 'Master Sword', + 'Power Star', + 'Triforce Piece', + 'Single Arrow', + 'Blue Mail', + 'Red Mail', + 'Progressive Armor', + 'Blue Boomerang', + 'Red Boomerang', + 'Blue Shield', + 'Red Shield', + 'Mirror Shield', + 'Progressive Shield', + 'Bug Catching Net', + 'Cane of Byrna', + 'Magic Upgrade (1/2)', + 'Magic Upgrade (1/4)' + ] + +KeysanityItems = ['Small Key (Eastern Palace)', + 'Big Key (Eastern Palace)', + 'Small Key (Escape)', + 'Small Key (Desert Palace)', + 'Big Key (Desert Palace)', + 'Small Key (Tower of Hera)', + 'Big Key (Tower of Hera)', + 'Small Key (Agahnims Tower)', + 'Small Key (Palace of Darkness)', + 'Big Key (Palace of Darkness)', + 'Small Key (Thieves Town)', + 'Big Key (Thieves Town)', + 'Small Key (Swamp Palace)', + 'Big Key (Swamp Palace)', + 'Small Key (Skull Woods)', + 'Big Key (Skull Woods)', + 'Small Key (Ice Palace)', + 'Big Key (Ice Palace)', + 'Small Key (Misery Mire)', + 'Big Key (Misery Mire)', + 'Small Key (Turtle Rock)', + 'Big Key (Turtle Rock)', + 'Small Key (Ganons Tower)', + 'Big Key (Ganons Tower)' + ] diff --git a/Rules.py b/Rules.py index 93df6081f1..c72d79d42c 100644 --- a/Rules.py +++ b/Rules.py @@ -1,30 +1,40 @@ import collections import logging +from BaseClasses import CollectionState -def set_rules(world): +def set_rules(world, player): if world.logic == 'nologic': logging.getLogger('').info('WARNING! Seeds generated under this logic often require major glitches and may be impossible!') - world.get_region('Links House').can_reach = lambda state: True - world.get_region('Sanctuary').can_reach = lambda state: True - old_rule = world.get_region('Old Man House').can_reach - world.get_region('Old Man House').can_reach = lambda state: state.can_reach('Old Man', 'Location') or old_rule(state) - return - - global_rules(world) + if world.mode != 'inverted': + world.get_region('Links House', player).can_reach_private = lambda state: True + world.get_region('Sanctuary', player).can_reach_private = lambda state: True + old_rule = world.get_region('Old Man House', player).can_reach + world.get_region('Old Man House', player).can_reach_private = lambda state: state.can_reach('Old Man', 'Location', player) or old_rule(state) + return + else: + world.get_region('Inverted Links House', player).can_reach_private = lambda state: True + world.get_region('Inverted Dark Sanctuary', player).entrances[0].parent_region.can_reach_private = lambda state: True + if world.shuffle != 'vanilla': + old_rule = world.get_region('Old Man House', player).can_reach + world.get_region('Old Man House', player).can_reach_private = lambda state: state.can_reach('Old Man', 'Location', player) or old_rule(state) + return + if world.mode != 'inverted': + global_rules(world, player) if world.mode == 'open': - open_rules(world) + open_rules(world, player) elif world.mode == 'standard': - standard_rules(world) - elif world.mode == 'swordless': - swordless_rules(world) + standard_rules(world, player) + elif world.mode == 'inverted': + open_rules(world, player) + inverted_rules(world, player) else: raise NotImplementedError('Not implemented yet') if world.logic == 'noglitches': - no_glitches_rules(world) + no_glitches_rules(world, player) elif world.logic == 'minorglitches': logging.getLogger('').info('Minor Glitches may be buggy still. No guarantee for proper logic checks.') else: @@ -32,19 +42,24 @@ def set_rules(world): if world.goal == 'dungeons': # require all dungeons to beat ganon - add_rule(world.get_location('Ganon'), lambda state: state.can_reach('Master Sword Pedestal', 'Location') and state.has('Beat Agahnim 1') and state.has('Beat Agahnim 2')) + add_rule(world.get_location('Ganon', player), lambda state: state.can_reach('Master Sword Pedestal', 'Location', player) and state.has('Beat Agahnim 1', player) and state.has('Beat Agahnim 2', player) and state.has_crystals(7, player)) elif world.goal == 'ganon': # require aga2 to beat ganon - add_rule(world.get_location('Ganon'), lambda state: state.has('Beat Agahnim 2')) - - set_big_bomb_rules(world) + add_rule(world.get_location('Ganon', player), lambda state: state.has('Beat Agahnim 2', player)) + + if world.mode != 'inverted': + set_big_bomb_rules(world, player) + else: + set_inverted_big_bomb_rules(world, player) # if swamp and dam have not been moved we require mirror for swamp palace - if not world.swamp_patch_required: - add_rule(world.get_entrance('Swamp Palace Moat'), lambda state: state.has_Mirror()) - - set_bunny_rules(world) + if not world.swamp_patch_required[player]: + add_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has_Mirror(player)) + if world.mode != 'inverted': + set_bunny_rules(world, player) + else: + set_inverted_bunny_rules(world, player) def set_rule(spot, rule): spot.access_rule = rule @@ -64,375 +79,801 @@ def add_rule(spot, rule, combine='and'): spot.access_rule = lambda state: rule(state) and old_rule(state) -def add_lamp_requirement(spot): - add_rule(spot, lambda state: state.has('Lamp', state.world.lamps_needed_for_dark_rooms)) +def add_lamp_requirement(spot, player): + add_rule(spot, lambda state: state.has('Lamp', player, state.world.lamps_needed_for_dark_rooms)) -def forbid_item(location, item): +def forbid_item(location, item, player): old_rule = location.item_rule - location.item_rule = lambda i: i.name != item and old_rule(i) + location.item_rule = lambda i: (i.name != item or i.player != player) and old_rule(i) +def add_item_rule(location, rule): + old_rule = location.item_rule + location.item_rule = lambda item: rule(item) and old_rule(item) -def item_in_locations(state, item, locations): +def item_in_locations(state, item, player, locations): for location in locations: - if item_name(state, location) == item: + if item_name(state, location[0], location[1]) == (item, player): return True return False -def item_name(state, location): - location = state.world.get_location(location) +def item_name(state, location, player): + location = state.world.get_location(location, player) if location.item is None: return None - return location.item.name + return (location.item.name, location.item.player) -def global_rules(world): +def global_rules(world, player): + if world.goal == 'triforcehunt': + for location in world.get_locations(): + if location.player != player: + forbid_item(location, 'Triforce Piece', player) + # ganon can only carry triforce - world.get_location('Ganon').item_rule = lambda item: item.name == 'Triforce' + add_item_rule(world.get_location('Ganon', player), lambda item: item.name == 'Triforce' and item.player == player) - # these are default save&quit points and always accessible - world.get_region('Links House').can_reach = lambda state: True - world.get_region('Sanctuary').can_reach = lambda state: True + if world.mode == 'standard': + world.get_region('Hyrule Castle Secret Entrance', player).can_reach_private = lambda state: True + old_rule = world.get_region('Links House', player).can_reach + world.get_region('Links House', player).can_reach_private = lambda state: state.can_reach('Sanctuary', 'Region', player) or old_rule(state) + else: + # these are default save&quit points and always accessible + world.get_region('Links House', player).can_reach_private = lambda state: True + world.get_region('Sanctuary', player).can_reach_private = lambda state: True # we can s&q to the old man house after we rescue him. This may be somewhere completely different if caves are shuffled! - old_rule = world.get_region('Old Man House').can_reach - world.get_region('Old Man House').can_reach = lambda state: state.can_reach('Old Man', 'Location') or old_rule(state) + old_rule = world.get_region('Old Man House', player).can_reach + world.get_region('Old Man House', player).can_reach_private = lambda state: state.can_reach('Old Man', 'Location', player) or old_rule(state) # overworld requirements - set_rule(world.get_entrance('Kings Grave'), lambda state: state.has_Boots()) - set_rule(world.get_entrance('Kings Grave Outer Rocks'), lambda state: state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Kings Grave Inner Rocks'), lambda state: state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Kings Grave Mirror Spot'), lambda state: state.has_Pearl() and state.has_Mirror()) + set_rule(world.get_entrance('Kings Grave', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Kings Grave Outer Rocks', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Kings Grave Inner Rocks', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Kings Grave Mirror Spot', player), lambda state: state.has_Pearl(player) and state.has_Mirror(player)) # Caution: If king's grave is releaxed at all to account for reaching it via a two way cave's exit in insanity mode, then the bomb shop logic will need to be updated (that would involve create a small ledge-like Region for it) - set_rule(world.get_entrance('Bonk Fairy (Light)'), lambda state: state.has_Boots()) - set_rule(world.get_location('Sunken Treasure'), lambda state: state.can_reach('Dam')) - set_rule(world.get_entrance('Bat Cave Drop Ledge'), lambda state: state.has('Hammer')) - set_rule(world.get_entrance('Lumberjack Tree Tree'), lambda state: state.has_Boots() and state.has('Beat Agahnim 1')) - set_rule(world.get_entrance('Bonk Rock Cave'), lambda state: state.has_Boots()) - set_rule(world.get_entrance('Desert Palace Stairs'), lambda state: state.has('Book of Mudora')) - set_rule(world.get_entrance('Sanctuary Grave'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('20 Rupee Cave'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('50 Rupee Cave'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('Death Mountain Entrance Rock'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('Bumper Cave Entrance Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Flute Spot 1'), lambda state: state.has('Ocarina')) - set_rule(world.get_entrance('Lake Hylia Central Island Teleporter'), lambda state: state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Dark Desert Teleporter'), lambda state: state.has('Ocarina') and state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('East Hyrule Teleporter'), lambda state: state.has('Hammer') and state.can_lift_rocks() and state.has_Pearl()) # bunny cannot use hammer - set_rule(world.get_entrance('South Hyrule Teleporter'), lambda state: state.has('Hammer') and state.can_lift_rocks() and state.has_Pearl()) # bunny cannot use hammer - set_rule(world.get_entrance('Kakariko Teleporter'), lambda state: ((state.has('Hammer') and state.can_lift_rocks()) or state.can_lift_heavy_rocks()) and state.has_Pearl()) # bunny cannot lift bushes - set_rule(world.get_location('Flute Spot'), lambda state: state.has('Shovel')) - set_rule(world.get_location('Dark Blacksmith Ruins'), lambda state: state.has('Return Smith')) - set_rule(world.get_location('Purple Chest'), lambda state: state.has('Pick Up Purple Chest')) # Can S&Q with chest + set_rule(world.get_entrance('Bonk Fairy (Light)', player), lambda state: state.has_Boots(player)) + set_rule(world.get_location('Sunken Treasure', player), lambda state: state.can_reach('Dam', 'Region', player)) + set_rule(world.get_entrance('Bat Cave Drop Ledge', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Lumberjack Tree Tree', player), lambda state: state.has_Boots(player) and state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('Bonk Rock Cave', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Desert Palace Stairs', player), lambda state: state.has('Book of Mudora', player)) + set_rule(world.get_entrance('Sanctuary Grave', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('20 Rupee Cave', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('50 Rupee Cave', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Death Mountain Entrance Rock', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Bumper Cave Entrance Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Flute Spot 1', player), lambda state: state.has('Ocarina', player)) + set_rule(world.get_entrance('Lake Hylia Central Island Teleporter', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Dark Desert Teleporter', player), lambda state: state.has('Ocarina', player) and state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('East Hyrule Teleporter', player), lambda state: state.has('Hammer', player) and state.can_lift_rocks(player) and state.has_Pearl(player)) # bunny cannot use hammer + set_rule(world.get_entrance('South Hyrule Teleporter', player), lambda state: state.has('Hammer', player) and state.can_lift_rocks(player) and state.has_Pearl(player)) # bunny cannot use hammer + set_rule(world.get_entrance('Kakariko Teleporter', player), lambda state: ((state.has('Hammer', player) and state.can_lift_rocks(player)) or state.can_lift_heavy_rocks(player)) and state.has_Pearl(player)) # bunny cannot lift bushes + set_rule(world.get_location('Flute Spot', player), lambda state: state.has('Shovel', player)) + set_rule(world.get_location('Dark Blacksmith Ruins', player), lambda state: state.has('Return Smith', player)) + set_rule(world.get_location('Purple Chest', player), lambda state: state.has('Pick Up Purple Chest', player)) # Can S&Q with chest - set_rule(world.get_location('Zora\'s Ledge'), lambda state: state.has('Flippers')) - set_rule(world.get_entrance('Waterfall of Wishing'), lambda state: state.has('Flippers')) # can be fake flippered into, but is in weird state inside that might prevent you from doing things. Can be improved in future Todo - set_rule(world.get_location('Frog'), lambda state: state.can_lift_heavy_rocks()) # will get automatic moon pearl requirement - set_rule(world.get_location('Missing Smith'), lambda state: state.has('Get Frog')) # Can S&Q with smith - set_rule(world.get_location('Blacksmith'), lambda state: state.has('Return Smith')) - set_rule(world.get_location('Magic Bat'), lambda state: state.has('Magic Powder')) - set_rule(world.get_location('Sick Kid'), lambda state: state.has_bottle()) - set_rule(world.get_location('Library'), lambda state: state.has_Boots()) - set_rule(world.get_location('Potion Shop'), lambda state: state.has('Mushroom')) - set_rule(world.get_entrance('Desert Palace Entrance (North) Rocks'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('Desert Ledge Return Rocks'), lambda state: state.can_lift_rocks()) # should we decide to place something that is not a dungeon end up there at some point - set_rule(world.get_entrance('Checkerboard Cave'), lambda state: state.can_lift_rocks()) - set_rule(world.get_location('Master Sword Pedestal'), lambda state: state.has('Red Pendant') and state.has('Blue Pendant') and state.has('Green Pendant')) - set_rule(world.get_location('Sahasrahla'), lambda state: state.has('Green Pendant')) - set_rule(world.get_entrance('Agahnims Tower'), lambda state: state.has('Cape') or state.has_beam_sword() or state.has('Beat Agahnim 1')) # barrier gets removed after killing agahnim, relevant for entrance shuffle - set_rule(world.get_entrance('Agahnim 1'), lambda state: state.has_sword() and state.has_key('Small Key (Agahnims Tower)', 2)) - set_defeat_dungeon_boss_rule(world.get_location('Agahnim 1')) - set_rule(world.get_location('Castle Tower - Dark Maze'), lambda state: state.has_key('Small Key (Agahnims Tower)')) - set_rule(world.get_entrance('Top of Pyramid'), lambda state: state.has('Beat Agahnim 1')) - set_rule(world.get_entrance('Old Man Cave Exit (West)'), lambda state: False) # drop cannot be climbed up - set_rule(world.get_entrance('Broken Bridge (West)'), lambda state: state.has('Hookshot')) - set_rule(world.get_entrance('Broken Bridge (East)'), lambda state: state.has('Hookshot')) - set_rule(world.get_entrance('East Death Mountain Teleporter'), lambda state: state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Fairy Ascension Rocks'), lambda state: state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Paradox Cave Push Block Reverse'), lambda state: state.has('Mirror')) # can erase block - set_rule(world.get_entrance('Death Mountain (Top)'), lambda state: state.has('Hammer')) - set_rule(world.get_entrance('Turtle Rock Teleporter'), lambda state: state.can_lift_heavy_rocks() and state.has('Hammer')) - set_rule(world.get_location('Ether Tablet'), lambda state: state.has('Book of Mudora') and state.has_beam_sword()) - set_rule(world.get_entrance('East Death Mountain (Top)'), lambda state: state.has('Hammer')) + set_rule(world.get_location('Zora\'s Ledge', player), lambda state: state.has('Flippers', player)) + set_rule(world.get_entrance('Waterfall of Wishing', player), lambda state: state.has('Flippers', player)) # can be fake flippered into, but is in weird state inside that might prevent you from doing things. Can be improved in future Todo + set_rule(world.get_location('Frog', player), lambda state: state.can_lift_heavy_rocks(player)) # will get automatic moon pearl requirement + set_rule(world.get_location('Missing Smith', player), lambda state: state.has('Get Frog', player)) # Can S&Q with smith + set_rule(world.get_location('Blacksmith', player), lambda state: state.has('Return Smith', player)) + set_rule(world.get_location('Magic Bat', player), lambda state: state.has('Magic Powder', player)) + set_rule(world.get_location('Sick Kid', player), lambda state: state.has_bottle(player)) + set_rule(world.get_location('Library', player), lambda state: state.has_Boots(player)) + set_rule(world.get_location('Potion Shop', player), lambda state: state.has('Mushroom', player)) + set_rule(world.get_entrance('Desert Palace Entrance (North) Rocks', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Desert Ledge Return Rocks', player), lambda state: state.can_lift_rocks(player)) # should we decide to place something that is not a dungeon end up there at some point + set_rule(world.get_entrance('Checkerboard Cave', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_location('Master Sword Pedestal', player), lambda state: state.has('Red Pendant', player) and state.has('Blue Pendant', player) and state.has('Green Pendant', player)) + set_rule(world.get_location('Sahasrahla', player), lambda state: state.has('Green Pendant', player)) + set_rule(world.get_entrance('Agahnims Tower', player), lambda state: state.has('Cape', player) or state.has_beam_sword(player) or state.has('Beat Agahnim 1', player)) # barrier gets removed after killing agahnim, relevant for entrance shuffle + set_rule(world.get_entrance('Agahnim 1', player), lambda state: state.has_sword(player) and state.has_key('Small Key (Agahnims Tower)', player, 2)) + set_defeat_dungeon_boss_rule(world.get_location('Agahnim 1', player)) + set_rule(world.get_location('Castle Tower - Dark Maze', player), lambda state: state.has_key('Small Key (Agahnims Tower)', player)) + set_rule(world.get_entrance('Top of Pyramid', player), lambda state: state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('Old Man Cave Exit (West)', player), lambda state: False) # drop cannot be climbed up + set_rule(world.get_entrance('Broken Bridge (West)', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('Broken Bridge (East)', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('East Death Mountain Teleporter', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Fairy Ascension Rocks', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Paradox Cave Push Block Reverse', player), lambda state: state.has('Mirror', player)) # can erase block + set_rule(world.get_entrance('Death Mountain (Top)', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Turtle Rock Teleporter', player), lambda state: state.can_lift_heavy_rocks(player) and state.has('Hammer', player)) + set_rule(world.get_location('Ether Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has_beam_sword(player)) + set_rule(world.get_entrance('East Death Mountain (Top)', player), lambda state: state.has('Hammer', player)) - set_rule(world.get_location('Catfish'), lambda state: state.can_lift_rocks()) - set_rule(world.get_entrance('Northeast Dark World Broken Bridge Pass'), lambda state: state.has_Pearl() and (state.can_lift_rocks() or state.has('Hammer') or state.has('Flippers'))) - set_rule(world.get_entrance('East Dark World Broken Bridge Pass'), lambda state: state.has_Pearl() and (state.can_lift_rocks() or state.has('Hammer'))) - set_rule(world.get_entrance('South Dark World Bridge'), lambda state: state.has('Hammer') and state.has_Pearl()) - set_rule(world.get_entrance('Bonk Fairy (Dark)'), lambda state: state.has_Pearl() and state.has_Boots()) - set_rule(world.get_entrance('West Dark World Gap'), lambda state: state.has_Pearl() and state.has('Hookshot')) - set_rule(world.get_entrance('Palace of Darkness'), lambda state: state.has_Pearl()) # kiki needs pearl - set_rule(world.get_entrance('Hyrule Castle Ledge Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Hyrule Castle Main Gate'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Dark Lake Hylia Drop (East)'), lambda state: (state.has_Pearl() and state.has('Flippers') or state.has_Mirror())) # Overworld Bunny Revival - set_rule(world.get_location('Bombos Tablet'), lambda state: state.has('Book of Mudora') and state.has_beam_sword() and state.has_Mirror()) - set_rule(world.get_entrance('Dark Lake Hylia Drop (South)'), lambda state: state.has_Pearl() and state.has('Flippers')) # ToDo any fake flipper set up? - set_rule(world.get_entrance('Dark Lake Hylia Ledge Fairy'), lambda state: state.has_Pearl()) # bomb required - set_rule(world.get_entrance('Dark Lake Hylia Ledge Spike Cave'), lambda state: state.can_lift_rocks() and state.has_Pearl()) - set_rule(world.get_entrance('Dark Lake Hylia Teleporter'), lambda state: state.has_Pearl() and (state.has('Hammer') or state.can_lift_rocks())) # Fake Flippers - set_rule(world.get_entrance('Village of Outcasts Heavy Rock'), lambda state: state.has_Pearl() and state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Hype Cave'), lambda state: state.has_Pearl()) # bomb required - set_rule(world.get_entrance('Brewery'), lambda state: state.has_Pearl()) # bomb required - set_rule(world.get_entrance('Thieves Town'), lambda state: state.has_Pearl()) # bunny cannot pull - set_rule(world.get_entrance('Skull Woods First Section Hole (North)'), lambda state: state.has_Pearl()) # bunny cannot lift bush - set_rule(world.get_entrance('Skull Woods Second Section Hole'), lambda state: state.has_Pearl()) # bunny cannot lift bush - set_rule(world.get_entrance('Maze Race Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Cave 45 Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('East Dark World Bridge'), lambda state: state.has_Pearl() and state.has('Hammer')) - set_rule(world.get_entrance('Lake Hylia Island Mirror Spot'), lambda state: state.has_Pearl() and state.has_Mirror() and state.has('Flippers')) - set_rule(world.get_entrance('Lake Hylia Central Island Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('East Dark World River Pier'), lambda state: state.has_Pearl() and state.has('Flippers')) # ToDo any fake flipper set up? - set_rule(world.get_entrance('Graveyard Ledge Mirror Spot'), lambda state: state.has_Pearl() and state.has_Mirror()) - set_rule(world.get_entrance('Bumper Cave Entrance Rock'), lambda state: state.has_Pearl() and state.can_lift_rocks()) - set_rule(world.get_entrance('Bumper Cave Ledge Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Bat Cave Drop Ledge Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Dark World Hammer Peg Cave'), lambda state: state.has_Pearl() and state.has('Hammer')) - set_rule(world.get_entrance('Village of Outcasts Eastern Rocks'), lambda state: state.has_Pearl() and state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Peg Area Rocks'), lambda state: state.has_Pearl() and state.can_lift_heavy_rocks()) - set_rule(world.get_entrance('Village of Outcasts Pegs'), lambda state: state.has_Pearl() and state.has('Hammer')) - set_rule(world.get_entrance('Grassy Lawn Pegs'), lambda state: state.has_Pearl() and state.has('Hammer')) - set_rule(world.get_entrance('Bumper Cave Exit (Top)'), lambda state: state.has('Cape')) - set_rule(world.get_entrance('Bumper Cave Exit (Bottom)'), lambda state: state.has('Cape') or state.has('Hookshot')) + set_rule(world.get_location('Catfish', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Northeast Dark World Broken Bridge Pass', player), lambda state: state.has_Pearl(player) and (state.can_lift_rocks(player) or state.has('Hammer', player) or state.has('Flippers', player))) + set_rule(world.get_entrance('East Dark World Broken Bridge Pass', player), lambda state: state.has_Pearl(player) and (state.can_lift_rocks(player) or state.has('Hammer', player))) + set_rule(world.get_entrance('South Dark World Bridge', player), lambda state: state.has('Hammer', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Bonk Fairy (Dark)', player), lambda state: state.has_Pearl(player) and state.has_Boots(player)) + set_rule(world.get_entrance('West Dark World Gap', player), lambda state: state.has_Pearl(player) and state.has('Hookshot', player)) + set_rule(world.get_entrance('Palace of Darkness', player), lambda state: state.has_Pearl(player)) # kiki needs pearl + set_rule(world.get_entrance('Hyrule Castle Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Hyrule Castle Main Gate', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (East)', player), lambda state: (state.has_Pearl(player) and state.has('Flippers', player) or state.has_Mirror(player))) # Overworld Bunny Revival + set_rule(world.get_location('Bombos Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has_beam_sword(player) and state.has_Mirror(player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (South)', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) # ToDo any fake flipper set up? + set_rule(world.get_entrance('Dark Lake Hylia Ledge Fairy', player), lambda state: state.has_Pearl(player)) # bomb required + set_rule(world.get_entrance('Dark Lake Hylia Ledge Spike Cave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Dark Lake Hylia Teleporter', player), lambda state: state.has_Pearl(player) and (state.has('Hammer', player) or state.can_lift_rocks(player))) # Fake Flippers + set_rule(world.get_entrance('Village of Outcasts Heavy Rock', player), lambda state: state.has_Pearl(player) and state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Hype Cave', player), lambda state: state.has_Pearl(player)) # bomb required + set_rule(world.get_entrance('Brewery', player), lambda state: state.has_Pearl(player)) # bomb required + set_rule(world.get_entrance('Thieves Town', player), lambda state: state.has_Pearl(player)) # bunny cannot pull + set_rule(world.get_entrance('Skull Woods First Section Hole (North)', player), lambda state: state.has_Pearl(player)) # bunny cannot lift bush + set_rule(world.get_entrance('Skull Woods Second Section Hole', player), lambda state: state.has_Pearl(player)) # bunny cannot lift bush + set_rule(world.get_entrance('Maze Race Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Cave 45 Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('East Dark World Bridge', player), lambda state: state.has_Pearl(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Lake Hylia Island Mirror Spot', player), lambda state: state.has_Pearl(player) and state.has_Mirror(player) and state.has('Flippers', player)) + set_rule(world.get_entrance('Lake Hylia Central Island Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('East Dark World River Pier', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) # ToDo any fake flipper set up? + set_rule(world.get_entrance('Graveyard Ledge Mirror Spot', player), lambda state: state.has_Pearl(player) and state.has_Mirror(player)) + set_rule(world.get_entrance('Bumper Cave Entrance Rock', player), lambda state: state.has_Pearl(player) and state.can_lift_rocks(player)) + set_rule(world.get_entrance('Bumper Cave Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Bat Cave Drop Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark World Hammer Peg Cave', player), lambda state: state.has_Pearl(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Village of Outcasts Eastern Rocks', player), lambda state: state.has_Pearl(player) and state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Peg Area Rocks', player), lambda state: state.has_Pearl(player) and state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Village of Outcasts Pegs', player), lambda state: state.has_Pearl(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Grassy Lawn Pegs', player), lambda state: state.has_Pearl(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Bumper Cave Exit (Top)', player), lambda state: state.has('Cape', player)) + set_rule(world.get_entrance('Bumper Cave Exit (Bottom)', player), lambda state: state.has('Cape', player) or state.has('Hookshot', player)) - set_rule(world.get_entrance('Skull Woods Final Section'), lambda state: state.has('Fire Rod') and state.has_Pearl()) # bunny cannot use fire rod - set_rule(world.get_entrance('Misery Mire'), lambda state: state.has_Pearl() and state.has_sword() and state.has_misery_mire_medallion()) # sword required to cast magic (!) - set_rule(world.get_entrance('Desert Ledge (Northeast) Mirror Spot'), lambda state: state.has_Mirror()) + set_rule(world.get_entrance('Skull Woods Final Section', player), lambda state: state.has('Fire Rod', player) and state.has_Pearl(player)) # bunny cannot use fire rod + set_rule(world.get_entrance('Misery Mire', player), lambda state: state.has_Pearl(player) and state.has_sword(player) and state.has_misery_mire_medallion(player)) # sword required to cast magic (!) + set_rule(world.get_entrance('Desert Ledge (Northeast) Mirror Spot', player), lambda state: state.has_Mirror(player)) - set_rule(world.get_entrance('Desert Ledge Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Desert Palace Stairs Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Desert Palace Entrance (North) Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Spectacle Rock Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Hookshot Cave'), lambda state: state.can_lift_rocks() and state.has_Pearl()) + set_rule(world.get_entrance('Desert Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Desert Palace Stairs Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Desert Palace Entrance (North) Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Spectacle Rock Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Hookshot Cave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) - set_rule(world.get_entrance('East Death Mountain (Top) Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Mimic Cave Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Spiral Cave Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Fairy Ascension Mirror Spot'), lambda state: state.has_Mirror() and state.has_Pearl()) # need to lift flowers - set_rule(world.get_entrance('Isolated Ledge Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Superbunny Cave Exit (Bottom)'), lambda state: False) # Cannot get to bottom exit from top. Just exists for shuffling + set_rule(world.get_entrance('East Death Mountain (Top) Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Mimic Cave Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Spiral Cave Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Fairy Ascension Mirror Spot', player), lambda state: state.has_Mirror(player) and state.has_Pearl(player)) # need to lift flowers + set_rule(world.get_entrance('Isolated Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Superbunny Cave Exit (Bottom)', player), lambda state: False) # Cannot get to bottom exit from top. Just exists for shuffling - set_rule(world.get_location('Spike Cave'), lambda state: - state.has('Hammer') and state.can_lift_rocks() and - ((state.has('Cape') and state.can_extend_magic(16, True)) or - (state.has('Cane of Byrna') and - (state.can_extend_magic(12, True) or - (state.world.can_take_damage and (state.has_Boots() or state.has_hearts(4)))))) + set_rule(world.get_location('Spike Cave', player), lambda state: + state.has('Hammer', player) and state.can_lift_rocks(player) and + ((state.has('Cape', player) and state.can_extend_magic(player, 16, True)) or + (state.has('Cane of Byrna', player) and + (state.can_extend_magic(player, 12, True) or + (state.world.can_take_damage and (state.has_Boots(player) or state.has_hearts(player, 4)))))) ) - set_rule(world.get_location('Hookshot Cave - Top Right'), lambda state: state.has('Hookshot')) - set_rule(world.get_location('Hookshot Cave - Top Left'), lambda state: state.has('Hookshot')) - set_rule(world.get_location('Hookshot Cave - Bottom Right'), lambda state: state.has('Hookshot') or state.has('Pegasus Boots')) - set_rule(world.get_location('Hookshot Cave - Bottom Left'), lambda state: state.has('Hookshot')) - set_rule(world.get_entrance('Floating Island Mirror Spot'), lambda state: state.has_Mirror()) - set_rule(world.get_entrance('Turtle Rock'), lambda state: state.has_Pearl() and state.has_sword() and state.has_turtle_rock_medallion() and state.can_reach('Turtle Rock (Top)', 'Region')) # sword required to cast magic (!) - set_rule(world.get_location('Mimic Cave'), lambda state: state.has('Hammer')) + set_rule(world.get_location('Hookshot Cave - Top Right', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_location('Hookshot Cave - Top Left', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_location('Hookshot Cave - Bottom Right', player), lambda state: state.has('Hookshot', player) or state.has('Pegasus Boots', player)) + set_rule(world.get_location('Hookshot Cave - Bottom Left', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('Floating Island Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Turtle Rock', player), lambda state: state.has_Pearl(player) and state.has_sword(player) and state.has_turtle_rock_medallion(player) and state.can_reach('Turtle Rock (Top)', 'Region', player)) # sword required to cast magic (!) + set_rule(world.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player)) - set_rule(world.get_entrance('Sewers Door'), lambda state: state.has_key('Small Key (Escape)')) - set_rule(world.get_entrance('Sewers Back Door'), lambda state: state.has_key('Small Key (Escape)')) + set_rule(world.get_entrance('Sewers Door', player), lambda state: state.has_key('Small Key (Escape)', player)) + set_rule(world.get_entrance('Sewers Back Door', player), lambda state: state.has_key('Small Key (Escape)', player)) - set_rule(world.get_location('Eastern Palace - Big Chest'), lambda state: state.has('Big Key (Eastern Palace)')) - set_rule(world.get_location('Eastern Palace - Boss'), lambda state: state.can_shoot_arrows() and state.has('Big Key (Eastern Palace)') and world.get_location('Eastern Palace - Boss').parent_region.dungeon.boss.can_defeat(state)) - set_rule(world.get_location('Eastern Palace - Prize'), lambda state: state.can_shoot_arrows() and state.has('Big Key (Eastern Palace)') and world.get_location('Eastern Palace - Prize').parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Eastern Palace - Big Chest', player), lambda state: state.has('Big Key (Eastern Palace)', player)) + set_rule(world.get_location('Eastern Palace - Boss', player), lambda state: state.can_shoot_arrows(player) and state.has('Big Key (Eastern Palace)', player) and world.get_location('Eastern Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Eastern Palace - Prize', player), lambda state: state.can_shoot_arrows(player) and state.has('Big Key (Eastern Palace)', player) and world.get_location('Eastern Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) for location in ['Eastern Palace - Boss', 'Eastern Palace - Big Chest']: - forbid_item(world.get_location(location), 'Big Key (Eastern Palace)') + forbid_item(world.get_location(location, player), 'Big Key (Eastern Palace)', player) - set_rule(world.get_location('Desert Palace - Big Chest'), lambda state: state.has('Big Key (Desert Palace)')) - set_rule(world.get_location('Desert Palace - Torch'), lambda state: state.has_Boots()) - set_rule(world.get_entrance('Desert Palace East Wing'), lambda state: state.has_key('Small Key (Desert Palace)')) - set_rule(world.get_location('Desert Palace - Prize'), lambda state: state.has_key('Small Key (Desert Palace)') and state.has('Big Key (Desert Palace)') and state.has_fire_source() and world.get_location('Desert Palace - Prize').parent_region.dungeon.boss.can_defeat(state)) - set_rule(world.get_location('Desert Palace - Boss'), lambda state: state.has_key('Small Key (Desert Palace)') and state.has('Big Key (Desert Palace)') and state.has_fire_source() and world.get_location('Desert Palace - Boss').parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Desert Palace - Big Chest', player), lambda state: state.has('Big Key (Desert Palace)', player)) + set_rule(world.get_location('Desert Palace - Torch', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Desert Palace East Wing', player), lambda state: state.has_key('Small Key (Desert Palace)', player)) + set_rule(world.get_location('Desert Palace - Prize', player), lambda state: state.has_key('Small Key (Desert Palace)', player) and state.has('Big Key (Desert Palace)', player) and state.has_fire_source(player) and world.get_location('Desert Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Desert Palace - Boss', player), lambda state: state.has_key('Small Key (Desert Palace)', player) and state.has('Big Key (Desert Palace)', player) and state.has_fire_source(player) and world.get_location('Desert Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) for location in ['Desert Palace - Boss', 'Desert Palace - Big Chest']: - forbid_item(world.get_location(location), 'Big Key (Desert Palace)') + forbid_item(world.get_location(location, player), 'Big Key (Desert Palace)', player) for location in ['Desert Palace - Boss', 'Desert Palace - Big Key Chest', 'Desert Palace - Compass Chest']: - forbid_item(world.get_location(location), 'Small Key (Desert Palace)') + forbid_item(world.get_location(location, player), 'Small Key (Desert Palace)', player) - set_rule(world.get_entrance('Tower of Hera Small Key Door'), lambda state: state.has_key('Small Key (Tower of Hera)') or item_name(state, 'Tower of Hera - Big Key Chest') == 'Small Key (Tower of Hera)') - set_rule(world.get_entrance('Tower of Hera Big Key Door'), lambda state: state.has('Big Key (Tower of Hera)')) - set_rule(world.get_location('Tower of Hera - Big Chest'), lambda state: state.has('Big Key (Tower of Hera)')) - set_rule(world.get_location('Tower of Hera - Big Key Chest'), lambda state: state.has_fire_source()) - set_always_allow(world.get_location('Tower of Hera - Big Key Chest'), lambda state, item: item.name == 'Small Key (Tower of Hera)') - set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize')) + set_rule(world.get_entrance('Tower of Hera Small Key Door', player), lambda state: state.has_key('Small Key (Tower of Hera)', player) or item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player)) + set_rule(world.get_entrance('Tower of Hera Big Key Door', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(world.get_location('Tower of Hera - Big Chest', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(world.get_location('Tower of Hera - Big Key Chest', player), lambda state: state.has_fire_source(player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Tower of Hera - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Tower of Hera)' and item.player == player) + set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize', player)) for location in ['Tower of Hera - Boss', 'Tower of Hera - Big Chest', 'Tower of Hera - Compass Chest']: - forbid_item(world.get_location(location), 'Big Key (Tower of Hera)') + forbid_item(world.get_location(location, player), 'Big Key (Tower of Hera)', player) # for location in ['Tower of Hera - Big Key Chest']: -# forbid_item(world.get_location(location), 'Small Key (Tower of Hera)') +# forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player) - set_rule(world.get_entrance('Swamp Palace Moat'), lambda state: state.has('Flippers') and state.has('Open Floodgate')) - add_rule(world.get_location('Sunken Treasure'), lambda state: state.has('Open Floodgate')) + set_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player)) + add_rule(world.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player)) - set_rule(world.get_entrance('Swamp Palace Small Key Door'), lambda state: state.has_key('Small Key (Swamp Palace)')) - set_rule(world.get_entrance('Swamp Palace (Center)'), lambda state: state.has('Hammer')) - set_rule(world.get_location('Swamp Palace - Big Chest'), lambda state: state.has('Big Key (Swamp Palace)') or item_name(state, 'Swamp Palace - Big Chest') == 'Big Key (Swamp Palace)') - set_always_allow(world.get_location('Swamp Palace - Big Chest'), lambda state, item: item.name == 'Big Key (Swamp Palace)') - set_rule(world.get_entrance('Swamp Palace (North)'), lambda state: state.has('Hookshot')) - set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Prize')) + set_rule(world.get_entrance('Swamp Palace Small Key Door', player), lambda state: state.has_key('Small Key (Swamp Palace)', player)) + set_rule(world.get_entrance('Swamp Palace (Center)', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_location('Swamp Palace - Big Chest', player), lambda state: state.has('Big Key (Swamp Palace)', player) or item_name(state, 'Swamp Palace - Big Chest', player) == ('Big Key (Swamp Palace)', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Swamp Palace - Big Chest', player), lambda state, item: item.name == 'Big Key (Swamp Palace)' and item.player == player) + set_rule(world.get_entrance('Swamp Palace (North)', player), lambda state: state.has('Hookshot', player)) + set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Prize', player)) for location in ['Swamp Palace - Entrance']: - forbid_item(world.get_location(location), 'Big Key (Swamp Palace)') + forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player) - set_rule(world.get_entrance('Thieves Town Big Key Door'), lambda state: state.has('Big Key (Thieves Town)')) - set_rule(world.get_entrance('Blind Fight'), lambda state: state.has_key('Small Key (Thieves Town)')) - set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Prize')) - set_rule(world.get_location('Thieves\' Town - Big Chest'), lambda state: (state.has_key('Small Key (Thieves Town)') or item_name(state, 'Thieves\' Town - Big Chest') == 'Small Key (Thieves Town)') and state.has('Hammer')) - set_always_allow(world.get_location('Thieves\' Town - Big Chest'), lambda state, item: item.name == 'Small Key (Thieves Town)' and state.has('Hammer')) - set_rule(world.get_location('Thieves\' Town - Attic'), lambda state: state.has_key('Small Key (Thieves Town)')) + set_rule(world.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player)) + set_rule(world.get_entrance('Blind Fight', player), lambda state: state.has_key('Small Key (Thieves Town)', player)) + set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Prize', player)) + set_rule(world.get_location('Thieves\' Town - Big Chest', player), lambda state: (state.has_key('Small Key (Thieves Town)', player) or item_name(state, 'Thieves\' Town - Big Chest', player) == ('Small Key (Thieves Town)', player)) and state.has('Hammer', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Thieves\' Town - Big Chest', player), lambda state, item: item.name == 'Small Key (Thieves Town)' and item.player == player and state.has('Hammer', player)) + set_rule(world.get_location('Thieves\' Town - Attic', player), lambda state: state.has_key('Small Key (Thieves Town)', player)) for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Big Chest', 'Thieves\' Town - Blind\'s Cell', 'Thieves\' Town - Boss']: - forbid_item(world.get_location(location), 'Big Key (Thieves Town)') + forbid_item(world.get_location(location, player), 'Big Key (Thieves Town)', player) for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Boss']: - forbid_item(world.get_location(location), 'Small Key (Thieves Town)') + forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player) - set_rule(world.get_entrance('Skull Woods First Section South Door'), lambda state: state.has_key('Small Key (Skull Woods)')) - set_rule(world.get_entrance('Skull Woods First Section (Right) North Door'), lambda state: state.has_key('Small Key (Skull Woods)')) - set_rule(world.get_entrance('Skull Woods First Section West Door'), lambda state: state.has_key('Small Key (Skull Woods)', 2)) # ideally would only be one key, but we may have spent thst key already on escaping the right section - set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit'), lambda state: state.has_key('Small Key (Skull Woods)', 2)) - set_rule(world.get_location('Skull Woods - Big Chest'), lambda state: state.has('Big Key (Skull Woods)') or item_name(state, 'Skull Woods - Big Chest') == 'Big Key (Skull Woods)') - set_always_allow(world.get_location('Skull Woods - Big Chest'), lambda state, item: item.name == 'Big Key (Skull Woods)') - set_rule(world.get_entrance('Skull Woods Torch Room'), lambda state: state.has_key('Small Key (Skull Woods)', 3) and state.has('Fire Rod') and state.has_sword()) # sword required for curtain - set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Prize')) + set_rule(world.get_entrance('Skull Woods First Section South Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player)) + set_rule(world.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player)) + set_rule(world.get_entrance('Skull Woods First Section West Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 2)) # ideally would only be one key, but we may have spent thst key already on escaping the right section + set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 2)) + set_rule(world.get_location('Skull Woods - Big Chest', player), lambda state: state.has('Big Key (Skull Woods)', player) or item_name(state, 'Skull Woods - Big Chest', player) == ('Big Key (Skull Woods)', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Skull Woods - Big Chest', player), lambda state, item: item.name == 'Big Key (Skull Woods)' and item.player == player) + set_rule(world.get_entrance('Skull Woods Torch Room', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 3) and state.has('Fire Rod', player) and state.has_sword(player)) # sword required for curtain + set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Prize', player)) for location in ['Skull Woods - Boss']: - forbid_item(world.get_location(location), 'Small Key (Skull Woods)') + forbid_item(world.get_location(location, player), 'Small Key (Skull Woods)', player) - set_rule(world.get_entrance('Ice Palace Entrance Room'), lambda state: state.has('Fire Rod') or (state.has('Bombos') and state.has_sword())) - set_rule(world.get_location('Ice Palace - Big Chest'), lambda state: state.has('Big Key (Ice Palace)')) - set_rule(world.get_entrance('Ice Palace (Kholdstare)'), lambda state: state.can_lift_rocks() and state.has('Hammer') and state.has('Big Key (Ice Palace)') and (state.has_key('Small Key (Ice Palace)', 2) or (state.has('Cane of Somaria') and state.has_key('Small Key (Ice Palace)', 1)))) + set_rule(world.get_entrance('Ice Palace Entrance Room', player), lambda state: state.can_melt_things(player)) + set_rule(world.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player)) + set_rule(world.get_entrance('Ice Palace (Kholdstare)', player), lambda state: state.can_lift_rocks(player) and state.has('Hammer', player) and state.has('Big Key (Ice Palace)', player) and (state.has_key('Small Key (Ice Palace)', player, 2) or (state.has('Cane of Somaria', player) and state.has_key('Small Key (Ice Palace)', player, 1)))) # TODO: investigate change from VT. Changed to hookshot or 2 keys (no checking for big key in specific chests) - set_rule(world.get_entrance('Ice Palace (East)'), lambda state: (state.has('Hookshot') or (item_in_locations(state, 'Big Key (Ice Palace)', ['Ice Palace - Spike Room', 'Ice Palace - Big Key Chest', 'Ice Palace - Map Chest']) and state.has_key('Small Key (Ice Palace)'))) and (state.world.can_take_damage or state.has('Hookshot') or state.has('Cape') or state.has('Cane of Byrna'))) - set_rule(world.get_entrance('Ice Palace (East Top)'), lambda state: state.can_lift_rocks() and state.has('Hammer')) - set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Prize')) + set_rule(world.get_entrance('Ice Palace (East)', player), lambda state: (state.has('Hookshot', player) or (item_in_locations(state, 'Big Key (Ice Palace)', player, [('Ice Palace - Spike Room', player), ('Ice Palace - Big Key Chest', player), ('Ice Palace - Map Chest', player)]) and state.has_key('Small Key (Ice Palace)', player))) and (state.world.can_take_damage or state.has('Hookshot', player) or state.has('Cape', player) or state.has('Cane of Byrna', player))) + set_rule(world.get_entrance('Ice Palace (East Top)', player), lambda state: state.can_lift_rocks(player) and state.has('Hammer', player)) + set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Prize', player)) for location in ['Ice Palace - Big Chest', 'Ice Palace - Boss']: - forbid_item(world.get_location(location), 'Big Key (Ice Palace)') + forbid_item(world.get_location(location, player), 'Big Key (Ice Palace)', player) - set_rule(world.get_entrance('Misery Mire Entrance Gap'), lambda state: (state.has_Boots() or state.has('Hookshot')) and (state.has_sword() or state.has('Fire Rod') or state.has('Ice Rod') or state.has('Hammer') or state.has('Cane of Somaria') or state.can_shoot_arrows())) # need to defeat wizzrobes, bombs don't work ... - set_rule(world.get_location('Misery Mire - Big Chest'), lambda state: state.has('Big Key (Misery Mire)')) - set_rule(world.get_location('Misery Mire - Spike Chest'), lambda state: (state.world.can_take_damage and state.has_hearts(4)) or state.has('Cane of Byrna') or state.has('Cape')) - set_rule(world.get_entrance('Misery Mire Big Key Door'), lambda state: state.has('Big Key (Misery Mire)')) + set_rule(world.get_entrance('Misery Mire Entrance Gap', player), lambda state: (state.has_Boots(player) or state.has('Hookshot', player)) and (state.has_sword(player) or state.has('Fire Rod', player) or state.has('Ice Rod', player) or state.has('Hammer', player) or state.has('Cane of Somaria', player) or state.can_shoot_arrows(player))) # need to defeat wizzrobes, bombs don't work ... + set_rule(world.get_location('Misery Mire - Big Chest', player), lambda state: state.has('Big Key (Misery Mire)', player)) + set_rule(world.get_location('Misery Mire - Spike Chest', player), lambda state: (state.world.can_take_damage and state.has_hearts(player, 4)) or state.has('Cane of Byrna', player) or state.has('Cape', player)) + set_rule(world.get_entrance('Misery Mire Big Key Door', player), lambda state: state.has('Big Key (Misery Mire)', player)) # you can squander the free small key from the pot by opening the south door to the north west switch room, locking you out of accessing a color switch ... # big key gives backdoor access to that from the teleporter in the north west - set_rule(world.get_location('Misery Mire - Map Chest'), lambda state: state.has_key('Small Key (Misery Mire)', 1) or state.has('Big Key (Misery Mire)')) + set_rule(world.get_location('Misery Mire - Map Chest', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 1) or state.has('Big Key (Misery Mire)', player)) # in addition, you can open the door to the map room before getting access to a color switch, so this is locked behing 2 small keys or the big key... - set_rule(world.get_location('Misery Mire - Main Lobby'), lambda state: state.has_key('Small Key (Misery Mire)', 2) or state.has_key('Big Key (Misery Mire)')) + set_rule(world.get_location('Misery Mire - Main Lobby', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 2) or state.has_key('Big Key (Misery Mire)', player)) # we can place a small key in the West wing iff it also contains/blocks the Big Key, as we cannot reach and softlock with the basement key door yet - set_rule(world.get_entrance('Misery Mire (West)'), lambda state: state.has_key('Small Key (Misery Mire)', 2) if ((item_name(state, 'Misery Mire - Compass Chest') in ['Big Key (Misery Mire)']) or - (item_name(state, 'Misery Mire - Big Key Chest') in ['Big Key (Misery Mire)'])) else state.has_key('Small Key (Misery Mire)', 3)) - set_rule(world.get_location('Misery Mire - Compass Chest'), lambda state: state.has_fire_source()) - set_rule(world.get_location('Misery Mire - Big Key Chest'), lambda state: state.has_fire_source()) - set_rule(world.get_entrance('Misery Mire (Vitreous)'), lambda state: state.has('Cane of Somaria')) - set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Prize')) + set_rule(world.get_entrance('Misery Mire (West)', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 2) if ((item_name(state, 'Misery Mire - Compass Chest', player) in [('Big Key (Misery Mire)', player)]) or + (item_name(state, 'Misery Mire - Big Key Chest', player) in [('Big Key (Misery Mire)', player)])) else state.has_key('Small Key (Misery Mire)', player, 3)) + set_rule(world.get_location('Misery Mire - Compass Chest', player), lambda state: state.has_fire_source(player)) + set_rule(world.get_location('Misery Mire - Big Key Chest', player), lambda state: state.has_fire_source(player)) + set_rule(world.get_entrance('Misery Mire (Vitreous)', player), lambda state: state.has('Cane of Somaria', player)) + set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Prize', player)) for location in ['Misery Mire - Big Chest', 'Misery Mire - Boss']: - forbid_item(world.get_location(location), 'Big Key (Misery Mire)') + forbid_item(world.get_location(location, player), 'Big Key (Misery Mire)', player) - set_rule(world.get_entrance('Turtle Rock Entrance Gap'), lambda state: state.has('Cane of Somaria')) - set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse'), lambda state: state.has('Cane of Somaria')) - set_rule(world.get_location('Turtle Rock - Compass Chest'), lambda state: state.has('Cane of Somaria')) # We could get here from the middle section without Cane as we don't cross the entrance gap! - set_rule(world.get_location('Turtle Rock - Roller Room - Left'), lambda state: state.has('Cane of Somaria') and state.has('Fire Rod')) - set_rule(world.get_location('Turtle Rock - Roller Room - Right'), lambda state: state.has('Cane of Somaria') and state.has('Fire Rod')) - set_rule(world.get_location('Turtle Rock - Big Chest'), lambda state: state.has('Big Key (Turtle Rock)') and (state.has('Cane of Somaria') or state.has('Hookshot'))) - set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)'), lambda state: state.has('Cane of Somaria') or state.has('Hookshot')) - set_rule(world.get_entrance('Turtle Rock Big Key Door'), lambda state: state.has('Big Key (Turtle Rock)')) - set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)'), lambda state: state.has('Cane of Somaria')) - set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)'), lambda state: state.has('Cane of Somaria')) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left'), lambda state: state.has('Cane of Byrna') or state.has('Cape') or state.has('Mirror Shield')) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right'), lambda state: state.has('Cane of Byrna') or state.has('Cape') or state.has('Mirror Shield')) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left'), lambda state: state.has('Cane of Byrna') or state.has('Cape') or state.has('Mirror Shield')) - set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right'), lambda state: state.has('Cane of Byrna') or state.has('Cape') or state.has('Mirror Shield')) - set_rule(world.get_entrance('Turtle Rock (Trinexx)'), lambda state: state.has_key('Small Key (Turtle Rock)', 4) and state.has('Big Key (Turtle Rock)') and state.has('Cane of Somaria')) - set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Prize')) + set_rule(world.get_entrance('Turtle Rock Entrance Gap', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_location('Turtle Rock - Compass Chest', player), lambda state: state.has('Cane of Somaria', player)) # We could get here from the middle section without Cane as we don't cross the entrance gap! + set_rule(world.get_location('Turtle Rock - Roller Room - Left', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(world.get_location('Turtle Rock - Roller Room - Right', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(world.get_location('Turtle Rock - Big Chest', player), lambda state: state.has('Big Key (Turtle Rock)', player) and (state.has('Cane of Somaria', player) or state.has('Hookshot', player))) + set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)', player), lambda state: state.has('Cane of Somaria', player) or state.has('Hookshot', player)) + set_rule(world.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player)) + set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_entrance('Turtle Rock (Trinexx)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 4) and state.has('Big Key (Turtle Rock)', player) and state.has('Cane of Somaria', player)) + set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Prize', player)) - set_rule(world.get_entrance('Palace of Darkness Bonk Wall'), lambda state: state.can_shoot_arrows()) - set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop'), lambda state: state.has('Hammer')) - set_rule(world.get_entrance('Palace of Darkness Bridge Room'), lambda state: state.has_key('Small Key (Palace of Darkness)', 1)) # If we can reach any other small key door, we already have back door access to this area - set_rule(world.get_entrance('Palace of Darkness Big Key Door'), lambda state: state.has_key('Small Key (Palace of Darkness)', 6) and state.has('Big Key (Palace of Darkness)') and state.can_shoot_arrows() and state.has('Hammer')) - set_rule(world.get_entrance('Palace of Darkness (North)'), lambda state: state.has_key('Small Key (Palace of Darkness)', 4)) - set_rule(world.get_location('Palace of Darkness - Big Chest'), lambda state: state.has('Big Key (Palace of Darkness)')) + set_rule(world.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: state.can_shoot_arrows(player)) + set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Palace of Darkness Bridge Room', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 1)) # If we can reach any other small key door, we already have back door access to this area + set_rule(world.get_entrance('Palace of Darkness Big Key Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) and state.has('Big Key (Palace of Darkness)', player) and state.can_shoot_arrows(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Palace of Darkness (North)', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 4)) + set_rule(world.get_location('Palace of Darkness - Big Chest', player), lambda state: state.has('Big Key (Palace of Darkness)', player)) - set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase'), lambda state: state.has_key('Small Key (Palace of Darkness)', 6) or (item_name(state, 'Palace of Darkness - Big Key Chest') in ['Small Key (Palace of Darkness)'] and state.has_key('Small Key (Palace of Darkness)', 3))) - set_always_allow(world.get_location('Palace of Darkness - Big Key Chest'), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and state.has_key('Small Key (Palace of Darkness)', 5)) + set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) or (item_name(state, 'Palace of Darkness - Big Key Chest', player) in [('Small Key (Palace of Darkness)', player)] and state.has_key('Small Key (Palace of Darkness)', player, 3))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Palace of Darkness - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state.has_key('Small Key (Palace of Darkness)', player, 5)) + else: + forbid_item(world.get_location('Palace of Darkness - Big Key Chest', player), 'Small Key (Palace of Darkness)', player) - set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door'), lambda state: state.has_key('Small Key (Palace of Darkness)', 6) or (item_name(state, 'Palace of Darkness - Harmless Hellway') in ['Small Key (Palace of Darkness)'] and state.has_key('Small Key (Palace of Darkness)', 4))) - set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway'), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and state.has_key('Small Key (Palace of Darkness)', 5)) - set_rule(world.get_entrance('Palace of Darkness Maze Door'), lambda state: state.has_key('Small Key (Palace of Darkness)', 6)) - set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss')) - set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize')) + set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) or (item_name(state, 'Palace of Darkness - Harmless Hellway', player) in [('Small Key (Palace of Darkness)', player)] and state.has_key('Small Key (Palace of Darkness)', player, 4))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state.has_key('Small Key (Palace of Darkness)', player, 5)) + else: + forbid_item(world.get_location('Palace of Darkness - Harmless Hellway', player), 'Small Key (Palace of Darkness)', player) + + set_rule(world.get_entrance('Palace of Darkness Maze Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6)) + set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize', player)) # these key rules are conservative, you might be able to get away with more lenient rules randomizer_room_chests = ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', 'Ganons Tower - Randomizer Room - Bottom Left', 'Ganons Tower - Randomizer Room - Bottom Right'] compass_room_chests = ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', 'Ganons Tower - Compass Room - Bottom Left', 'Ganons Tower - Compass Room - Bottom Right'] - set_rule(world.get_location('Ganons Tower - Bob\'s Torch'), lambda state: state.has_Boots()) - set_rule(world.get_entrance('Ganons Tower (Tile Room)'), lambda state: state.has('Cane of Somaria')) - set_rule(world.get_entrance('Ganons Tower (Hookshot Room)'), lambda state: state.has('Hammer')) + set_rule(world.get_location('Ganons Tower - Bob\'s Torch', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Ganons Tower (Tile Room)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Ganons Tower (Hookshot Room)', player), lambda state: state.has('Hammer', player)) - set_rule(world.get_entrance('Ganons Tower (Map Room)'), lambda state: state.has_key('Small Key (Ganons Tower)', 4) or (item_name(state, 'Ganons Tower - Map Chest') in ['Big Key (Ganons Tower)', 'Small Key (Ganons Tower)'] and state.has_key('Small Key (Ganons Tower)', 3))) - set_always_allow(world.get_location('Ganons Tower - Map Chest'), lambda state, item: item.name == 'Small Key (Ganons Tower)' and state.has_key('Small Key (Ganons Tower)', 3)) + set_rule(world.get_entrance('Ganons Tower (Map Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_name(state, 'Ganons Tower - Map Chest', player) in [('Big Key (Ganons Tower)', player), ('Small Key (Ganons Tower)', player)] and state.has_key('Small Key (Ganons Tower)', player, 3))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Ganons Tower - Map Chest', player), lambda state, item: item.name == 'Small Key (Ganons Tower)' and item.player == player and state.has_key('Small Key (Ganons Tower)', player, 3)) + else: + forbid_item(world.get_location('Ganons Tower - Map Chest', player), 'Small Key (Ganons Tower)', player) # It is possible to need more than 2 keys to get through this entance if you spend keys elsewhere. We reflect this in the chest requirements. # However we need to leave these at the lower values to derive that with 3 keys it is always possible to reach Bob and Ice Armos. - set_rule(world.get_entrance('Ganons Tower (Double Switch Room)'), lambda state: state.has_key('Small Key (Ganons Tower)', 2)) + set_rule(world.get_entrance('Ganons Tower (Double Switch Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 2)) # It is possible to need more than 3 keys .... - set_rule(world.get_entrance('Ganons Tower (Firesnake Room)'), lambda state: state.has_key('Small Key (Ganons Tower)', 3)) + set_rule(world.get_entrance('Ganons Tower (Firesnake Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3)) #The actual requirements for these rooms to avoid key-lock - set_rule(world.get_location('Ganons Tower - Firesnake Room'), lambda state: state.has_key('Small Key (Ganons Tower)', 3) or (item_in_locations(state, 'Big Key (Ganons Tower)', randomizer_room_chests) and state.has_key('Small Key (Ganons Tower)', 2))) + set_rule(world.get_location('Ganons Tower - Firesnake Room', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 2))) for location in randomizer_room_chests: - set_rule(world.get_location(location), lambda state: state.has_key('Small Key (Ganons Tower)', 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', randomizer_room_chests) and state.has_key('Small Key (Ganons Tower)', 3))) + set_rule(world.get_location(location, player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 3))) # Once again it is possible to need more than 3 keys... - set_rule(world.get_entrance('Ganons Tower (Tile Room) Key Door'), lambda state: state.has_key('Small Key (Ganons Tower)', 3) and state.has('Fire Rod')) + set_rule(world.get_entrance('Ganons Tower (Tile Room) Key Door', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3) and state.has('Fire Rod', player)) # Actual requirements for location in compass_room_chests: - set_rule(world.get_location(location), lambda state: state.has('Fire Rod') and (state.has_key('Small Key (Ganons Tower)', 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', compass_room_chests) and state.has_key('Small Key (Ganons Tower)', 3)))) + set_rule(world.get_location(location, player), lambda state: state.has('Fire Rod', player) and (state.has_key('Small Key (Ganons Tower)', player, 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(compass_room_chests, [player] * len(compass_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 3)))) - set_rule(world.get_location('Ganons Tower - Big Chest'), lambda state: state.has('Big Key (Ganons Tower)')) + set_rule(world.get_location('Ganons Tower - Big Chest', player), lambda state: state.has('Big Key (Ganons Tower)', player)) - set_rule(world.get_location('Ganons Tower - Big Key Room - Left'), lambda state: world.get_location('Ganons Tower - Big Key Room - Left').parent_region.dungeon.bosses['bottom'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Big Key Chest'), lambda state: world.get_location('Ganons Tower - Big Key Chest').parent_region.dungeon.bosses['bottom'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Big Key Room - Right'), lambda state: world.get_location('Ganons Tower - Big Key Room - Right').parent_region.dungeon.bosses['bottom'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Big Key Room - Left', player), lambda state: world.get_location('Ganons Tower - Big Key Room - Left', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Big Key Chest', player), lambda state: world.get_location('Ganons Tower - Big Key Chest', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Big Key Room - Right', player), lambda state: world.get_location('Ganons Tower - Big Key Room - Right', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) - set_rule(world.get_entrance('Ganons Tower Big Key Door'), lambda state: state.has('Big Key (Ganons Tower)') and state.can_shoot_arrows()) - set_rule(world.get_entrance('Ganons Tower Torch Rooms'), lambda state: state.has_fire_source() and world.get_entrance('Ganons Tower Torch Rooms').parent_region.dungeon.bosses['middle'].can_defeat(state)) - set_rule(world.get_location('Ganons Tower - Pre-Moldorm Chest'), lambda state: state.has_key('Small Key (Ganons Tower)', 3)) - set_rule(world.get_entrance('Ganons Tower Moldorm Door'), lambda state: state.has_key('Small Key (Ganons Tower)', 4)) - set_rule(world.get_entrance('Ganons Tower Moldorm Gap'), lambda state: state.has('Hookshot') and world.get_entrance('Ganons Tower Moldorm Gap').parent_region.dungeon.bosses['top'].can_defeat(state)) - set_defeat_dungeon_boss_rule(world.get_location('Agahnim 2')) - set_rule(world.get_entrance('Pyramid Hole'), lambda state: state.has('Beat Agahnim 2')) + set_rule(world.get_entrance('Ganons Tower Big Key Door', player), lambda state: state.has('Big Key (Ganons Tower)', player) and state.can_shoot_arrows(player)) + set_rule(world.get_entrance('Ganons Tower Torch Rooms', player), lambda state: state.has_fire_source(player) and world.get_entrance('Ganons Tower Torch Rooms', player).parent_region.dungeon.bosses['middle'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Pre-Moldorm Chest', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3)) + set_rule(world.get_entrance('Ganons Tower Moldorm Door', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4)) + set_rule(world.get_entrance('Ganons Tower Moldorm Gap', player), lambda state: state.has('Hookshot', player) and world.get_entrance('Ganons Tower Moldorm Gap', player).parent_region.dungeon.bosses['top'].can_defeat(state)) + set_defeat_dungeon_boss_rule(world.get_location('Agahnim 2', player)) + set_rule(world.get_entrance('Pyramid Hole', player), lambda state: state.has('Beat Agahnim 2', player)) for location in ['Ganons Tower - Big Chest', 'Ganons Tower - Mini Helmasaur Room - Left', 'Ganons Tower - Mini Helmasaur Room - Right', 'Ganons Tower - Pre-Moldorm Chest', 'Ganons Tower - Validation Chest']: - forbid_item(world.get_location(location), 'Big Key (Ganons Tower)') + forbid_item(world.get_location(location, player), 'Big Key (Ganons Tower)', player) - set_rule(world.get_location('Ganon'), lambda state: state.has_beam_sword() and state.has_fire_source() and state.has('Crystal 1') and state.has('Crystal 2') - and state.has('Crystal 3') and state.has('Crystal 4') and state.has('Crystal 5') and state.has('Crystal 6') and state.has('Crystal 7') - and (state.has('Tempered Sword') or state.has('Golden Sword') or (state.has('Silver Arrows') and state.can_shoot_arrows()) or state.has('Lamp') or state.can_extend_magic(12))) # need to light torch a sufficient amount of times - set_rule(world.get_entrance('Ganon Drop'), lambda state: state.has_beam_sword()) # need to damage ganon to get tiles to drop + set_rule(world.get_location('Ganon', player), lambda state: state.has_beam_sword(player) and state.has_fire_source(player) and state.has_crystals(world.crystals_needed_for_ganon, player) + and (state.has('Tempered Sword', player) or state.has('Golden Sword', player) or (state.has('Silver Arrows', player) and state.can_shoot_arrows(player)) or state.has('Lamp', player) or state.can_extend_magic(player, 12))) # need to light torch a sufficient amount of times + set_rule(world.get_entrance('Ganon Drop', player), lambda state: state.has_beam_sword(player)) # need to damage ganon to get tiles to drop - set_rule(world.get_entrance('Ganons Tower'), lambda state: False) # This is a safety for the TR function below to not require GT entrance in its key logic. + set_rule(world.get_entrance('Ganons Tower', player), lambda state: False) # This is a safety for the TR function below to not require GT entrance in its key logic. - set_trock_key_rules(world) + if world.swords == 'swordless': + swordless_rules(world, player) - set_rule(world.get_entrance('Ganons Tower'), lambda state: state.has('Crystal 1') and state.has('Crystal 2') and state.has('Crystal 3') and state.has('Crystal 4') and state.has('Crystal 5') and state.has('Crystal 6') and state.has('Crystal 7')) + set_trock_key_rules(world, player) + set_rule(world.get_entrance('Ganons Tower', player), lambda state: state.has_crystals(world.crystals_needed_for_gt, player)) -def no_glitches_rules(world): - set_rule(world.get_entrance('Zoras River'), lambda state: state.has('Flippers') or state.can_lift_rocks()) - set_rule(world.get_entrance('Lake Hylia Central Island Pier'), lambda state: state.has('Flippers')) # can be fake flippered to - set_rule(world.get_entrance('Hobo Bridge'), lambda state: state.has('Flippers')) - set_rule(world.get_entrance('Dark Lake Hylia Drop (East)'), lambda state: state.has_Pearl() and state.has('Flippers')) - set_rule(world.get_entrance('Dark Lake Hylia Teleporter'), lambda state: state.has_Pearl() and state.has('Flippers') and (state.has('Hammer') or state.can_lift_rocks())) - set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop'), lambda state: state.has_Pearl() and state.has('Flippers')) - add_rule(world.get_entrance('Ganons Tower (Hookshot Room)'), lambda state: state.has('Hookshot') or state.has_Boots()) - add_rule(world.get_entrance('Ganons Tower (Double Switch Room)'), lambda state: state.has('Hookshot')) +def inverted_rules(world, player): + if world.goal == 'triforcehunt': + for location in world.get_locations(): + if location.player != player: + forbid_item(location, 'Triforce Piece', player) + + add_item_rule(world.get_location('Ganon', player), lambda item: item.name == 'Triforce' and item.player == player) + + world.get_region('Inverted Links House', player).can_reach_private = lambda state: True + world.get_region('Inverted Dark Sanctuary', player).entrances[0].parent_region.can_reach_private = lambda state: True + + # we can s&q to the old man house after we rescue him. This may be somewhere completely different if caves are shuffled! + if world.shuffle != 'vanilla': + old_rule = world.get_region('Old Man House', player).can_reach + world.get_region('Old Man House', player).can_reach_private = lambda state: state.can_reach('Old Man', 'Location', player) or old_rule(state) + # overworld requirements + set_rule(world.get_location('Maze Race', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Mini Moldorm Cave', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Light Hype Fairy', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Potion Shop Pier', player), lambda state: state.has('Flippers', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Light World Pier', player), lambda state: state.has('Flippers', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Kings Grave', player), lambda state: state.has_Boots(player) and state.can_lift_heavy_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Kings Grave Outer Rocks', player), lambda state: state.can_lift_heavy_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Kings Grave Inner Rocks', player), lambda state: state.can_lift_heavy_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Potion Shop Inner Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Potion Shop Outer Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Potion Shop Outer Rock', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Potion Shop Inner Rock', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Graveyard Cave Inner Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Graveyard Cave Outer Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Secret Passage Inner Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Secret Passage Outer Bushes', player), lambda state: state.has_Pearl(player)) + # Caution: If king's grave is releaxed at all to account for reaching it via a two way cave's exit in insanity mode, then the bomb shop logic will need to be updated (that would involve create a small ledge-like Region for it) + set_rule(world.get_entrance('Bonk Fairy (Light)', player), lambda state: state.has_Boots(player) and state.has_Pearl(player)) + add_rule(world.get_location('Sunken Treasure', player), lambda state: state.can_reach('Light World', 'Region', player) and state.has('Open Floodgate', player)) + set_rule(world.get_entrance('Bat Cave Drop Ledge', player), lambda state: state.has('Hammer', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Lumberjack Tree Tree', player), lambda state: state.has_Boots(player) and state.has_Pearl(player) and state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('Bonk Rock Cave', player), lambda state: state.has_Boots(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Desert Palace Stairs', player), lambda state: state.has('Book of Mudora', player)) # bunny can use book + set_rule(world.get_entrance('Sanctuary Grave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('20 Rupee Cave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('50 Rupee Cave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Death Mountain Entrance Rock', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Bumper Cave Entrance Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Lake Hylia Central Island Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark Lake Hylia Central Island Teleporter', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Dark Desert Teleporter', player), lambda state: state.can_flute(player) and state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('East Dark World Teleporter', player), lambda state: state.has('Hammer', player) and state.can_lift_rocks(player) and state.has_Pearl(player)) # bunny cannot use hammer + set_rule(world.get_entrance('South Dark World Teleporter', player), lambda state: state.has('Hammer', player) and state.can_lift_rocks(player) and state.has_Pearl(player)) # bunny cannot use hammer + set_rule(world.get_entrance('West Dark World Teleporter', player), lambda state: ((state.has('Hammer', player) and state.can_lift_rocks(player)) or state.can_lift_heavy_rocks(player)) and state.has_Pearl(player)) + set_rule(world.get_location('Flute Spot', player), lambda state: state.has('Shovel', player) and state.has_Pearl(player)) + set_rule(world.get_location('Dark Blacksmith Ruins', player), lambda state: state.has('Return Smith', player)) + set_rule(world.get_location('Purple Chest', player), lambda state: state.has('Pick Up Purple Chest', player)) # Can S&Q with chest + + set_rule(world.get_location('Zora\'s Ledge', player), lambda state: state.has('Flippers', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Waterfall of Wishing', player), lambda state: state.has('Flippers', player) and state.has_Pearl(player)) # can be fake flippered into, but is in weird state inside that might prevent you from doing things. Can be improved in future Todo + set_rule(world.get_location('Frog', player), lambda state: state.can_lift_heavy_rocks(player) or (state.can_reach('Light World', 'Region', player) and state.has_Mirror(player))) + set_rule(world.get_location('Missing Smith', player), lambda state: state.has('Get Frog', player) and state.can_reach('Blacksmiths Hut', 'Region', player)) # Can't S&Q with smith + set_rule(world.get_location('Blacksmith', player), lambda state: state.has('Return Smith', player)) + set_rule(world.get_location('Magic Bat', player), lambda state: state.has('Magic Powder', player) and state.has_Pearl(player)) + set_rule(world.get_location('Sick Kid', player), lambda state: state.has_bottle(player)) + set_rule(world.get_location('Mushroom', player), lambda state: state.has_Pearl(player)) # need pearl to pick up bushes + set_rule(world.get_entrance('Bush Covered Lawn Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Bush Covered Lawn Inner Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Bush Covered Lawn Outer Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Bomb Hut Inner Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Bomb Hut Outer Bushes', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('North Fairy Cave Drop', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Lost Woods Hideout Drop', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_location('Library', player), lambda state: state.has_Boots(player)) + set_rule(world.get_location('Potion Shop', player), lambda state: state.has('Mushroom', player) and (state.can_reach('Potion Shop Area', 'Region', player))) # new inverted region, need pearl for bushes or access to potion shop door/waterfall fairy + set_rule(world.get_entrance('Desert Palace Entrance (North) Rocks', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Desert Ledge Return Rocks', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) # should we decide to place something that is not a dungeon end up there at some point + set_rule(world.get_entrance('Checkerboard Cave', player), lambda state: state.can_lift_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_location('Master Sword Pedestal', player), lambda state: state.has('Red Pendant', player) and state.has('Blue Pendant', player) and state.has('Green Pendant', player)) + set_rule(world.get_location('Sahasrahla', player), lambda state: state.has('Green Pendant', player)) + set_rule(world.get_entrance('Agahnim 1', player), lambda state: state.has_sword(player) and state.has_key('Small Key (Agahnims Tower)', player, 2)) + set_defeat_dungeon_boss_rule(world.get_location('Agahnim 1', player)) + set_rule(world.get_location('Castle Tower - Dark Maze', player), lambda state: state.has_key('Small Key (Agahnims Tower)', player)) + set_rule(world.get_entrance('LW Hyrule Castle Ledge SQ', player), lambda state: state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('EDM Hyrule Castle Ledge SQ', player), lambda state: state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('WDM Hyrule Castle Ledge SQ', player), lambda state: state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('Hyrule Castle Secret Entrance Drop', player), lambda state: state.has_Pearl(player)) + set_rule(world.get_entrance('Old Man Cave Exit (West)', player), lambda state: False) # drop cannot be climbed up + set_rule(world.get_entrance('Broken Bridge (West)', player), lambda state: state.has('Hookshot', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Broken Bridge (East)', player), lambda state: state.has('Hookshot', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Dark Death Mountain Teleporter (East Bottom)', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Fairy Ascension Rocks', player), lambda state: state.can_lift_heavy_rocks(player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Paradox Cave Push Block Reverse', player), lambda state: state.has('Mirror', player)) # can erase block + set_rule(world.get_entrance('Death Mountain (Top)', player), lambda state: state.has('Hammer', player) and state.has_Pearl(player)) + set_rule(world.get_entrance('Dark Death Mountain Teleporter (East)', player), lambda state: state.can_lift_heavy_rocks(player) and state.has('Hammer', player) and state.has_Pearl(player)) # bunny cannot use hammer + set_rule(world.get_location('Ether Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has_beam_sword(player)) + set_rule(world.get_entrance('East Death Mountain (Top)', player), lambda state: state.has('Hammer', player) and state.has_Pearl(player)) # bunny can not use hammer + + set_rule(world.get_location('Catfish', player), lambda state: state.can_lift_rocks(player) or (state.has('Flippers', player) and state.has_Mirror(player) and state.has_Pearl(player) and state.can_reach('Light World', 'Region', player))) + set_rule(world.get_entrance('Northeast Dark World Broken Bridge Pass', player), lambda state: ((state.can_lift_rocks(player) or state.has('Hammer', player)) or state.has('Flippers', player))) + set_rule(world.get_entrance('East Dark World Broken Bridge Pass', player), lambda state: (state.can_lift_rocks(player) or state.has('Hammer', player))) + set_rule(world.get_entrance('South Dark World Bridge', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Bonk Fairy (Dark)', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('West Dark World Gap', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (East)', player), lambda state: state.has('Flippers', player)) + set_rule(world.get_location('Bombos Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has_beam_sword(player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (South)', player), lambda state: state.has('Flippers', player)) # ToDo any fake flipper set up? + set_rule(world.get_entrance('Dark Lake Hylia Ledge Pier', player), lambda state: state.has('Flippers', player)) + set_rule(world.get_entrance('Dark Lake Hylia Ledge Spike Cave', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Dark Lake Hylia Teleporter', player), lambda state: state.has('Flippers', player) and (state.has('Hammer', player) or state.can_lift_rocks(player))) # Fake Flippers + set_rule(world.get_entrance('Village of Outcasts Heavy Rock', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('East Dark World Bridge', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Lake Hylia Central Island Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('East Dark World River Pier', player), lambda state: state.has('Flippers', player)) # ToDo any fake flipper set up? (Qirn Jump) + set_rule(world.get_entrance('Bumper Cave Entrance Rock', player), lambda state: state.can_lift_rocks(player)) + set_rule(world.get_entrance('Bumper Cave Ledge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Hammer Peg Area Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark World Hammer Peg Cave', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Village of Outcasts Eastern Rocks', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Peg Area Rocks', player), lambda state: state.can_lift_heavy_rocks(player)) + set_rule(world.get_entrance('Village of Outcasts Pegs', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Grassy Lawn Pegs', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Bumper Cave Exit (Top)', player), lambda state: state.has('Cape', player)) + set_rule(world.get_entrance('Bumper Cave Exit (Bottom)', player), lambda state: state.has('Cape', player) or state.has('Hookshot', player)) + + set_rule(world.get_entrance('Skull Woods Final Section', player), lambda state: state.has('Fire Rod', player)) + set_rule(world.get_entrance('Misery Mire', player), lambda state: state.has_sword(player) and state.has_misery_mire_medallion(player)) # sword required to cast magic (!) + + set_rule(world.get_entrance('Hookshot Cave', player), lambda state: state.can_lift_rocks(player)) + + set_rule(world.get_entrance('East Death Mountain Mirror Spot (Top)', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Death Mountain (Top) Mirror Spot', player), lambda state: state.has_Mirror(player)) + + set_rule(world.get_entrance('East Death Mountain Mirror Spot (Bottom)', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark Death Mountain Ledge Mirror Spot (East)', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Dark Death Mountain Ledge Mirror Spot (West)', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Laser Bridge Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Superbunny Cave Exit (Bottom)', player), lambda state: False) # Cannot get to bottom exit from top. Just exists for shuffling + + set_rule(world.get_location('Spike Cave', player), lambda state: + state.has('Hammer', player) and state.can_lift_rocks(player) and + ((state.has('Cape', player) and state.can_extend_magic(player, 16, True)) or + (state.has('Cane of Byrna', player) and + (state.can_extend_magic(player, 12, True) or + (state.world.can_take_damage and (state.has_Boots(player) or state.has_hearts(player, 4)))))) + ) + + set_rule(world.get_location('Hookshot Cave - Top Right', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_location('Hookshot Cave - Top Left', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_location('Hookshot Cave - Bottom Right', player), lambda state: state.has('Hookshot', player) or state.has('Pegasus Boots', player)) + set_rule(world.get_location('Hookshot Cave - Bottom Left', player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('Floating Island Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Turtle Rock', player), lambda state: state.has_sword(player) and state.has_turtle_rock_medallion(player) and state.can_reach('Turtle Rock (Top)', 'Region', player)) # sword required to cast magic (!) + set_rule(world.get_location('Mimic Cave', player), lambda state: state.has('Hammer', player)) + + # new inverted spots + set_rule(world.get_entrance('Post Aga Teleporter', player), lambda state: state.has('Beat Agahnim 1', player)) + set_rule(world.get_entrance('Mire Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Desert Palace Stairs Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Death Mountain Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('East Dark World Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('West Dark World Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('South Dark World Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Northeast Dark World Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Potion Shop Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Shopping Mall Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Maze Race Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Desert Palace North Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Death Mountain (Top) Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Graveyard Cave Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Bomb Hut Mirror Spot', player), lambda state: state.has_Mirror(player)) + set_rule(world.get_entrance('Skull Woods Mirror Spot', player), lambda state: state.has_Mirror(player)) + + # inverted flute spots + + set_rule(world.get_entrance('DDM Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('NEDW Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('WDW Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('SDW Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('EDW Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('DLHL Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('DD Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('EDDM Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('Dark Grassy Lawn Flute', player), lambda state: state.can_flute(player)) + set_rule(world.get_entrance('Hammer Peg Area Flute', player), lambda state: state.can_flute(player)) + + set_rule(world.get_entrance('Sewers Door', player), lambda state: state.has_key('Small Key (Escape)', player)) + set_rule(world.get_entrance('Sewers Back Door', player), lambda state: state.has_key('Small Key (Escape)', player)) + + set_rule(world.get_location('Eastern Palace - Big Chest', player), lambda state: state.has('Big Key (Eastern Palace)', player)) + set_rule(world.get_location('Eastern Palace - Boss', player), lambda state: state.can_shoot_arrows(player) and state.has('Big Key (Eastern Palace)', player) and world.get_location('Eastern Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Eastern Palace - Prize', player), lambda state: state.can_shoot_arrows(player) and state.has('Big Key (Eastern Palace)', player) and world.get_location('Eastern Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) + for location in ['Eastern Palace - Boss', 'Eastern Palace - Big Chest']: + forbid_item(world.get_location(location, player), 'Big Key (Eastern Palace)', player) + + set_rule(world.get_location('Desert Palace - Big Chest', player), lambda state: state.has('Big Key (Desert Palace)', player)) + set_rule(world.get_location('Desert Palace - Torch', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Desert Palace East Wing', player), lambda state: state.has_key('Small Key (Desert Palace)', player)) + set_rule(world.get_location('Desert Palace - Prize', player), lambda state: state.has_key('Small Key (Desert Palace)', player) and state.has('Big Key (Desert Palace)', player) and state.has_fire_source(player) and world.get_location('Desert Palace - Prize', player).parent_region.dungeon.boss.can_defeat(state)) + set_rule(world.get_location('Desert Palace - Boss', player), lambda state: state.has_key('Small Key (Desert Palace)', player) and state.has('Big Key (Desert Palace)', player) and state.has_fire_source(player) and world.get_location('Desert Palace - Boss', player).parent_region.dungeon.boss.can_defeat(state)) + for location in ['Desert Palace - Boss', 'Desert Palace - Big Chest']: + forbid_item(world.get_location(location, player), 'Big Key (Desert Palace)', player) + + for location in ['Desert Palace - Boss', 'Desert Palace - Big Key Chest', 'Desert Palace - Compass Chest']: + forbid_item(world.get_location(location, player), 'Small Key (Desert Palace)', player) + + set_rule(world.get_entrance('Tower of Hera Small Key Door', player), lambda state: state.has_key('Small Key (Tower of Hera)', player) or item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player)) + set_rule(world.get_entrance('Tower of Hera Big Key Door', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(world.get_location('Tower of Hera - Big Chest', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(world.get_location('Tower of Hera - Big Key Chest', player), lambda state: state.has_fire_source(player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Tower of Hera - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Tower of Hera)' and item.player == player) + set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Tower of Hera - Prize', player)) + for location in ['Tower of Hera - Boss', 'Tower of Hera - Big Chest', 'Tower of Hera - Compass Chest']: + forbid_item(world.get_location(location, player), 'Big Key (Tower of Hera)', player) +# for location in ['Tower of Hera - Big Key Chest']: +# forbid_item(world.get_location(location, player), 'Small Key (Tower of Hera)', player) + + set_rule(world.get_entrance('Swamp Palace Moat', player), lambda state: state.has('Flippers', player) and state.has('Open Floodgate', player)) + add_rule(world.get_location('Sunken Treasure', player), lambda state: state.has('Open Floodgate', player)) + + set_rule(world.get_entrance('Swamp Palace Small Key Door', player), lambda state: state.has_key('Small Key (Swamp Palace)', player)) + set_rule(world.get_entrance('Swamp Palace (Center)', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_location('Swamp Palace - Big Chest', player), lambda state: state.has('Big Key (Swamp Palace)', player) or item_name(state, 'Swamp Palace - Big Chest', player) == ('Big Key (Swamp Palace)', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Swamp Palace - Big Chest', player), lambda state, item: item.name == 'Big Key (Swamp Palace)' and item.player == player) + set_rule(world.get_entrance('Swamp Palace (North)', player), lambda state: state.has('Hookshot', player)) + set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Swamp Palace - Prize', player)) + for location in ['Swamp Palace - Entrance']: + forbid_item(world.get_location(location, player), 'Big Key (Swamp Palace)', player) + + set_rule(world.get_entrance('Thieves Town Big Key Door', player), lambda state: state.has('Big Key (Thieves Town)', player)) + set_rule(world.get_entrance('Blind Fight', player), lambda state: state.has_key('Small Key (Thieves Town)', player)) + set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Thieves\' Town - Prize', player)) + set_rule(world.get_location('Thieves\' Town - Big Chest', player), lambda state: (state.has_key('Small Key (Thieves Town)', player) or item_name(state, 'Thieves\' Town - Big Chest', player) == ('Small Key (Thieves Town)', player)) and state.has('Hammer', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Thieves\' Town - Big Chest', player), lambda state, item: item.name == 'Small Key (Thieves Town)' and item.player == player and state.has('Hammer', player)) + set_rule(world.get_location('Thieves\' Town - Attic', player), lambda state: state.has_key('Small Key (Thieves Town)', player)) + for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Big Chest', 'Thieves\' Town - Blind\'s Cell', 'Thieves\' Town - Boss']: + forbid_item(world.get_location(location, player), 'Big Key (Thieves Town)', player) + for location in ['Thieves\' Town - Attic', 'Thieves\' Town - Boss']: + forbid_item(world.get_location(location, player), 'Small Key (Thieves Town)', player) + + set_rule(world.get_entrance('Skull Woods First Section South Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player)) + set_rule(world.get_entrance('Skull Woods First Section (Right) North Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player)) + set_rule(world.get_entrance('Skull Woods First Section West Door', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 2)) # ideally would only be one key, but we may have spent thst key already on escaping the right section + set_rule(world.get_entrance('Skull Woods First Section (Left) Door to Exit', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 2)) + set_rule(world.get_location('Skull Woods - Big Chest', player), lambda state: state.has('Big Key (Skull Woods)', player) or item_name(state, 'Skull Woods - Big Chest', player) == ('Big Key (Skull Woods)', player)) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Skull Woods - Big Chest', player), lambda state, item: item.name == 'Big Key (Skull Woods)' and item.player == player) + + set_rule(world.get_entrance('Skull Woods Torch Room', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 3) and state.has('Fire Rod', player) and state.has_sword(player)) # sword required for curtain + set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Skull Woods - Prize', player)) + for location in ['Skull Woods - Boss']: + forbid_item(world.get_location(location, player), 'Small Key (Skull Woods)', player) + + set_rule(world.get_entrance('Ice Palace Entrance Room', player), lambda state: state.can_melt_things(player)) + set_rule(world.get_location('Ice Palace - Big Chest', player), lambda state: state.has('Big Key (Ice Palace)', player)) + set_rule(world.get_entrance('Ice Palace (Kholdstare)', player), lambda state: state.can_lift_rocks(player) and state.has('Hammer', player) and state.has('Big Key (Ice Palace)', player) and (state.has_key('Small Key (Ice Palace)', player, 2) or (state.has('Cane of Somaria', player) and state.has_key('Small Key (Ice Palace)', player, 1)))) + # TODO: investigate change from VT. Changed to hookshot or 2 keys (no checking for big key in specific chests) + set_rule(world.get_entrance('Ice Palace (East)', player), lambda state: (state.has('Hookshot', player) or (item_in_locations(state, 'Big Key (Ice Palace)', player, [('Ice Palace - Spike Room', player), ('Ice Palace - Big Key Chest', player), ('Ice Palace - Map Chest', player)]) and state.has_key('Small Key (Ice Palace)', player))) and (state.world.can_take_damage or state.has('Hookshot', player) or state.has('Cape', player) or state.has('Cane of Byrna', player))) + set_rule(world.get_entrance('Ice Palace (East Top)', player), lambda state: state.can_lift_rocks(player) and state.has('Hammer', player)) + set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Ice Palace - Prize', player)) + for location in ['Ice Palace - Big Chest', 'Ice Palace - Boss']: + forbid_item(world.get_location(location, player), 'Big Key (Ice Palace)', player) + + set_rule(world.get_entrance('Misery Mire Entrance Gap', player), lambda state: (state.has_Boots(player) or state.has('Hookshot', player)) and (state.has_sword(player) or state.has('Fire Rod', player) or state.has('Ice Rod', player) or state.has('Hammer', player) or state.has('Cane of Somaria', player) or state.can_shoot_arrows(player))) # need to defeat wizzrobes, bombs don't work ... + set_rule(world.get_location('Misery Mire - Big Chest', player), lambda state: state.has('Big Key (Misery Mire)', player)) + set_rule(world.get_location('Misery Mire - Spike Chest', player), lambda state: (state.world.can_take_damage and state.has_hearts(player, 4)) or state.has('Cane of Byrna', player) or state.has('Cape', player)) + set_rule(world.get_entrance('Misery Mire Big Key Door', player), lambda state: state.has('Big Key (Misery Mire)', player)) + # you can squander the free small key from the pot by opening the south door to the north west switch room, locking you out of accessing a color switch ... + # big key gives backdoor access to that from the teleporter in the north west + set_rule(world.get_location('Misery Mire - Map Chest', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 1) or state.has('Big Key (Misery Mire)', player)) + # in addition, you can open the door to the map room before getting access to a color switch, so this is locked behing 2 small keys or the big key... + set_rule(world.get_location('Misery Mire - Main Lobby', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 2) or state.has_key('Big Key (Misery Mire)', player)) + # we can place a small key in the West wing iff it also contains/blocks the Big Key, as we cannot reach and softlock with the basement key door yet + set_rule(world.get_entrance('Misery Mire (West)', player), lambda state: state.has_key('Small Key (Misery Mire)', player, 2) if ((item_name(state, 'Misery Mire - Compass Chest', player) in [('Big Key (Misery Mire)', player)]) or + (item_name(state, 'Misery Mire - Big Key Chest', player) in [('Big Key (Misery Mire)', player)])) else state.has_key('Small Key (Misery Mire)', player, 3)) + set_rule(world.get_location('Misery Mire - Compass Chest', player), lambda state: state.has_fire_source(player)) + set_rule(world.get_location('Misery Mire - Big Key Chest', player), lambda state: state.has_fire_source(player)) + set_rule(world.get_entrance('Misery Mire (Vitreous)', player), lambda state: state.has('Cane of Somaria', player)) + set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Misery Mire - Prize', player)) + for location in ['Misery Mire - Big Chest', 'Misery Mire - Boss']: + forbid_item(world.get_location(location, player), 'Big Key (Misery Mire)', player) + + set_rule(world.get_entrance('Turtle Rock Entrance Gap', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Turtle Rock Entrance Gap Reverse', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_location('Turtle Rock - Compass Chest', player), lambda state: state.has('Cane of Somaria', player)) # We could get here from the middle section without Cane as we don't cross the entrance gap! + set_rule(world.get_location('Turtle Rock - Roller Room - Left', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(world.get_location('Turtle Rock - Roller Room - Right', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player)) + set_rule(world.get_location('Turtle Rock - Big Chest', player), lambda state: state.has('Big Key (Turtle Rock)', player) and (state.has('Cane of Somaria', player) or state.has('Hookshot', player))) + set_rule(world.get_entrance('Turtle Rock (Big Chest) (North)', player), lambda state: state.has('Cane of Somaria', player) or state.has('Hookshot', player)) + set_rule(world.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player)) + set_rule(world.get_entrance('Turtle Rock (Dark Room) (North)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Turtle Rock (Dark Room) (South)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Bottom Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Left', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_location('Turtle Rock - Eye Bridge - Top Right', player), lambda state: state.has('Cane of Byrna', player) or state.has('Cape', player) or state.has('Mirror Shield', player)) + set_rule(world.get_entrance('Turtle Rock (Trinexx)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 4) and state.has('Big Key (Turtle Rock)', player) and state.has('Cane of Somaria', player)) + set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Turtle Rock - Prize', player)) + + set_rule(world.get_entrance('Palace of Darkness Bonk Wall', player), lambda state: state.can_shoot_arrows(player)) + set_rule(world.get_entrance('Palace of Darkness Hammer Peg Drop', player), lambda state: state.has('Hammer', player)) + set_rule(world.get_entrance('Palace of Darkness Bridge Room', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 1)) # If we can reach any other small key door, we already have back door access to this area + set_rule(world.get_entrance('Palace of Darkness Big Key Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) and state.has('Big Key (Palace of Darkness)', player) and state.can_shoot_arrows(player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Palace of Darkness (North)', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 4)) + set_rule(world.get_location('Palace of Darkness - Big Chest', player), lambda state: state.has('Big Key (Palace of Darkness)', player)) + + set_rule(world.get_entrance('Palace of Darkness Big Key Chest Staircase', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) or (item_name(state, 'Palace of Darkness - Big Key Chest', player) in [('Small Key (Palace of Darkness)', player)] and state.has_key('Small Key (Palace of Darkness)', player, 3))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Palace of Darkness - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state.has_key('Small Key (Palace of Darkness)', player, 5)) + else: + forbid_item(world.get_location('Palace of Darkness - Big Key Chest', player), 'Small Key (Palace of Darkness)', player) + + set_rule(world.get_entrance('Palace of Darkness Spike Statue Room Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6) or (item_name(state, 'Palace of Darkness - Harmless Hellway', player) in [('Small Key (Palace of Darkness)', player)] and state.has_key('Small Key (Palace of Darkness)', player, 4))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Palace of Darkness - Harmless Hellway', player), lambda state, item: item.name == 'Small Key (Palace of Darkness)' and item.player == player and state.has_key('Small Key (Palace of Darkness)', player, 5)) + else: + forbid_item(world.get_location('Palace of Darkness - Harmless Hellway', player), 'Small Key (Palace of Darkness)', player) + + set_rule(world.get_entrance('Palace of Darkness Maze Door', player), lambda state: state.has_key('Small Key (Palace of Darkness)', player, 6)) + set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Boss', player)) + set_defeat_dungeon_boss_rule(world.get_location('Palace of Darkness - Prize', player)) + + # these key rules are conservative, you might be able to get away with more lenient rules + randomizer_room_chests = ['Ganons Tower - Randomizer Room - Top Left', 'Ganons Tower - Randomizer Room - Top Right', 'Ganons Tower - Randomizer Room - Bottom Left', 'Ganons Tower - Randomizer Room - Bottom Right'] + compass_room_chests = ['Ganons Tower - Compass Room - Top Left', 'Ganons Tower - Compass Room - Top Right', 'Ganons Tower - Compass Room - Bottom Left', 'Ganons Tower - Compass Room - Bottom Right'] + + set_rule(world.get_location('Ganons Tower - Bob\'s Torch', player), lambda state: state.has_Boots(player)) + set_rule(world.get_entrance('Ganons Tower (Tile Room)', player), lambda state: state.has('Cane of Somaria', player)) + set_rule(world.get_entrance('Ganons Tower (Hookshot Room)', player), lambda state: state.has('Hammer', player)) + + set_rule(world.get_entrance('Ganons Tower (Map Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_name(state, 'Ganons Tower - Map Chest', player) in [('Big Key (Ganons Tower)', player), ('Small Key (Ganons Tower)', player)] and state.has_key('Small Key (Ganons Tower)', player, 3))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Ganons Tower - Map Chest', player), lambda state, item: item.name == 'Small Key (Ganons Tower)' and item.player == player and state.has_key('Small Key (Ganons Tower)', player, 3)) + else: + forbid_item(world.get_location('Ganons Tower - Map Chest', player), 'Small Key (Ganons Tower)', player) + + # It is possible to need more than 2 keys to get through this entance if you spend keys elsewhere. We reflect this in the chest requirements. + # However we need to leave these at the lower values to derive that with 3 keys it is always possible to reach Bob and Ice Armos. + set_rule(world.get_entrance('Ganons Tower (Double Switch Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 2)) + # It is possible to need more than 3 keys .... + set_rule(world.get_entrance('Ganons Tower (Firesnake Room)', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3)) + + #The actual requirements for these rooms to avoid key-lock + set_rule(world.get_location('Ganons Tower - Firesnake Room', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 2))) + for location in randomizer_room_chests: + set_rule(world.get_location(location, player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(randomizer_room_chests, [player] * len(randomizer_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 3))) + + # Once again it is possible to need more than 3 keys... + set_rule(world.get_entrance('Ganons Tower (Tile Room) Key Door', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3) and state.has('Fire Rod', player)) + # Actual requirements + for location in compass_room_chests: + set_rule(world.get_location(location, player), lambda state: state.has('Fire Rod', player) and (state.has_key('Small Key (Ganons Tower)', player, 4) or (item_in_locations(state, 'Big Key (Ganons Tower)', player, zip(compass_room_chests, [player] * len(compass_room_chests))) and state.has_key('Small Key (Ganons Tower)', player, 3)))) + + set_rule(world.get_location('Ganons Tower - Big Chest', player), lambda state: state.has('Big Key (Ganons Tower)', player)) + + set_rule(world.get_location('Ganons Tower - Big Key Room - Left', player), lambda state: world.get_location('Ganons Tower - Big Key Room - Left', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Big Key Chest', player), lambda state: world.get_location('Ganons Tower - Big Key Chest', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Big Key Room - Right', player), lambda state: world.get_location('Ganons Tower - Big Key Room - Right', player).parent_region.dungeon.bosses['bottom'].can_defeat(state)) + + set_rule(world.get_entrance('Ganons Tower Big Key Door', player), lambda state: state.has('Big Key (Ganons Tower)', player) and state.can_shoot_arrows(player)) + set_rule(world.get_entrance('Ganons Tower Torch Rooms', player), lambda state: state.has_fire_source(player) and world.get_entrance('Ganons Tower Torch Rooms', player).parent_region.dungeon.bosses['middle'].can_defeat(state)) + set_rule(world.get_location('Ganons Tower - Pre-Moldorm Chest', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 3)) + set_rule(world.get_entrance('Ganons Tower Moldorm Door', player), lambda state: state.has_key('Small Key (Ganons Tower)', player, 4)) + set_rule(world.get_entrance('Ganons Tower Moldorm Gap', player), lambda state: state.has('Hookshot', player) and world.get_entrance('Ganons Tower Moldorm Gap', player).parent_region.dungeon.bosses['top'].can_defeat(state)) + set_defeat_dungeon_boss_rule(world.get_location('Agahnim 2', player)) + set_rule(world.get_entrance('Inverted Pyramid Hole', player), lambda state: state.has('Beat Agahnim 2', player)) + for location in ['Ganons Tower - Big Chest', 'Ganons Tower - Mini Helmasaur Room - Left', 'Ganons Tower - Mini Helmasaur Room - Right', + 'Ganons Tower - Pre-Moldorm Chest', 'Ganons Tower - Validation Chest']: + forbid_item(world.get_location(location, player), 'Big Key (Ganons Tower)', player) + + set_rule(world.get_location('Ganon', player), lambda state: state.has_beam_sword(player) and state.has_fire_source(player) and state.has_crystals(world.crystals_needed_for_ganon, player) + and (state.has('Tempered Sword', player) or state.has('Golden Sword', player) or (state.has('Silver Arrows', player) and state.can_shoot_arrows(player)) or state.has('Lamp', player) or state.can_extend_magic(player, 12))) # need to light torch a sufficient amount of times + set_rule(world.get_entrance('Ganon Drop', player), lambda state: state.has_beam_sword(player)) # need to damage ganon to get tiles to drop + + set_rule(world.get_entrance('Inverted Ganons Tower', player), lambda state: False) # This is a safety for the TR function below to not require GT entrance in its key logic. + + if world.swords == 'swordless': + swordless_rules(world, player) + + set_trock_key_rules(world, player) + + set_rule(world.get_entrance('Inverted Ganons Tower', player), lambda state: state.has_crystals(world.crystals_needed_for_gt, player)) + +def no_glitches_rules(world, player): + if world.mode != 'inverted': + set_rule(world.get_entrance('Zoras River', player), lambda state: state.has('Flippers', player) or state.can_lift_rocks(player)) + set_rule(world.get_entrance('Lake Hylia Central Island Pier', player), lambda state: state.has('Flippers', player)) # can be fake flippered to + set_rule(world.get_entrance('Hobo Bridge', player), lambda state: state.has('Flippers', player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (East)', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) + set_rule(world.get_entrance('Dark Lake Hylia Teleporter', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player) and (state.has('Hammer', player) or state.can_lift_rocks(player))) + set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) + else: + set_rule(world.get_entrance('Zoras River', player), lambda state: state.has_Pearl(player) and (state.has('Flippers', player) or state.can_lift_rocks(player))) + set_rule(world.get_entrance('Lake Hylia Central Island Pier', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) # can be fake flippered to + set_rule(world.get_entrance('Hobo Bridge', player), lambda state: state.has_Pearl(player) and state.has('Flippers', player)) + set_rule(world.get_entrance('Dark Lake Hylia Drop (East)', player), lambda state: state.has('Flippers', player)) + set_rule(world.get_entrance('Dark Lake Hylia Teleporter', player), lambda state: state.has('Flippers', player) and (state.has('Hammer', player) or state.can_lift_rocks(player))) + set_rule(world.get_entrance('Dark Lake Hylia Ledge Drop', player), lambda state: state.has('Flippers', player)) + + add_rule(world.get_entrance('Ganons Tower (Hookshot Room)', player), lambda state: state.has('Hookshot', player) or state.has_Boots(player)) + add_rule(world.get_entrance('Ganons Tower (Double Switch Room)', player), lambda state: state.has('Hookshot', player)) DMs_room_chests = ['Ganons Tower - DMs Room - Top Left', 'Ganons Tower - DMs Room - Top Right', 'Ganons Tower - DMs Room - Bottom Left', 'Ganons Tower - DMs Room - Bottom Right'] for location in DMs_room_chests: - add_rule(world.get_location(location), lambda state: state.has('Hookshot')) - set_rule(world.get_entrance('Paradox Cave Push Block Reverse'), lambda state: False) # no glitches does not require block override - set_rule(world.get_entrance('Paradox Cave Bomb Jump'), lambda state: False) - set_rule(world.get_entrance('Skull Woods First Section Bomb Jump'), lambda state: False) + add_rule(world.get_location(location, player), lambda state: state.has('Hookshot', player)) + set_rule(world.get_entrance('Paradox Cave Push Block Reverse', player), lambda state: False) # no glitches does not require block override + set_rule(world.get_entrance('Paradox Cave Bomb Jump', player), lambda state: False) + set_rule(world.get_entrance('Skull Woods First Section Bomb Jump', player), lambda state: False) # Light cones in standard depend on which world we actually are in, not which one the location would normally be # We add Lamp requirements only to those locations which lie in the dark world (or everything if open @@ -447,11 +888,11 @@ def no_glitches_rules(world): def add_conditional_lamp(spot, region, spottype='Location'): if spottype == 'Location': - spot = world.get_location(spot) + spot = world.get_location(spot, player) else: - spot = world.get_entrance(spot) - if (not world.dark_world_light_cone and check_is_dark_world(world.get_region(region))) or (not world.light_world_light_cone and not check_is_dark_world(world.get_region(region))): - add_lamp_requirement(spot) + spot = world.get_entrance(spot, player) + if (not world.dark_world_light_cone and check_is_dark_world(world.get_region(region, player))) or (not world.light_world_light_cone and not check_is_dark_world(world.get_region(region, player))): + add_lamp_requirement(spot, player) add_conditional_lamp('Misery Mire (Vitreous)', 'Misery Mire (Entrance)', 'Entrance') add_conditional_lamp('Turtle Rock (Dark Room) (North)', 'Turtle Rock (Entrance)', 'Entrance') @@ -460,8 +901,12 @@ def no_glitches_rules(world): add_conditional_lamp('Palace of Darkness Maze Door', 'Palace of Darkness (Entrance)', 'Entrance') add_conditional_lamp('Palace of Darkness - Dark Basement - Left', 'Palace of Darkness (Entrance)', 'Location') add_conditional_lamp('Palace of Darkness - Dark Basement - Right', 'Palace of Darkness (Entrance)', 'Location') - add_conditional_lamp('Agahnim 1', 'Agahnims Tower', 'Entrance') - add_conditional_lamp('Castle Tower - Dark Maze', 'Agahnims Tower', 'Location') + if world.mode != 'inverted': + add_conditional_lamp('Agahnim 1', 'Agahnims Tower', 'Entrance') + add_conditional_lamp('Castle Tower - Dark Maze', 'Agahnims Tower', 'Location') + else: + add_conditional_lamp('Agahnim 1', 'Inverted Agahnims Tower', 'Entrance') + add_conditional_lamp('Castle Tower - Dark Maze', 'Inverted Agahnims Tower', 'Location') add_conditional_lamp('Old Man', 'Old Man Cave', 'Location') add_conditional_lamp('Old Man Cave Exit (East)', 'Old Man Cave', 'Entrance') add_conditional_lamp('Death Mountain Return Cave Exit (East)', 'Death Mountain Return Cave', 'Entrance') @@ -473,79 +918,93 @@ def no_glitches_rules(world): add_conditional_lamp('Eastern Palace - Prize', 'Eastern Palace', 'Location') if not world.sewer_light_cone: - add_lamp_requirement(world.get_location('Sewers - Dark Cross')) - add_lamp_requirement(world.get_entrance('Sewers Back Door')) - add_lamp_requirement(world.get_entrance('Throne Room')) + add_lamp_requirement(world.get_location('Sewers - Dark Cross', player), player) + add_lamp_requirement(world.get_entrance('Sewers Back Door', player), player) + add_lamp_requirement(world.get_entrance('Throne Room', player), player) -def open_rules(world): +def open_rules(world, player): # softlock protection as you can reach the sewers small key door with a guard drop key - forbid_item(world.get_location('Hyrule Castle - Boomerang Chest'), 'Small Key (Escape)') - forbid_item(world.get_location('Hyrule Castle - Zelda\'s Chest'), 'Small Key (Escape)') + forbid_item(world.get_location('Hyrule Castle - Boomerang Chest', player), 'Small Key (Escape)', player) + forbid_item(world.get_location('Hyrule Castle - Zelda\'s Chest', player), 'Small Key (Escape)', player) - set_rule(world.get_location('Hyrule Castle - Boomerang Chest'), lambda state: state.has_key('Small Key (Escape)')) - set_rule(world.get_location('Hyrule Castle - Zelda\'s Chest'), lambda state: state.has_key('Small Key (Escape)')) + set_rule(world.get_location('Hyrule Castle - Boomerang Chest', player), lambda state: state.has_key('Small Key (Escape)', player)) + set_rule(world.get_location('Hyrule Castle - Zelda\'s Chest', player), lambda state: state.has_key('Small Key (Escape)', player)) -def swordless_rules(world): +def swordless_rules(world, player): - # for the time being swordless mode just inherits all fixes from open mode. - # should there ever be fixes that apply to open mode but not swordless, this - # can be revisited. - open_rules(world) + set_rule(world.get_entrance('Agahnim 1', player), lambda state: (state.has('Hammer', player) or state.has('Fire Rod', player) or state.can_shoot_arrows(player) or state.has('Cane of Somaria', player)) and state.has_key('Small Key (Agahnims Tower)', player, 2)) + set_rule(world.get_location('Ether Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has('Hammer', player)) + set_rule(world.get_entrance('Skull Woods Torch Room', player), lambda state: state.has_key('Small Key (Skull Woods)', player, 3) and state.has('Fire Rod', player)) # no curtain + set_rule(world.get_entrance('Ice Palace Entrance Room', player), lambda state: state.has('Fire Rod', player) or state.has('Bombos', player)) #in swordless mode bombos pads are present in the relevant parts of ice palace + set_rule(world.get_location('Ganon', player), lambda state: state.has('Hammer', player) and state.has_fire_source(player) and state.has('Silver Arrows', player) and state.can_shoot_arrows(player) and state.has_crystals(world.crystals_needed_for_ganon, player)) + set_rule(world.get_entrance('Ganon Drop', player), lambda state: state.has('Hammer', player)) # need to damage ganon to get tiles to drop - set_rule(world.get_entrance('Agahnims Tower'), lambda state: state.has('Cape') or state.has('Hammer') or state.has('Beat Agahnim 1')) # barrier gets removed after killing agahnim, relevant for entrance shuffle - set_rule(world.get_entrance('Agahnim 1'), lambda state: (state.has('Hammer') or state.has('Fire Rod') or state.can_shoot_arrows() or state.has('Cane of Somaria')) and state.has_key('Small Key (Agahnims Tower)', 2)) - set_rule(world.get_location('Ether Tablet'), lambda state: state.has('Book of Mudora') and state.has('Hammer')) - set_rule(world.get_location('Bombos Tablet'), lambda state: state.has('Book of Mudora') and state.has('Hammer') and state.has_Mirror()) - set_rule(world.get_entrance('Misery Mire'), lambda state: state.has_Pearl() and state.has_misery_mire_medallion()) # sword not required to use medallion for opening in swordless (!) - set_rule(world.get_entrance('Turtle Rock'), lambda state: state.has_Pearl() and state.has_turtle_rock_medallion() and state.can_reach('Turtle Rock (Top)', 'Region')) # sword not required to use medallion for opening in swordless (!) - set_rule(world.get_entrance('Skull Woods Torch Room'), lambda state: state.has_key('Small Key (Skull Woods)', 3) and state.has('Fire Rod')) # no curtain - set_rule(world.get_entrance('Ice Palace Entrance Room'), lambda state: state.has('Fire Rod') or state.has('Bombos')) #in swordless mode bombos pads are present in the relevant parts of ice palace - set_rule(world.get_location('Ganon'), lambda state: state.has('Hammer') and state.has_fire_source() and state.has('Silver Arrows') and state.can_shoot_arrows() and state.has('Crystal 1') and state.has('Crystal 2') - and state.has('Crystal 3') and state.has('Crystal 4') and state.has('Crystal 5') and state.has('Crystal 6') and state.has('Crystal 7')) - set_rule(world.get_entrance('Ganon Drop'), lambda state: state.has('Hammer')) # need to damage ganon to get tiles to drop + if world.mode != 'inverted': + set_rule(world.get_entrance('Agahnims Tower', player), lambda state: state.has('Cape', player) or state.has('Hammer', player) or state.has('Beat Agahnim 1', player)) # barrier gets removed after killing agahnim, relevant for entrance shuffle + set_rule(world.get_entrance('Turtle Rock', player), lambda state: state.has_Pearl(player) and state.has_turtle_rock_medallion(player) and state.can_reach('Turtle Rock (Top)', 'Region', player)) # sword not required to use medallion for opening in swordless (!) + set_rule(world.get_entrance('Misery Mire', player), lambda state: state.has_Pearl(player) and state.has_misery_mire_medallion(player)) # sword not required to use medallion for opening in swordless (!) + set_rule(world.get_location('Bombos Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has('Hammer', player) and state.has_Mirror(player)) + else: + # only need ddm access for aga tower in inverted + set_rule(world.get_entrance('Turtle Rock', player), lambda state: state.has_turtle_rock_medallion(player) and state.can_reach('Turtle Rock (Top)', 'Region', player)) # sword not required to use medallion for opening in swordless (!) + set_rule(world.get_entrance('Misery Mire', player), lambda state: state.has_misery_mire_medallion(player)) # sword not required to use medallion for opening in swordless (!) + set_rule(world.get_location('Bombos Tablet', player), lambda state: state.has('Book of Mudora', player) and state.has('Hammer', player)) +def standard_rules(world, player): + add_rule(world.get_entrance('Sewers Door', player), lambda state: state.can_kill_most_things(player)) -def standard_rules(world): - for loc in ['Sanctuary','Sewers - Secret Room - Left', 'Sewers - Secret Room - Middle', - 'Sewers - Secret Room - Right']: - add_rule(world.get_location(loc), lambda state: state.can_kill_most_things() and state.has_key('Small Key (Escape)')) + set_rule(world.get_entrance('Hyrule Castle Exit (East)', player), lambda state: state.can_reach('Sanctuary', 'Region', player)) + set_rule(world.get_entrance('Hyrule Castle Exit (West)', player), lambda state: state.can_reach('Sanctuary', 'Region', player)) + + # ensures the required weapon for escape lands on uncle (unless player has it pre-equipped) + add_rule(world.get_location('Secret Passage', player), lambda state: state.can_kill_most_things(player)) + add_rule(world.get_location('Hyrule Castle - Map Chest', player), lambda state: state.can_kill_most_things(player)) + + def uncle_item_rule(item): + copy_state = CollectionState(world) + copy_state.collect(item) + copy_state.sweep_for_events() + return copy_state.can_reach('Sanctuary', 'Region', player) + + add_item_rule(world.get_location('Link\'s Uncle', player), uncle_item_rule) # easiest way to enforce key placement not relevant for open - set_rule(world.get_location('Sewers - Dark Cross'), lambda state: state.can_kill_most_things()) + set_rule(world.get_location('Sewers - Dark Cross', player), lambda state: state.can_kill_most_things(player)) - set_rule(world.get_location('Hyrule Castle - Boomerang Chest'), lambda state: state.can_kill_most_things()) - set_rule(world.get_location('Hyrule Castle - Zelda\'s Chest'), lambda state: state.can_kill_most_things()) + set_rule(world.get_location('Hyrule Castle - Boomerang Chest', player), lambda state: state.can_kill_most_things(player)) + set_rule(world.get_location('Hyrule Castle - Zelda\'s Chest', player), lambda state: state.can_kill_most_things(player)) -def set_trock_key_rules(world): +def set_trock_key_rules(world, player): - all_state = world.get_all_state(True) # First set all relevant locked doors to impassible. for entrance in ['Turtle Rock Dark Room Staircase', 'Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)', 'Turtle Rock Pokey Room']: - set_rule(world.get_entrance(entrance), lambda state: False) + set_rule(world.get_entrance(entrance, player), lambda state: False) + all_state = world.get_all_state(True) + # Check if each of the four main regions of the dungoen can be reached. The previous code section prevents key-costing moves within the dungeon. - can_reach_back = all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)')) if world.can_access_trock_eyebridge is None else world.can_access_trock_eyebridge + can_reach_back = all_state.can_reach(world.get_region('Turtle Rock (Eye Bridge)', player)) if world.can_access_trock_eyebridge is None else world.can_access_trock_eyebridge world.can_access_trock_eyebridge = can_reach_back - can_reach_front = all_state.can_reach(world.get_region('Turtle Rock (Entrance)')) if world.can_access_trock_front is None else world.can_access_trock_front + can_reach_front = all_state.can_reach(world.get_region('Turtle Rock (Entrance)', player)) if world.can_access_trock_front is None else world.can_access_trock_front world.can_access_trock_front = can_reach_front - can_reach_big_chest = all_state.can_reach(world.get_region('Turtle Rock (Big Chest)')) if world.can_access_trock_big_chest is None else world.can_access_trock_big_chest + can_reach_big_chest = all_state.can_reach(world.get_region('Turtle Rock (Big Chest)', player)) if world.can_access_trock_big_chest is None else world.can_access_trock_big_chest world.can_access_trock_big_chest = can_reach_big_chest - can_reach_middle = all_state.can_reach(world.get_region('Turtle Rock (Second Section)')) if world.can_access_trock_middle is None else world.can_access_trock_middle + can_reach_middle = all_state.can_reach(world.get_region('Turtle Rock (Second Section)', player)) if world.can_access_trock_middle is None else world.can_access_trock_middle world.can_access_trock_middle = can_reach_middle # No matter what, the key requirement for going from the middle to the bottom should be three keys. - set_rule(world.get_entrance('Turtle Rock Dark Room Staircase'), lambda state: state.has_key('Small Key (Turtle Rock)', 3)) + set_rule(world.get_entrance('Turtle Rock Dark Room Staircase', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 3)) # The following represent the most common and most restrictive key rules. These are overwritten later as needed. - set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)'), lambda state: state.has_key('Small Key (Turtle Rock)', 4)) - set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'), lambda state: state.has_key('Small Key (Turtle Rock)', 4)) - set_rule(world.get_entrance('Turtle Rock Pokey Room'), lambda state: state.has_key('Small Key (Turtle Rock)', 4)) + set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 4)) + set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 4)) + set_rule(world.get_entrance('Turtle Rock Pokey Room', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 4)) # No matter what, the Big Key cannot be in the Big Chest or held by Trinexx. non_big_key_locations = ['Turtle Rock - Big Chest', 'Turtle Rock - Boss'] @@ -553,45 +1012,58 @@ def set_trock_key_rules(world): def tr_big_key_chest_keys_needed(state): # This function handles the key requirements for the TR Big Chest in the situations it having the Big Key should logically require 2 keys, small key # should logically require no keys, and anything else should logically require 4 keys. - item = item_name(state, 'Turtle Rock - Big Key Chest') - if item in ['Small Key (Turtle Rock)']: + item = item_name(state, 'Turtle Rock - Big Key Chest', player) + if item in [('Small Key (Turtle Rock)', player)]: return 0 - if item in ['Big Key (Turtle Rock)']: + if item in [('Big Key (Turtle Rock)', player)]: return 2 return 4 # Now we need to set rules based on which entrances we have access to. The most important point is whether we have back access. If we have back access, we # might open all the locked doors in any order so we need maximally restrictive rules. if can_reach_back: - set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: (state.has_key('Small Key (Turtle Rock)', 4) or item_name(state, 'Turtle Rock - Big Key Chest') == 'Small Key (Turtle Rock)')) - set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)') + set_rule(world.get_location('Turtle Rock - Big Key Chest', player), lambda state: (state.has_key('Small Key (Turtle Rock)', player, 4) or item_name(state, 'Turtle Rock - Big Key Chest', player) == ('Small Key (Turtle Rock)', player))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Turtle Rock - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Turtle Rock)' and item.player == player) + else: + forbid_item(world.get_location('Turtle Rock - Big Key Chest', player), 'Small Key (Turtle Rock)', player) elif can_reach_front and can_reach_middle: - set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has_key('Small Key (Turtle Rock)', tr_big_key_chest_keys_needed(state))) - set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)') + set_rule(world.get_location('Turtle Rock - Big Key Chest', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, tr_big_key_chest_keys_needed(state))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Turtle Rock - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Turtle Rock)' and item.player == player) + else: + forbid_item(world.get_location('Turtle Rock - Big Key Chest', player), 'Small Key (Turtle Rock)', player) non_big_key_locations += ['Turtle Rock - Crystaroller Room', 'Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'] elif can_reach_front: - set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)'), lambda state: state.has_key('Small Key (Turtle Rock)', 2)) - set_rule(world.get_entrance('Turtle Rock Pokey Room'), lambda state: state.has_key('Small Key (Turtle Rock)', 1)) - set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: state.has_key('Small Key (Turtle Rock)', tr_big_key_chest_keys_needed(state))) - set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)' and state.has_key('Small Key (Turtle Rock)', 2)) + set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (North)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 2)) + set_rule(world.get_entrance('Turtle Rock Pokey Room', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 1)) + set_rule(world.get_location('Turtle Rock - Big Key Chest', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, tr_big_key_chest_keys_needed(state))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Turtle Rock - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Turtle Rock)' and item.player == player and state.has_key('Small Key (Turtle Rock)', player, 2)) + else: + forbid_item(world.get_location('Turtle Rock - Big Key Chest', player), 'Small Key (Turtle Rock)', player) non_big_key_locations += ['Turtle Rock - Crystaroller Room', 'Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'] elif can_reach_big_chest: - set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)'), lambda state: state.has_key('Small Key (Turtle Rock)', 2) if item_in_locations(state, 'Big Key (Turtle Rock)', ['Turtle Rock - Compass Chest', 'Turtle Rock - Roller Room - Left', 'Turtle Rock - Roller Room - Right']) else state.has_key('Small Key (Turtle Rock)', 4)) - set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: (state.has_key('Small Key (Turtle Rock)', 4) or item_name(state, 'Turtle Rock - Big Key Chest') == 'Small Key (Turtle Rock)')) - set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)') + set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 2) if item_in_locations(state, 'Big Key (Turtle Rock)', player, [('Turtle Rock - Compass Chest', player), ('Turtle Rock - Roller Room - Left', player), ('Turtle Rock - Roller Room - Right', player)]) else state.has_key('Small Key (Turtle Rock)', player, 4)) + set_rule(world.get_location('Turtle Rock - Big Key Chest', player), lambda state: (state.has_key('Small Key (Turtle Rock)', player, 4) or item_name(state, 'Turtle Rock - Big Key Chest', player) == ('Small Key (Turtle Rock)', player))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Turtle Rock - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Turtle Rock)' and item.player == player) + else: + forbid_item(world.get_location('Turtle Rock - Big Key Chest', player), 'Small Key (Turtle Rock)', player) non_big_key_locations += ['Turtle Rock - Crystaroller Room', 'Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'] if not world.keysanity: non_big_key_locations += ['Turtle Rock - Big Key Chest'] else: - set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)'), lambda state: state.has_key('Small Key (Turtle Rock)', 2) if item_in_locations(state, 'Big Key (Turtle Rock)', ['Turtle Rock - Compass Chest', 'Turtle Rock - Roller Room - Left', 'Turtle Rock - Roller Room - Right']) else state.has_key('Small Key (Turtle Rock)', 4)) - set_rule(world.get_location('Turtle Rock - Big Key Chest'), lambda state: (state.has_key('Small Key (Turtle Rock)', 4) or item_name(state, 'Turtle Rock - Big Key Chest') == 'Small Key (Turtle Rock)')) - set_always_allow(world.get_location('Turtle Rock - Big Key Chest'), lambda state, item: item.name == 'Small Key (Turtle Rock)') + set_rule(world.get_entrance('Turtle Rock (Chain Chomp Room) (South)', player), lambda state: state.has_key('Small Key (Turtle Rock)', player, 2) if item_in_locations(state, 'Big Key (Turtle Rock)', player, [('Turtle Rock - Compass Chest', player), ('Turtle Rock - Roller Room - Left', player), ('Turtle Rock - Roller Room - Right', player)]) else state.has_key('Small Key (Turtle Rock)', player, 4)) + set_rule(world.get_location('Turtle Rock - Big Key Chest', player), lambda state: (state.has_key('Small Key (Turtle Rock)', player, 4) or item_name(state, 'Turtle Rock - Big Key Chest', player) == ('Small Key (Turtle Rock)', player))) + if world.accessibility != 'locations': + set_always_allow(world.get_location('Turtle Rock - Big Key Chest', player), lambda state, item: item.name == 'Small Key (Turtle Rock)' and item.player == player) non_big_key_locations += ['Turtle Rock - Crystaroller Room', 'Turtle Rock - Eye Bridge - Bottom Left', 'Turtle Rock - Eye Bridge - Bottom Right', 'Turtle Rock - Eye Bridge - Top Left', 'Turtle Rock - Eye Bridge - Top Right'] @@ -600,16 +1072,16 @@ def set_trock_key_rules(world): # set big key restrictions for location in non_big_key_locations: - forbid_item(world.get_location(location), 'Big Key (Turtle Rock)') + forbid_item(world.get_location(location, player), 'Big Key (Turtle Rock)', player) # small key restriction for location in ['Turtle Rock - Boss']: - forbid_item(world.get_location(location), 'Small Key (Turtle Rock)') + forbid_item(world.get_location(location, player), 'Small Key (Turtle Rock)', player) -def set_big_bomb_rules(world): +def set_big_bomb_rules(world, player): # this is a mess - bombshop_entrance = world.get_region('Big Bomb Shop').entrances[0] + bombshop_entrance = world.get_region('Big Bomb Shop', player).entrances[0] Normal_LW_entrances = ['Blinds Hideout', 'Bonk Fairy (Light)', 'Lake Hylia Fairy', @@ -723,23 +1195,23 @@ def set_big_bomb_rules(world): Desert_mirrorable_ledge_entrances = ['Desert Palace Entrance (West)', 'Desert Palace Entrance (North)', 'Desert Palace Entrance (South)', - 'Checkerboard Cave',] + 'Checkerboard Cave'] - set_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.can_reach('East Dark World', 'Region') and state.can_reach('Big Bomb Shop', 'Region') and state.has('Crystal 5') and state.has('Crystal 6')) + set_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_reach('East Dark World', 'Region', player) and state.can_reach('Big Bomb Shop', 'Region', player) and state.has('Crystal 5', player) and state.has('Crystal 6', player)) #crossing peg bridge starting from the southern dark world def cross_peg_bridge(state): - return state.has('Hammer') and state.has_Pearl() + return state.has('Hammer', player) and state.has_Pearl(player) # returning via the eastern and southern teleporters needs the same items, so we use the southern teleporter for out routing. # crossing preg bridge already requires hammer so we just add the gloves to the requirement def southern_teleporter(state): - return state.can_lift_rocks() and cross_peg_bridge(state) + return state.can_lift_rocks(player) and cross_peg_bridge(state) # the basic routes assume you can reach eastern light world with the bomb. # you can then use the southern teleporter, or (if you have beaten Aga1) the hyrule castle gate warp def basic_routes(state): - return southern_teleporter(state) or state.can_reach('Top of Pyramid', 'Entrance') + return southern_teleporter(state) or state.can_reach('Top of Pyramid', 'Entrance', player) # Key for below abbreviations: # P = pearl @@ -752,90 +1224,260 @@ def set_big_bomb_rules(world): #1. basic routes #2. Can reach Eastern dark world some other way, mirror, get bomb, return to mirror spot, walk to pyramid: Needs mirror # -> M or BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: basic_routes(state) or state.has_Mirror()) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: basic_routes(state) or state.has_Mirror(player)) elif bombshop_entrance.name in LW_walkable_entrances: #1. Mirror then basic routes # -> M and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has_Mirror() and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) and basic_routes(state)) elif bombshop_entrance.name in Northern_DW_entrances: #1. Mirror and basic routes #2. Go to south DW and then cross peg bridge: Need Mitts and hammer and moon pearl # -> (Mitts and CPB) or (M and BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.can_lift_heavy_rocks() and cross_peg_bridge(state)) or (state.has_Mirror() and basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.can_lift_heavy_rocks(player) and cross_peg_bridge(state)) or (state.has_Mirror(player) and basic_routes(state))) elif bombshop_entrance.name == 'Bumper Cave (Bottom)': #1. Mirror and Lift rock and basic_routes #2. Mirror and Flute and basic routes (can make difference if accessed via insanity or w/ mirror from connector, and then via hyrule castle gate, because no gloves are needed in that case) #3. Go to south DW and then cross peg bridge: Need Mitts and hammer and moon pearl # -> (Mitts and CPB) or (((G or Flute) and M) and BR)) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.can_lift_heavy_rocks() and cross_peg_bridge(state)) or (((state.can_lift_rocks() or state.has('Ocarina')) and state.has_Mirror()) and basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.can_lift_heavy_rocks(player) and cross_peg_bridge(state)) or (((state.can_lift_rocks(player) or state.has('Ocarina', player)) and state.has_Mirror(player)) and basic_routes(state))) elif bombshop_entrance.name in Southern_DW_entrances: #1. Mirror and enter via gate: Need mirror and Aga1 #2. cross peg bridge: Need hammer and moon pearl # -> CPB or (M and A) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: cross_peg_bridge(state) or (state.has_Mirror() and state.can_reach('Top of Pyramid', 'Entrance'))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: cross_peg_bridge(state) or (state.has_Mirror(player) and state.can_reach('Top of Pyramid', 'Entrance', player))) elif bombshop_entrance.name in Isolated_DW_entrances: # 1. mirror then flute then basic routes # -> M and Flute and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has_Mirror() and state.has('Ocarina') and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) and state.has('Ocarina', player) and basic_routes(state)) elif bombshop_entrance.name in Isolated_LW_entrances: # 1. flute then basic routes # Prexisting mirror spot is not permitted, because mirror might have been needed to reach these isolated locations. # -> Flute and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has('Ocarina') and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has('Ocarina', player) and basic_routes(state)) elif bombshop_entrance.name in West_LW_DM_entrances: # 1. flute then basic routes or mirror # Prexisting mirror spot is permitted, because flute can be used to reach west DM directly. # -> Flute and (M or BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has('Ocarina') and (state.has_Mirror() or basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has('Ocarina', player) and (state.has_Mirror(player) or basic_routes(state))) elif bombshop_entrance.name in East_LW_DM_entrances: # 1. flute then basic routes or mirror and hookshot # Prexisting mirror spot is permitted, because flute can be used to reach west DM directly and then east DM via Hookshot # -> Flute and ((M and Hookshot) or BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has('Ocarina') and ((state.has_Mirror() and state.has('Hookshot')) or basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has('Ocarina', player) and ((state.has_Mirror(player) and state.has('Hookshot', player)) or basic_routes(state))) elif bombshop_entrance.name == 'Fairy Ascension Cave (Bottom)': # Same as East_LW_DM_entrances except navigation without BR requires Mitts # -> Flute and ((M and Hookshot and Mitts) or BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has('Ocarina') and ((state.has_Mirror() and state.has('Hookshot') and state.can_lift_heavy_rocks()) or basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has('Ocarina', player) and ((state.has_Mirror(player) and state.has('Hookshot', player) and state.can_lift_heavy_rocks(player)) or basic_routes(state))) elif bombshop_entrance.name in Castle_ledge_entrances: # 1. mirror on pyramid to castle ledge, grab bomb, return through mirror spot: Needs mirror # 2. flute then basic routes # -> M or (Flute and BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: state.has_Mirror() or (state.has('Ocarina') and basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) or (state.has('Ocarina', player) and basic_routes(state))) elif bombshop_entrance.name in Desert_mirrorable_ledge_entrances: # Cases when you have mire access: Mirror to reach locations, return via mirror spot, move to center of desert, mirror anagin and: # 1. Have mire access, Mirror to reach locations, return via mirror spot, move to center of desert, mirror again and then basic routes # 2. flute then basic routes # -> (Mire access and M) or Flute) and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: ((state.can_reach('Dark Desert', 'Region') and state.has_Mirror()) or state.has('Ocarina')) and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: ((state.can_reach('Dark Desert', 'Region', player) and state.has_Mirror(player)) or state.has('Ocarina', player)) and basic_routes(state)) elif bombshop_entrance.name == 'Old Man Cave (West)': # 1. Lift rock then basic_routes # 2. flute then basic_routes # -> (Flute or G) and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.has('Ocarina') or state.can_lift_rocks()) and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.has('Ocarina', player) or state.can_lift_rocks(player)) and basic_routes(state)) elif bombshop_entrance.name == 'Graveyard Cave': # 1. flute then basic routes # 2. (has west dark world access) use existing mirror spot (required Pearl), mirror again off ledge # -> (Flute or (M and P and West Dark World access) and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.has('Ocarina') or (state.can_reach('West Dark World', 'Region') and state.has_Pearl() and state.has_Mirror())) and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.has('Ocarina', player) or (state.can_reach('West Dark World', 'Region', player) and state.has_Pearl(player) and state.has_Mirror(player))) and basic_routes(state)) elif bombshop_entrance.name in Mirror_from_SDW_entrances: # 1. flute then basic routes # 2. (has South dark world access) use existing mirror spot, mirror again off ledge # -> (Flute or (M and South Dark World access) and BR - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.has('Ocarina') or (state.can_reach('South Dark World', 'Region') and state.has_Mirror())) and basic_routes(state)) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.has('Ocarina', player) or (state.can_reach('South Dark World', 'Region', player) and state.has_Mirror(player))) and basic_routes(state)) elif bombshop_entrance.name == 'Dark World Potion Shop': # 1. walk down by lifting rock: needs gloves and pearl` # 2. walk down by hammering peg: needs hammer and pearl # 3. mirror and basic routes # -> (P and (H or Gloves)) or (M and BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.has_Pearl() and (state.has('Hammer') or state.can_lift_rocks())) or (state.has_Mirror() and basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.has_Pearl(player) and (state.has('Hammer', player) or state.can_lift_rocks(player))) or (state.has_Mirror(player) and basic_routes(state))) elif bombshop_entrance.name == 'Kings Grave': # same as the Normal_LW_entrances case except that the pre-existing mirror is only possible if you have mitts # (because otherwise mirror was used to reach the grave, so would cancel a pre-existing mirror spot) # to account for insanity, must consider a way to escape without a cave for basic_routes # -> (M and Mitts) or ((Mitts or Flute or (M and P and West Dark World access)) and BR) - add_rule(world.get_entrance('Pyramid Fairy'), lambda state: (state.can_lift_heavy_rocks() and state.has_Mirror()) or ((state.can_lift_heavy_rocks() or state.has('Ocarina') or (state.can_reach('West Dark World', 'Region') and state.has_Pearl() and state.has_Mirror())) and basic_routes(state))) + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: (state.can_lift_heavy_rocks(player) and state.has_Mirror(player)) or ((state.can_lift_heavy_rocks(player) or state.has('Ocarina', player) or (state.can_reach('West Dark World', 'Region', player) and state.has_Pearl(player) and state.has_Mirror(player))) and basic_routes(state))) -def set_bunny_rules(world): +def set_inverted_big_bomb_rules(world, player): + bombshop_entrance = world.get_region('Inverted Big Bomb Shop', player).entrances[0] + Normal_LW_entrances = ['Blinds Hideout', + 'Bonk Fairy (Light)', + 'Lake Hylia Fairy', + 'Light Hype Fairy', + 'Desert Fairy', + 'Chicken House', + 'Aginahs Cave', + 'Sahasrahlas Hut', + 'Cave Shop (Lake Hylia)', + 'Blacksmiths Hut', + 'Sick Kids House', + 'Lost Woods Gamble', + 'Fortune Teller (Light)', + 'Snitch Lady (East)', + 'Snitch Lady (West)', + 'Bush Covered House', + 'Tavern (Front)', + 'Light World Bomb Hut', + 'Kakariko Shop', + 'Mini Moldorm Cave', + 'Long Fairy Cave', + 'Good Bee Cave', + '20 Rupee Cave', + '50 Rupee Cave', + 'Ice Rod Cave', + 'Bonk Rock Cave', + 'Library', + 'Potion Shop', + 'Waterfall of Wishing', + 'Dam', + 'Lumberjack House', + 'Lake Hylia Fortune Teller', + 'Eastern Palace', + 'Kakariko Gamble Game', + 'Kakariko Well Cave', + 'Bat Cave Cave', + 'Elder House (East)', + 'Elder House (West)', + 'North Fairy Cave', + 'Lost Woods Hideout Stump', + 'Lumberjack Tree Cave', + 'Two Brothers House (East)', + 'Sanctuary', + 'Hyrule Castle Entrance (South)', + 'Hyrule Castle Secret Entrance Stairs'] + LW_walkable_entrances = ['Dark Lake Hylia Ledge Fairy', + 'Dark Lake Hylia Ledge Spike Cave', + 'Dark Lake Hylia Ledge Hint', + 'Mire Shed', + 'Dark Desert Hint', + 'Dark Desert Fairy', + 'Misery Mire'] + Northern_DW_entrances = ['Brewery', + 'C-Shaped House', + 'Chest Game', + 'Dark World Hammer Peg Cave', + 'Red Shield Shop', + 'Dark Sanctuary Hint', + 'Fortune Teller (Dark)', + 'Dark World Shop', + 'Dark World Lumberjack Shop', + 'Thieves Town', + 'Skull Woods First Section Door', + 'Skull Woods Second Section Door (East)'] + Southern_DW_entrances = ['Hype Cave', + 'Bonk Fairy (Dark)', + 'Archery Game', + 'Inverted Big Bomb Shop', + 'Dark Lake Hylia Shop', + 'Swamp Palace'] + Isolated_DW_entrances = ['Spike Cave', + 'Cave Shop (Dark Death Mountain)', + 'Dark Death Mountain Fairy', + 'Mimic Cave', + 'Skull Woods Second Section Door (West)', + 'Skull Woods Final Section', + 'Ice Palace', + 'Turtle Rock', + 'Dark Death Mountain Ledge (West)', + 'Dark Death Mountain Ledge (East)', + 'Bumper Cave (Top)', + 'Superbunny Cave (Top)', + 'Superbunny Cave (Bottom)', + 'Hookshot Cave', + 'Turtle Rock Isolated Ledge Entrance', + 'Hookshot Cave Back Entrance', + 'Inverted Ganons Tower'] + Isolated_LW_entrances = ['Capacity Upgrade', + 'Tower of Hera', + 'Death Mountain Return Cave (West)', + 'Paradox Cave (Top)', + 'Fairy Ascension Cave (Top)', + 'Spiral Cave', + 'Desert Palace Entrance (East)'] + West_LW_DM_entrances = ['Old Man Cave (East)', + 'Old Man House (Bottom)', + 'Old Man House (Top)', + 'Death Mountain Return Cave (East)', + 'Spectacle Rock Cave Peak', + 'Spectacle Rock Cave', + 'Spectacle Rock Cave (Bottom)'] + East_LW_DM_entrances = ['Paradox Cave (Bottom)', + 'Paradox Cave (Middle)', + 'Hookshot Fairy', + 'Spiral Cave (Bottom)'] + Mirror_from_SDW_entrances = ['Two Brothers House (West)', + 'Cave 45'] + Castle_ledge_entrances = ['Hyrule Castle Entrance (West)', + 'Hyrule Castle Entrance (East)', + 'Inverted Ganons Tower'] + Desert_mirrorable_ledge_entrances = ['Desert Palace Entrance (West)', + 'Desert Palace Entrance (North)', + 'Desert Palace Entrance (South)', + 'Checkerboard Cave',] + Desert_ledge_entrances = ['Desert Palace Entrance (West)', + 'Desert Palace Entrance (North)', + 'Desert Palace Entrance (South)'] + + set_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_reach('East Dark World', 'Region', player) and state.can_reach('Inverted Big Bomb Shop', 'Region', player) and state.has('Crystal 5', player) and state.has('Crystal 6', player)) + + #crossing peg bridge starting from the southern dark world + def cross_peg_bridge(state): + return state.has('Hammer', player) + + # Key for below abbreviations: + # P = pearl + # A = Aga1 + # H = hammer + # M = Mirror + # G = Glove + if bombshop_entrance.name in Normal_LW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player)) + elif bombshop_entrance.name in LW_walkable_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player)) + elif bombshop_entrance.name in Northern_DW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute or (state.can_lift_heavy_rocks(player) and (cross_peg_bridge(state) or (state.has_Mirror(player) and state.has('Beat Agahnim 1', player))))) + elif bombshop_entrance.name == 'Bumper Cave (Bottom)': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute or (state.can_lift_heavy_rocks(player) and (cross_peg_bridge(state) or state.has_Mirror(player) and state.has('Beat Agahnim 1', player)))) + elif bombshop_entrance.name in Southern_DW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: cross_peg_bridge(state) or state.can_flute(player) or (state.has_Mirror(player) and state.has('Beat Agahnim 1', player))) + elif bombshop_entrance.name in Isolated_DW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player)) + elif bombshop_entrance.name in Isolated_LW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player) and state.has_Mirror(player)) + elif bombshop_entrance.name in West_LW_DM_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player) and state.has_Mirror(player)) + elif bombshop_entrance.name in East_LW_DM_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player) and state.has_Mirror(player)) + elif bombshop_entrance.name == 'Fairy Ascension Cave (Bottom)': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player) and state.has_Mirror(player)) + elif bombshop_entrance.name in Castle_ledge_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player)) + elif bombshop_entrance.name in Desert_ledge_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) and state.can_flute(player)) + elif bombshop_entrance.name == 'Checkerboard Cave': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player)) + elif bombshop_entrance.name == 'Old Man Cave (West)': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) and ((state.can_lift_rocks(player) and cross_peg_bridge(state)) or state.can_flute(player))) + elif bombshop_entrance.name == 'Graveyard Cave': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player)) + elif bombshop_entrance.name in Mirror_from_SDW_entrances: + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.has_Mirror(player) and (state.can_flute(player) or cross_peg_bridge(state))) + elif bombshop_entrance.name == 'Dark World Potion Shop': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_flute(player) or state.has('Hammer', player) or state.can_lift_rocks(player)) + elif bombshop_entrance.name == 'Kings Grave': + add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.can_lift_heavy_rocks(player) and state.has_Mirror(player)) + + +def set_bunny_rules(world, player): # regions for the exits of multi-entrace caves/drops that bunny cannot pass # Note spiral cave may be technically passible, but it would be too absurd to require since OHKO mode is a thing. @@ -853,12 +1495,12 @@ def set_bunny_rules(world): def get_rule_to_add(region): if not region.is_light_world: - return lambda state: state.has_Pearl() + return lambda state: state.has_Pearl(player) # in this case we are mixed region. # we collect possible options. # The base option is having the moon pearl - possible_options = [lambda state: state.has_Pearl()] + possible_options = [lambda state: state.has_Pearl(player)] # We will search entrances recursively until we find # one that leads to an exclusively light world region @@ -885,7 +1527,7 @@ def set_bunny_rules(world): return options_to_access_rule(possible_options) # Add requirements for bunny-impassible caves if they occur in the dark world - for region in [world.get_region(name) for name in bunny_impassable_caves]: + for region in [world.get_region(name, player) for name in bunny_impassable_caves]: if not region.is_dark_world: continue @@ -893,15 +1535,88 @@ def set_bunny_rules(world): for exit in region.exits: add_rule(exit, rule) - paradox_shop = world.get_region('Light World Death Mountain Shop') + paradox_shop = world.get_region('Light World Death Mountain Shop', player) if paradox_shop.is_dark_world: add_rule(paradox_shop.entrances[0], get_rule_to_add(paradox_shop)) # Add requirements for all locations that are actually in the dark world, except those available to the bunny for location in world.get_locations(): - if location.parent_region.is_dark_world: + if location.player == player and location.parent_region.is_dark_world: if location.name in bunny_accessible_locations: continue add_rule(location, get_rule_to_add(location.parent_region)) + +def set_inverted_bunny_rules(world, player): + + # regions for the exits of multi-entrace caves/drops that bunny cannot pass + # Note spiral cave may be technically passible, but it would be too absurd to require since OHKO mode is a thing. + bunny_impassable_caves = ['Bumper Cave', 'Two Brothers House', 'Hookshot Cave', 'Skull Woods First Section (Right)', 'Skull Woods First Section (Left)', 'Skull Woods First Section (Top)', 'Turtle Rock (Entrance)', 'Turtle Rock (Second Section)', 'Turtle Rock (Big Chest)', 'Skull Woods Second Section (Drop)', + 'Turtle Rock (Eye Bridge)', 'Sewers', 'Pyramid', 'Spiral Cave (Top)', 'Desert Palace Main (Inner)', 'Fairy Ascension Cave (Drop)', 'The Sky'] + + bunny_accessible_locations = ['Link\'s Uncle', 'Sahasrahla', 'Sick Kid', 'Lost Woods Hideout', 'Lumberjack Tree', 'Checkerboard Cave', 'Potion Shop', 'Spectacle Rock Cave', 'Pyramid', 'Hype Cave - Generous Guy', 'Peg Cave', 'Bumper Cave Ledge', 'Dark Blacksmith Ruins', 'Bombos Tablet', 'Ether Tablet', 'Purple Chest'] + + + def path_to_access_rule(path, entrance): + return lambda state: state.can_reach(entrance) and all(rule(state) for rule in path) + + def options_to_access_rule(options): + return lambda state: any(rule(state) for rule in options) + + def get_rule_to_add(region): + if not region.is_dark_world: + return lambda state: state.has_Pearl(player) + # in this case we are mixed region. + # we collect possible options. + + # The base option is having the moon pearl + possible_options = [lambda state: state.has_Pearl(player)] + + # We will search entrances recursively until we find + # one that leads to an exclusively dark world region + # for each such entrance a new option is added that consist of: + # a) being able to reach it, and + # b) being able to access all entrances from there to `region` + seen = set([region]) + queue = collections.deque([(region, [])]) + while queue: + (current, path) = queue.popleft() + for entrance in current.entrances: + new_region = entrance.parent_region + if new_region in seen: + continue + new_path = path + [entrance.access_rule] + seen.add(new_region) + if not new_region.is_dark_world: + continue # we don't care about pure light world entrances + if new_region.is_light_world: + queue.append((new_region, new_path)) + else: + # we have reached pure dark world, so we have a new possible option + possible_options.append(path_to_access_rule(new_path, entrance)) + return options_to_access_rule(possible_options) + + # Add requirements for bunny-impassible caves if they occur in the light world + for region in [world.get_region(name, player) for name in bunny_impassable_caves]: + + if not region.is_light_world: + continue + rule = get_rule_to_add(region) + for exit in region.exits: + add_rule(exit, rule) + + paradox_shop = world.get_region('Light World Death Mountain Shop', player) + if paradox_shop.is_light_world: + add_rule(paradox_shop.entrances[0], get_rule_to_add(paradox_shop)) + + # Add requirements for all locations that are actually in the light world, except those available to the bunny + for location in world.get_locations(): + if location.player == player and location.parent_region.is_light_world: + + if location.name in bunny_accessible_locations: + continue + + add_rule(location, get_rule_to_add(location.parent_region)) + + diff --git a/Text.py b/Text.py index 22b2e04477..ac25428738 100644 --- a/Text.py +++ b/Text.py @@ -25,7 +25,8 @@ Uncle_texts = [ 'Forward this message to 10 other people or this seed will be awful.', 'I hope you like your seeds bootless and fluteless.', '10\n9\n8\n7\n6\n5\n4\n3\n2\n1\nGo!', - 'I\'m off to visit cousin Fritzl.' + 'I\'m off to visit cousin Fritzl.', + 'Don\'t forget to check Antlion Cave.' ] * 2 + [ "We're out of\nWeetabix. To\nthe store!", "This seed is\nbootless\nuntil boots.", @@ -534,7 +535,7 @@ class MultiByteCoreTextMapper(object): "{INTRO}": [0x6E, 0x00, 0x77, 0x07, 0x7A, 0x03, 0x6B, 0x02, 0x67], "{NOTEXT}": [0x6E, 0x00, 0x6B, 0x04], "{IBOX}": [0x6B, 0x02, 0x77, 0x07, 0x7A, 0x03], - "{C:GREEN}": [0x77, 0x07], + "{C:GREEN}": [0x77, 0x07], "{C:YELLOW}": [0x77, 0x02], } @@ -551,10 +552,10 @@ class MultiByteCoreTextMapper(object): linespace = wrap line = lines.pop(0) if line.startswith('{'): - if line == '{PAGEBREAK}': - if lineindex % 3 != 0: - # insert a wait for keypress, unless we just did so - outbuf.append(0x7E) + if line == '{PAGEBREAK}': + if lineindex % 3 != 0: + # insert a wait for keypress, unless we just did so + outbuf.append(0x7E) lineindex = 0 outbuf.extend(cls.special_commands[line]) continue @@ -1431,6 +1432,7 @@ class TextTable(object): 'desert_thief_question_yes', 'desert_thief_after_item_get', 'desert_thief_reassure', + 'pond_item_bottle_filled' ] for msg in messages_to_zero: @@ -1882,5 +1884,12 @@ class TextTable(object): # 190 text['sign_east_death_mountain_bridge'] = CompressedTextMapper.convert("How did you get up here?") text['fish_money'] = CompressedTextMapper.convert("It's a secret to everyone.") + text['sign_ganons_tower'] = CompressedTextMapper.convert("You need all 7 crystals to enter.") + text['sign_ganon'] = CompressedTextMapper.convert("You need all 7 crystals to beat Ganon.") + text['ganon_phase_3_no_bow'] = CompressedTextMapper.convert("You have no bow. Dingus!") + text['ganon_phase_3_no_silvers_alt'] = CompressedTextMapper.convert("You can't best me without silver arrows!") + text['ganon_phase_3_no_silvers'] = CompressedTextMapper.convert("You can't best me without silver arrows!") + text['ganon_phase_3_silvers'] = CompressedTextMapper.convert("Oh no! Silver! My one true weakness!") + text['murahdahla'] = CompressedTextMapper.convert("Hello @. I\nam Murahdahla, brother of\nSahasrahla and Aginah. Behold the power of\ninvisibility.\n{PAUSE3}\n… … …\nWait! you can see me? I knew I should have\nhidden in a hollow tree.") text['end_pad_data'] = bytearray([0xfb]) text['terminator'] = bytearray([0xFF, 0xFF]) diff --git a/Utils.py b/Utils.py index 0063ed4a18..de9fd0c555 100644 --- a/Utils.py +++ b/Utils.py @@ -87,14 +87,6 @@ def close_console(): except Exception: pass -def new_logic_array(): - import random - l = list(range(256)) - random.SystemRandom().shuffle(l) - chunks = [l[i:i + 16] for i in range(0, len(l), 16)] - lines = [", ".join([str(j) for j in i]) for i in chunks] - print("logic_hash = ["+",\n ".join(lines)+"]") - def make_new_base2current(old_rom='Zelda no Densetsu - Kamigami no Triforce (Japan).sfc', new_rom='working.sfc'): from collections import OrderedDict import json diff --git a/_vendor/__init__.py b/_vendor/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/_vendor/collections_extended/CONTRIBUTERS b/_vendor/collections_extended/CONTRIBUTERS new file mode 100644 index 0000000000..333a02bfe7 --- /dev/null +++ b/_vendor/collections_extended/CONTRIBUTERS @@ -0,0 +1,5 @@ +Mike Lenzen https://github.com/mlenzen +Caleb Levy https://github.com/caleblevy +Marein Könings https://github.com/MareinK +Jad Kik https://github.com/jadkik +Kuba Marek https://github.com/bluecube \ No newline at end of file diff --git a/_vendor/collections_extended/LICENSE b/_vendor/collections_extended/LICENSE new file mode 100644 index 0000000000..8405e89a0b --- /dev/null +++ b/_vendor/collections_extended/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/_vendor/collections_extended/__init__.py b/_vendor/collections_extended/__init__.py new file mode 100644 index 0000000000..039fee030e --- /dev/null +++ b/_vendor/collections_extended/__init__.py @@ -0,0 +1,55 @@ +"""collections_extended contains a few extra basic data structures.""" +from ._compat import Collection +from .bags import bag, frozenbag +from .setlists import setlist, frozensetlist +from .bijection import bijection +from .range_map import RangeMap, MappedRange + +__version__ = '1.0.2' + +__all__ = ( + 'collection', + 'setlist', + 'frozensetlist', + 'bag', + 'frozenbag', + 'bijection', + 'RangeMap', + 'MappedRange', + 'Collection', + ) + + +def collection(iterable=None, mutable=True, ordered=False, unique=False): + """Return a Collection with the specified properties. + + Args: + iterable (Iterable): collection to instantiate new collection from. + mutable (bool): Whether or not the new collection is mutable. + ordered (bool): Whether or not the new collection is ordered. + unique (bool): Whether or not the new collection contains only unique values. + """ + if iterable is None: + iterable = tuple() + if unique: + if ordered: + if mutable: + return setlist(iterable) + else: + return frozensetlist(iterable) + else: + if mutable: + return set(iterable) + else: + return frozenset(iterable) + else: + if ordered: + if mutable: + return list(iterable) + else: + return tuple(iterable) + else: + if mutable: + return bag(iterable) + else: + return frozenbag(iterable) diff --git a/_vendor/collections_extended/_compat.py b/_vendor/collections_extended/_compat.py new file mode 100644 index 0000000000..bbf0fbd951 --- /dev/null +++ b/_vendor/collections_extended/_compat.py @@ -0,0 +1,53 @@ +"""Python 2/3 compatibility helpers.""" +import sys + +is_py2 = sys.version_info[0] == 2 + +if is_py2: + def keys_set(d): + """Return a set of passed dictionary's keys.""" + return set(d.keys()) +else: + keys_set = dict.keys + + +if sys.version_info < (3, 6): + from collections import Sized, Iterable, Container + + def _check_methods(C, *methods): + mro = C.__mro__ + for method in methods: + for B in mro: + if method in B.__dict__: + if B.__dict__[method] is None: + return NotImplemented + break + else: + return NotImplemented + return True + + class Collection(Sized, Iterable, Container): + """Backport from Python3.6.""" + + __slots__ = tuple() + + @classmethod + def __subclasshook__(cls, C): + if cls is Collection: + return _check_methods(C, "__len__", "__iter__", "__contains__") + return NotImplemented + +else: + from collections.abc import Collection + + +def handle_rich_comp_not_implemented(): + """Correctly handle unimplemented rich comparisons. + + In Python 3, return NotImplemented. + In Python 2, raise a TypeError. + """ + if is_py2: + raise TypeError() + else: + return NotImplemented diff --git a/_vendor/collections_extended/_util.py b/_vendor/collections_extended/_util.py new file mode 100644 index 0000000000..58a83f452b --- /dev/null +++ b/_vendor/collections_extended/_util.py @@ -0,0 +1,16 @@ +"""util functions for collections_extended.""" + + +def hash_iterable(it): + """Perform a O(1) memory hash of an iterable of arbitrary length. + + hash(tuple(it)) creates a temporary tuple containing all values from it + which could be a problem if it is large. + + See discussion at: + https://groups.google.com/forum/#!msg/python-ideas/XcuC01a8SYs/e-doB9TbDwAJ + """ + hash_value = hash(type(it)) + for value in it: + hash_value = hash((hash_value, value)) + return hash_value diff --git a/_vendor/collections_extended/bags.py b/_vendor/collections_extended/bags.py new file mode 100644 index 0000000000..cce132fe42 --- /dev/null +++ b/_vendor/collections_extended/bags.py @@ -0,0 +1,527 @@ +"""Bag class definitions.""" +import heapq +from operator import itemgetter +from collections import Set, MutableSet, Hashable + +from . import _compat + + +class _basebag(Set): + """Base class for bag classes. + + Base class for bag and frozenbag. Is not mutable and not hashable, so there's + no reason to use this instead of either bag or frozenbag. + """ + + # Basic object methods + + def __init__(self, iterable=None): + """Create a new basebag. + + If iterable isn't given, is None or is empty then the bag starts empty. + Otherwise each element from iterable will be added to the bag + however many times it appears. + + This runs in O(len(iterable)) + """ + self._dict = dict() + self._size = 0 + if iterable: + if isinstance(iterable, _basebag): + for elem, count in iterable._dict.items(): + self._dict[elem] = count + self._size += count + else: + for value in iterable: + self._dict[value] = self._dict.get(value, 0) + 1 + self._size += 1 + + def __repr__(self): + if self._size == 0: + return '{0}()'.format(self.__class__.__name__) + else: + repr_format = '{class_name}({values!r})' + return repr_format.format( + class_name=self.__class__.__name__, + values=tuple(self), + ) + + def __str__(self): + if self._size == 0: + return '{class_name}()'.format(class_name=self.__class__.__name__) + else: + format_single = '{elem!r}' + format_mult = '{elem!r}^{mult}' + strings = [] + for elem, mult in self._dict.items(): + if mult > 1: + strings.append(format_mult.format(elem=elem, mult=mult)) + else: + strings.append(format_single.format(elem=elem)) + return '{%s}' % ', '.join(strings) + + # New public methods (not overriding/implementing anything) + + def num_unique_elements(self): + """Return the number of unique elements. + + This runs in O(1) time + """ + return len(self._dict) + + def unique_elements(self): + """Return a view of unique elements in this bag. + + In Python 3: + This runs in O(1) time and returns a view of the unique elements + In Python 2: + This runs in O(n) and returns set of the current elements. + """ + return _compat.keys_set(self._dict) + + def count(self, value): + """Return the number of value present in this bag. + + If value is not in the bag no Error is raised, instead 0 is returned. + + This runs in O(1) time + + Args: + value: The element of self to get the count of + Returns: + int: The count of value in self + """ + return self._dict.get(value, 0) + + def nlargest(self, n=None): + """List the n most common elements and their counts. + + List is from the most + common to the least. If n is None, the list all element counts. + + Run time should be O(m log m) where m is len(self) + Args: + n (int): The number of elements to return + """ + if n is None: + return sorted(self._dict.items(), key=itemgetter(1), reverse=True) + else: + return heapq.nlargest(n, self._dict.items(), key=itemgetter(1)) + + @classmethod + def _from_iterable(cls, it): + return cls(it) + + @classmethod + def from_mapping(cls, mapping): + """Create a bag from a dict of elem->count. + + Each key in the dict is added if the value is > 0. + """ + out = cls() + for elem, count in mapping.items(): + if count > 0: + out._dict[elem] = count + out._size += count + return out + + def copy(self): + """Create a shallow copy of self. + + This runs in O(len(self.num_unique_elements())) + """ + return self.from_mapping(self._dict) + + # implementing Sized methods + + def __len__(self): + """Return the cardinality of the bag. + + This runs in O(1) + """ + return self._size + + # implementing Container methods + + def __contains__(self, value): + """Return the multiplicity of the element. + + This runs in O(1) + """ + return self._dict.get(value, 0) + + # implementing Iterable methods + + def __iter__(self): + """Iterate through all elements. + + Multiple copies will be returned if they exist. + """ + for value, count in self._dict.items(): + for i in range(count): + yield(value) + + # Comparison methods + + def _is_subset(self, other): + """Check that every element in self has a count <= in other. + + Args: + other (Set) + """ + if isinstance(other, _basebag): + for elem, count in self._dict.items(): + if not count <= other._dict.get(elem, 0): + return False + else: + for elem in self: + if self._dict.get(elem, 0) > 1 or elem not in other: + return False + return True + + def _is_superset(self, other): + """Check that every element in self has a count >= in other. + + Args: + other (Set) + """ + if isinstance(other, _basebag): + for elem, count in other._dict.items(): + if not self._dict.get(elem, 0) >= count: + return False + else: + for elem in other: + if elem not in self: + return False + return True + + def __le__(self, other): + if not isinstance(other, Set): + return _compat.handle_rich_comp_not_implemented() + return len(self) <= len(other) and self._is_subset(other) + + def __lt__(self, other): + if not isinstance(other, Set): + return _compat.handle_rich_comp_not_implemented() + return len(self) < len(other) and self._is_subset(other) + + def __gt__(self, other): + if not isinstance(other, Set): + return _compat.handle_rich_comp_not_implemented() + return len(self) > len(other) and self._is_superset(other) + + def __ge__(self, other): + if not isinstance(other, Set): + return _compat.handle_rich_comp_not_implemented() + return len(self) >= len(other) and self._is_superset(other) + + def __eq__(self, other): + if not isinstance(other, Set): + return False + if isinstance(other, _basebag): + return self._dict == other._dict + if not len(self) == len(other): + return False + for elem in other: + if self._dict.get(elem, 0) != 1: + return False + return True + + def __ne__(self, other): + return not (self == other) + + # Operations - &, |, +, -, ^, * and isdisjoint + + def __and__(self, other): + """Intersection is the minimum of corresponding counts. + + This runs in O(l + n) where: + n is self.num_unique_elements() + if other is a bag: + l = 1 + else: + l = len(other) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + values = dict() + for elem in self._dict: + values[elem] = min(other._dict.get(elem, 0), self._dict.get(elem, 0)) + return self.from_mapping(values) + + def isdisjoint(self, other): + """Return if this bag is disjoint with the passed collection. + + This runs in O(len(other)) + + TODO move isdisjoint somewhere more appropriate + """ + for value in other: + if value in self: + return False + return True + + def __or__(self, other): + """Union is the maximum of all elements. + + This runs in O(m + n) where: + n is self.num_unique_elements() + if other is a bag: + m = other.num_unique_elements() + else: + m = len(other) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + values = dict() + for elem in self.unique_elements() | other.unique_elements(): + values[elem] = max(self._dict.get(elem, 0), other._dict.get(elem, 0)) + return self.from_mapping(values) + + def __add__(self, other): + """Return a new bag also containing all the elements of other. + + self + other = self & other + self | other + + This runs in O(m + n) where: + n is self.num_unique_elements() + m is len(other) + Args: + other (Iterable): elements to add to self + """ + out = self.copy() + for value in other: + out._dict[value] = out._dict.get(value, 0) + 1 + out._size += 1 + return out + + def __sub__(self, other): + """Difference between the sets. + + For normal sets this is all x s.t. x in self and x not in other. + For bags this is count(x) = max(0, self.count(x)-other.count(x)) + + This runs in O(m + n) where: + n is self.num_unique_elements() + m is len(other) + Args: + other (Iterable): elements to remove + """ + out = self.copy() + for value in other: + old_count = out._dict.get(value, 0) + if old_count == 1: + del out._dict[value] + out._size -= 1 + elif old_count > 1: + out._dict[value] = old_count - 1 + out._size -= 1 + return out + + def __mul__(self, other): + """Cartesian product of the two sets. + + other can be any iterable. + Both self and other must contain elements that can be added together. + + This should run in O(m*n+l) where: + m is the number of unique elements in self + n is the number of unique elements in other + if other is a bag: + l is 0 + else: + l is the len(other) + The +l will only really matter when other is an iterable with MANY + repeated elements. + For example: {'a'^2} * 'bbbbbbbbbbbbbbbbbbbbbbbbbb' + The algorithm will be dominated by counting the 'b's + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + values = dict() + for elem, count in self._dict.items(): + for other_elem, other_count in other._dict.items(): + new_elem = elem + other_elem + new_count = count * other_count + values[new_elem] = new_count + return self.from_mapping(values) + + def __xor__(self, other): + """Symmetric difference between the sets. + + other can be any iterable. + + This runs in O(m + n) where: + m = len(self) + n = len(other) + """ + return (self - other) | (other - self) + + +class bag(_basebag, MutableSet): + """bag is a mutable unhashable bag.""" + + def pop(self): + """Remove and return an element of self.""" + # TODO can this be done more efficiently (no need to create an iterator)? + it = iter(self) + try: + value = next(it) + except StopIteration: + raise KeyError + self.discard(value) + return value + + def add(self, elem): + """Add elem to self.""" + self._dict[elem] = self._dict.get(elem, 0) + 1 + self._size += 1 + + def discard(self, elem): + """Remove elem from this bag, silent if it isn't present.""" + try: + self.remove(elem) + except ValueError: + pass + + def remove(self, elem): + """Remove elem from this bag, raising a ValueError if it isn't present. + + Args: + elem: object to remove from self + Raises: + ValueError: if the elem isn't present + """ + old_count = self._dict.get(elem, 0) + if old_count == 0: + raise ValueError + elif old_count == 1: + del self._dict[elem] + else: + self._dict[elem] -= 1 + self._size -= 1 + + def discard_all(self, other): + """Discard all of the elems from other.""" + if not isinstance(other, _basebag): + other = self._from_iterable(other) + for elem, other_count in other._dict.items(): + old_count = self._dict.get(elem, 0) + new_count = old_count - other_count + if new_count >= 0: + if new_count == 0: + if elem in self: + del self._dict[elem] + else: + self._dict[elem] = new_count + self._size += new_count - old_count + + def remove_all(self, other): + """Remove all of the elems from other. + + Raises a ValueError if the multiplicity of any elem in other is greater + than in self. + """ + if not self._is_superset(other): + raise ValueError + self.discard_all(other) + + def clear(self): + """Remove all elements from this bag.""" + self._dict = dict() + self._size = 0 + + # In-place operations + + def __ior__(self, other): + """Set multiplicity of each element to the maximum of the two collections. + + if isinstance(other, _basebag): + This runs in O(other.num_unique_elements()) + else: + This runs in O(len(other)) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + for elem, other_count in other._dict.items(): + old_count = self._dict.get(elem, 0) + new_count = max(other_count, old_count) + self._dict[elem] = new_count + self._size += new_count - old_count + return self + + def __iand__(self, other): + """Set multiplicity of each element to the minimum of the two collections. + + if isinstance(other, _basebag): + This runs in O(other.num_unique_elements()) + else: + This runs in O(len(other)) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + for elem, old_count in set(self._dict.items()): + other_count = other._dict.get(elem, 0) + new_count = min(other_count, old_count) + if new_count == 0: + del self._dict[elem] + else: + self._dict[elem] = new_count + self._size += new_count - old_count + return self + + def __ixor__(self, other): + """Set self to the symmetric difference between the sets. + + if isinstance(other, _basebag): + This runs in O(other.num_unique_elements()) + else: + This runs in O(len(other)) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + other_minus_self = other - self + self -= other + self |= other_minus_self + return self + + def __isub__(self, other): + """Discard the elements of other from self. + + if isinstance(it, _basebag): + This runs in O(it.num_unique_elements()) + else: + This runs in O(len(it)) + """ + self.discard_all(other) + return self + + def __iadd__(self, other): + """Add all of the elements of other to self. + + if isinstance(it, _basebag): + This runs in O(it.num_unique_elements()) + else: + This runs in O(len(it)) + """ + if not isinstance(other, _basebag): + other = self._from_iterable(other) + for elem, other_count in other._dict.items(): + self._dict[elem] = self._dict.get(elem, 0) + other_count + self._size += other_count + return self + + +class frozenbag(_basebag, Hashable): + """frozenbag is an immutable, hashable bab.""" + + def __hash__(self): + """Compute the hash value of a frozenbag. + + This was copied directly from _collections_abc.Set._hash in Python3 which + is identical to _abcoll.Set._hash + We can't call it directly because Python2 raises a TypeError. + """ + if not hasattr(self, '_hash_value'): + self._hash_value = self._hash() + return self._hash_value diff --git a/_vendor/collections_extended/bijection.py b/_vendor/collections_extended/bijection.py new file mode 100644 index 0000000000..f9641de4d1 --- /dev/null +++ b/_vendor/collections_extended/bijection.py @@ -0,0 +1,94 @@ +"""Class definition for bijection.""" + +from collections import MutableMapping, Mapping + + +class bijection(MutableMapping): + """A one-to-one onto mapping, a dict with unique values.""" + + def __init__(self, iterable=None, **kwarg): + """Create a bijection from an iterable. + + Matches dict.__init__. + """ + self._data = {} + self.__inverse = self.__new__(bijection) + self.__inverse._data = {} + self.__inverse.__inverse = self + if iterable is not None: + if isinstance(iterable, Mapping): + for key, value in iterable.items(): + self[key] = value + else: + for pair in iterable: + self[pair[0]] = pair[1] + for key, value in kwarg.items(): + self[key] = value + + def __repr__(self): + if len(self._data) == 0: + return '{0}()'.format(self.__class__.__name__) + else: + repr_format = '{class_name}({values!r})' + return repr_format.format( + class_name=self.__class__.__name__, + values=self._data, + ) + + @property + def inverse(self): + """Return the inverse of this bijection.""" + return self.__inverse + + # Required for MutableMapping + def __len__(self): + return len(self._data) + + # Required for MutableMapping + def __getitem__(self, key): + return self._data[key] + + # Required for MutableMapping + def __setitem__(self, key, value): + if key in self: + del self.inverse._data[self[key]] + if value in self.inverse: + del self._data[self.inverse[value]] + self._data[key] = value + self.inverse._data[value] = key + + # Required for MutableMapping + def __delitem__(self, key): + value = self._data.pop(key) + del self.inverse._data[value] + + # Required for MutableMapping + def __iter__(self): + return iter(self._data) + + def __contains__(self, key): + return key in self._data + + def clear(self): + """Remove everything from this bijection.""" + self._data.clear() + self.inverse._data.clear() + + def copy(self): + """Return a copy of this bijection.""" + return bijection(self) + + def items(self): + """See Mapping.items.""" + return self._data.items() + + def keys(self): + """See Mapping.keys.""" + return self._data.keys() + + def values(self): + """See Mapping.values.""" + return self.inverse.keys() + + def __eq__(self, other): + return isinstance(other, bijection) and self._data == other._data diff --git a/_vendor/collections_extended/range_map.py b/_vendor/collections_extended/range_map.py new file mode 100644 index 0000000000..19a612388b --- /dev/null +++ b/_vendor/collections_extended/range_map.py @@ -0,0 +1,384 @@ +"""RangeMap class definition.""" +from bisect import bisect_left, bisect_right +from collections import namedtuple, Mapping, MappingView, Set + + +# Used to mark unmapped ranges +_empty = object() + +MappedRange = namedtuple('MappedRange', ('start', 'stop', 'value')) + + +class KeysView(MappingView, Set): + """A view of the keys that mark the starts of subranges. + + Since iterating over all the keys is impossible, the KeysView only + contains the keys that start each subrange. + """ + + __slots__ = () + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, key): + loc = self._mapping._bisect_left(key) + return self._mapping._keys[loc] == key and \ + self._mapping._values[loc] is not _empty + + def __iter__(self): + for item in self._mapping.ranges(): + yield item.start + + +class ItemsView(MappingView, Set): + """A view of the items that mark the starts of subranges. + + Since iterating over all the keys is impossible, the ItemsView only + contains the items that start each subrange. + """ + + __slots__ = () + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, item): + key, value = item + loc = self._mapping._bisect_left(key) + return self._mapping._keys[loc] == key and \ + self._mapping._values[loc] == value + + def __iter__(self): + for mapped_range in self._mapping.ranges(): + yield (mapped_range.start, mapped_range.value) + + +class ValuesView(MappingView): + """A view on the values of a Mapping.""" + + __slots__ = () + + def __contains__(self, value): + return value in self._mapping._values + + def __iter__(self): + for value in self._mapping._values: + if value is not _empty: + yield value + + +def _check_start_stop(start, stop): + """Check that start and stop are valid - orderable and in the right order. + + Raises: + ValueError: if stop <= start + TypeError: if unorderable + """ + if start is not None and stop is not None and stop <= start: + raise ValueError('stop must be > start') + + +def _check_key_slice(key): + if not isinstance(key, slice): + raise TypeError('Can only set and delete slices') + if key.step is not None: + raise ValueError('Cannot set or delete slices with steps') + + +class RangeMap(Mapping): + """Map ranges of orderable elements to values.""" + + def __init__(self, iterable=None, **kwargs): + """Create a RangeMap. + + A mapping or other iterable can be passed to initialize the RangeMap. + If mapping is passed, it is interpreted as a mapping from range start + indices to values. + If an iterable is passed, each element will define a range in the + RangeMap and should be formatted (start, stop, value). + + default_value is a an optional keyword argument that will initialize the + entire RangeMap to that value. Any missing ranges will be mapped to that + value. However, if ranges are subsequently deleted they will be removed + and *not* mapped to the default_value. + + Args: + iterable: A Mapping or an Iterable to initialize from. + default_value: If passed, the return value for all keys less than the + least key in mapping or missing ranges in iterable. If no mapping + or iterable, the return value for all keys. + """ + default_value = kwargs.pop('default_value', _empty) + if kwargs: + raise TypeError('Unknown keyword arguments: %s' % ', '.join(kwargs.keys())) + self._keys = [None] + self._values = [default_value] + if iterable: + if isinstance(iterable, Mapping): + self._init_from_mapping(iterable) + else: + self._init_from_iterable(iterable) + + @classmethod + def from_mapping(cls, mapping): + """Create a RangeMap from a mapping of interval starts to values.""" + obj = cls() + obj._init_from_mapping(mapping) + return obj + + def _init_from_mapping(self, mapping): + for key, value in sorted(mapping.items()): + self.set(value, key) + + @classmethod + def from_iterable(cls, iterable): + """Create a RangeMap from an iterable of tuples defining each range. + + Each element of the iterable is a tuple (start, stop, value). + """ + obj = cls() + obj._init_from_iterable(iterable) + return obj + + def _init_from_iterable(self, iterable): + for start, stop, value in iterable: + self.set(value, start=start, stop=stop) + + def __str__(self): + range_format = '({range.start}, {range.stop}): {range.value}' + values = ', '.join([range_format.format(range=r) for r in self.ranges()]) + return 'RangeMap(%s)' % values + + def __repr__(self): + range_format = '({range.start!r}, {range.stop!r}, {range.value!r})' + values = ', '.join([range_format.format(range=r) for r in self.ranges()]) + return 'RangeMap([%s])' % values + + def _bisect_left(self, key): + """Return the index of the key or the last key < key.""" + if key is None: + return 0 + else: + return bisect_left(self._keys, key, lo=1) + + def _bisect_right(self, key): + """Return the index of the first key > key.""" + if key is None: + return 1 + else: + return bisect_right(self._keys, key, lo=1) + + def ranges(self, start=None, stop=None): + """Generate MappedRanges for all mapped ranges. + + Yields: + MappedRange + """ + _check_start_stop(start, stop) + start_loc = self._bisect_right(start) + if stop is None: + stop_loc = len(self._keys) + else: + stop_loc = self._bisect_left(stop) + start_val = self._values[start_loc - 1] + candidate_keys = [start] + self._keys[start_loc:stop_loc] + [stop] + candidate_values = [start_val] + self._values[start_loc:stop_loc] + for i, value in enumerate(candidate_values): + if value is not _empty: + start_key = candidate_keys[i] + stop_key = candidate_keys[i + 1] + yield MappedRange(start_key, stop_key, value) + + def __contains__(self, value): + try: + self.__getitem(value) is not _empty + except KeyError: + return False + else: + return True + + def __iter__(self): + for key, value in zip(self._keys, self._values): + if value is not _empty: + yield key + + def __bool__(self): + if len(self._keys) > 1: + return True + else: + return self._values[0] != _empty + + __nonzero__ = __bool__ + + def __getitem(self, key): + """Get the value for a key (not a slice).""" + loc = self._bisect_right(key) - 1 + value = self._values[loc] + if value is _empty: + raise KeyError(key) + else: + return value + + def get(self, key, restval=None): + """Get the value of the range containing key, otherwise return restval.""" + try: + return self.__getitem(key) + except KeyError: + return restval + + def get_range(self, start=None, stop=None): + """Return a RangeMap for the range start to stop. + + Returns: + A RangeMap + """ + return self.from_iterable(self.ranges(start, stop)) + + def set(self, value, start=None, stop=None): + """Set the range from start to stop to value.""" + _check_start_stop(start, stop) + # start_index, stop_index will denote the sections we are replacing + start_index = self._bisect_left(start) + if start is not None: # start_index == 0 + prev_value = self._values[start_index - 1] + if prev_value == value: + # We're setting a range where the left range has the same + # value, so create one big range + start_index -= 1 + start = self._keys[start_index] + if stop is None: + new_keys = [start] + new_values = [value] + stop_index = len(self._keys) + else: + stop_index = self._bisect_right(stop) + stop_value = self._values[stop_index - 1] + stop_key = self._keys[stop_index - 1] + if stop_key == stop and stop_value == value: + new_keys = [start] + new_values = [value] + else: + new_keys = [start, stop] + new_values = [value, stop_value] + self._keys[start_index:stop_index] = new_keys + self._values[start_index:stop_index] = new_values + + def delete(self, start=None, stop=None): + """Delete the range from start to stop from self. + + Raises: + KeyError: If part of the passed range isn't mapped. + """ + _check_start_stop(start, stop) + start_loc = self._bisect_right(start) - 1 + if stop is None: + stop_loc = len(self._keys) + else: + stop_loc = self._bisect_left(stop) + for value in self._values[start_loc:stop_loc]: + if value is _empty: + raise KeyError((start, stop)) + # this is inefficient, we've already found the sub ranges + self.set(_empty, start=start, stop=stop) + + def empty(self, start=None, stop=None): + """Empty the range from start to stop. + + Like delete, but no Error is raised if the entire range isn't mapped. + """ + self.set(_empty, start=start, stop=stop) + + def clear(self): + """Remove all elements.""" + self._keys = [None] + self._values = [_empty] + + @property + def start(self): + """Get the start key of the first range. + + None if RangeMap is empty or unbounded to the left. + """ + if self._values[0] is _empty: + try: + return self._keys[1] + except IndexError: + # This is empty or everything is mapped to a single value + return None + else: + # This is unbounded to the left + return self._keys[0] + + @property + def end(self): + """Get the stop key of the last range. + + None if RangeMap is empty or unbounded to the right. + """ + if self._values[-1] is _empty: + return self._keys[-1] + else: + # This is unbounded to the right + return None + + def __eq__(self, other): + if isinstance(other, RangeMap): + return ( + self._keys == other._keys and + self._values == other._values + ) + else: + return False + + def __getitem__(self, key): + try: + _check_key_slice(key) + except TypeError: + return self.__getitem(key) + else: + return self.get_range(key.start, key.stop) + + def __setitem__(self, key, value): + _check_key_slice(key) + self.set(value, key.start, key.stop) + + def __delitem__(self, key): + _check_key_slice(key) + self.delete(key.start, key.stop) + + def __len__(self): + count = 0 + for v in self._values: + if v is not _empty: + count += 1 + return count + + def keys(self): + """Return a view of the keys.""" + return KeysView(self) + + def values(self): + """Return a view of the values.""" + return ValuesView(self) + + def items(self): + """Return a view of the item pairs.""" + return ItemsView(self) + + # Python2 - override slice methods + def __setslice__(self, i, j, value): + """Implement __setslice__ to override behavior in Python 2. + + This is required because empty slices pass integers in python2 as opposed + to None in python 3. + """ + raise SyntaxError('Assigning slices doesn\t work in Python 2, use set') + + def __delslice__(self, i, j): + raise SyntaxError('Deleting slices doesn\t work in Python 2, use delete') + + def __getslice__(self, i, j): + raise SyntaxError('Getting slices doesn\t work in Python 2, use get_range.') diff --git a/_vendor/collections_extended/setlists.py b/_vendor/collections_extended/setlists.py new file mode 100644 index 0000000000..2976077c73 --- /dev/null +++ b/_vendor/collections_extended/setlists.py @@ -0,0 +1,552 @@ +"""Setlist class definitions.""" +import random as random_ + +from collections import ( + Sequence, + Set, + MutableSequence, + MutableSet, + Hashable, + ) + +from . import _util + + +class _basesetlist(Sequence, Set): + """A setlist is an ordered Collection of unique elements. + + _basesetlist is the superclass of setlist and frozensetlist. It is immutable + and unhashable. + """ + + def __init__(self, iterable=None, raise_on_duplicate=False): + """Create a setlist. + + Args: + iterable (Iterable): Values to initialize the setlist with. + """ + self._list = list() + self._dict = dict() + if iterable: + if raise_on_duplicate: + self._extend(iterable) + else: + self._update(iterable) + + def __repr__(self): + if len(self) == 0: + return '{0}()'.format(self.__class__.__name__) + else: + repr_format = '{class_name}({values!r})' + return repr_format.format( + class_name=self.__class__.__name__, + values=tuple(self), + ) + + # Convenience methods + def _fix_neg_index(self, index): + if index < 0: + index += len(self) + if index < 0: + raise IndexError('index is out of range') + return index + + def _fix_end_index(self, index): + if index is None: + return len(self) + else: + return self._fix_neg_index(index) + + def _append(self, value): + # Checking value in self will check that value is Hashable + if value in self: + raise ValueError('Value "%s" already present' % str(value)) + else: + self._dict[value] = len(self) + self._list.append(value) + + def _extend(self, values): + new_values = set() + for value in values: + if value in new_values: + raise ValueError('New values contain duplicates') + elif value in self: + raise ValueError('New values contain elements already present in self') + else: + new_values.add(value) + for value in values: + self._dict[value] = len(self) + self._list.append(value) + + def _add(self, item): + if item not in self: + self._dict[item] = len(self) + self._list.append(item) + + def _update(self, values): + for value in values: + if value not in self: + self._dict[value] = len(self) + self._list.append(value) + + @classmethod + def _from_iterable(cls, it, **kwargs): + return cls(it, **kwargs) + + # Implement Container + def __contains__(self, value): + return value in self._dict + + # Iterable we get by inheriting from Sequence + + # Implement Sized + def __len__(self): + return len(self._list) + + # Implement Sequence + def __getitem__(self, index): + if isinstance(index, slice): + return self._from_iterable(self._list[index]) + return self._list[index] + + def count(self, value): + """Return the number of occurences of value in self. + + This runs in O(1) + + Args: + value: The value to count + Returns: + int: 1 if the value is in the setlist, otherwise 0 + """ + if value in self: + return 1 + else: + return 0 + + def index(self, value, start=0, end=None): + """Return the index of value between start and end. + + By default, the entire setlist is searched. + + This runs in O(1) + + Args: + value: The value to find the index of + start (int): The index to start searching at (defaults to 0) + end (int): The index to stop searching at (defaults to the end of the list) + Returns: + int: The index of the value + Raises: + ValueError: If the value is not in the list or outside of start - end + IndexError: If start or end are out of range + """ + try: + index = self._dict[value] + except KeyError: + raise ValueError + else: + start = self._fix_neg_index(start) + end = self._fix_end_index(end) + if start <= index and index < end: + return index + else: + raise ValueError + + @classmethod + def _check_type(cls, other, operand_name): + if not isinstance(other, _basesetlist): + message = ( + "unsupported operand type(s) for {operand_name}: " + "'{self_type}' and '{other_type}'").format( + operand_name=operand_name, + self_type=cls, + other_type=type(other), + ) + raise TypeError(message) + + def __add__(self, other): + self._check_type(other, '+') + out = self.copy() + out._extend(other) + return out + + # Implement Set + + def issubset(self, other): + return self <= other + + def issuperset(self, other): + return self >= other + + def union(self, other): + out = self.copy() + out.update(other) + return out + + def intersection(self, other): + other = set(other) + return self._from_iterable(item for item in self if item in other) + + def difference(self, other): + other = set(other) + return self._from_iterable(item for item in self if item not in other) + + def symmetric_difference(self, other): + return self.union(other) - self.intersection(other) + + def __sub__(self, other): + self._check_type(other, '-') + return self.difference(other) + + def __and__(self, other): + self._check_type(other, '&') + return self.intersection(other) + + def __or__(self, other): + self._check_type(other, '|') + return self.union(other) + + def __xor__(self, other): + self._check_type(other, '^') + return self.symmetric_difference(other) + + # Comparison + + def __eq__(self, other): + if not isinstance(other, _basesetlist): + return False + if not len(self) == len(other): + return False + for self_elem, other_elem in zip(self, other): + if self_elem != other_elem: + return False + return True + + def __ne__(self, other): + return not (self == other) + + # New methods + + def sub_index(self, sub, start=0, end=None): + """Return the index of a subsequence. + + This runs in O(len(sub)) + + Args: + sub (Sequence): An Iterable to search for + Returns: + int: The index of the first element of sub + Raises: + ValueError: If sub isn't a subsequence + TypeError: If sub isn't iterable + IndexError: If start or end are out of range + """ + start_index = self.index(sub[0], start, end) + end = self._fix_end_index(end) + if start_index + len(sub) > end: + raise ValueError + for i in range(1, len(sub)): + if sub[i] != self[start_index + i]: + raise ValueError + return start_index + + def copy(self): + return self.__class__(self) + + +class setlist(_basesetlist, MutableSequence, MutableSet): + """A mutable (unhashable) setlist.""" + + def __str__(self): + return '{[%s}]' % ', '.join(repr(v) for v in self) + + # Helper methods + def _delete_all(self, elems_to_delete, raise_errors): + indices_to_delete = set() + for elem in elems_to_delete: + try: + elem_index = self._dict[elem] + except KeyError: + if raise_errors: + raise ValueError('Passed values contain elements not in self') + else: + if elem_index in indices_to_delete: + if raise_errors: + raise ValueError('Passed vales contain duplicates') + indices_to_delete.add(elem_index) + self._delete_values_by_index(indices_to_delete) + + def _delete_values_by_index(self, indices_to_delete): + deleted_count = 0 + for i, elem in enumerate(self._list): + if i in indices_to_delete: + deleted_count += 1 + del self._dict[elem] + else: + new_index = i - deleted_count + self._list[new_index] = elem + self._dict[elem] = new_index + # Now remove deleted_count items from the end of the list + if deleted_count: + self._list = self._list[:-deleted_count] + + # Set/Sequence agnostic + def pop(self, index=-1): + """Remove and return the item at index.""" + value = self._list.pop(index) + del self._dict[value] + return value + + def clear(self): + """Remove all elements from self.""" + self._dict = dict() + self._list = list() + + # Implement MutableSequence + def __setitem__(self, index, value): + if isinstance(index, slice): + old_values = self[index] + for v in value: + if v in self and v not in old_values: + raise ValueError + self._list[index] = value + self._dict = {} + for i, v in enumerate(self._list): + self._dict[v] = i + else: + index = self._fix_neg_index(index) + old_value = self._list[index] + if value in self: + if value == old_value: + return + else: + raise ValueError + del self._dict[old_value] + self._list[index] = value + self._dict[value] = index + + def __delitem__(self, index): + if isinstance(index, slice): + indices_to_delete = set(self.index(e) for e in self._list[index]) + self._delete_values_by_index(indices_to_delete) + else: + index = self._fix_neg_index(index) + value = self._list[index] + del self._dict[value] + for elem in self._list[index + 1:]: + self._dict[elem] -= 1 + del self._list[index] + + def insert(self, index, value): + """Insert value at index. + + Args: + index (int): Index to insert value at + value: Value to insert + Raises: + ValueError: If value already in self + IndexError: If start or end are out of range + """ + if value in self: + raise ValueError + index = self._fix_neg_index(index) + self._dict[value] = index + for elem in self._list[index:]: + self._dict[elem] += 1 + self._list.insert(index, value) + + def append(self, value): + """Append value to the end. + + Args: + value: Value to append + Raises: + ValueError: If value alread in self + TypeError: If value isn't hashable + """ + self._append(value) + + def extend(self, values): + """Append all values to the end. + + If any of the values are present, ValueError will + be raised and none of the values will be appended. + + Args: + values (Iterable): Values to append + Raises: + ValueError: If any values are already present or there are duplicates + in the passed values. + TypeError: If any of the values aren't hashable. + """ + self._extend(values) + + def __iadd__(self, values): + """Add all values to the end of self. + + Args: + values (Iterable): Values to append + Raises: + ValueError: If any values are already present + """ + self._check_type(values, '+=') + self.extend(values) + return self + + def remove(self, value): + """Remove value from self. + + Args: + value: Element to remove from self + Raises: + ValueError: if element is already present + """ + try: + index = self._dict[value] + except KeyError: + raise ValueError('Value "%s" is not present.') + else: + del self[index] + + def remove_all(self, elems_to_delete): + """Remove all elements from elems_to_delete, raises ValueErrors. + + See Also: + discard_all + Args: + elems_to_delete (Iterable): Elements to remove. + Raises: + ValueError: If the count of any element is greater in + elems_to_delete than self. + TypeError: If any of the values aren't hashable. + """ + self._delete_all(elems_to_delete, raise_errors=True) + + # Implement MutableSet + + def add(self, item): + """Add an item. + + Note: + This does not raise a ValueError for an already present value like + append does. This is to match the behavior of set.add + Args: + item: Item to add + Raises: + TypeError: If item isn't hashable. + """ + self._add(item) + + def update(self, values): + """Add all values to the end. + + If any of the values are present, silently ignore + them (as opposed to extend which raises an Error). + + See also: + extend + Args: + values (Iterable): Values to add + Raises: + TypeError: If any of the values are unhashable. + """ + self._update(values) + + def discard_all(self, elems_to_delete): + """Discard all the elements from elems_to_delete. + + This is much faster than removing them one by one. + This runs in O(len(self) + len(elems_to_delete)) + + Args: + elems_to_delete (Iterable): Elements to discard. + Raises: + TypeError: If any of the values aren't hashable. + """ + self._delete_all(elems_to_delete, raise_errors=False) + + def discard(self, value): + """Discard an item. + + Note: + This does not raise a ValueError for a missing value like remove does. + This is to match the behavior of set.discard + """ + try: + self.remove(value) + except ValueError: + pass + + def difference_update(self, other): + """Update self to include only the differene with other.""" + other = set(other) + indices_to_delete = set() + for i, elem in enumerate(self): + if elem in other: + indices_to_delete.add(i) + if indices_to_delete: + self._delete_values_by_index(indices_to_delete) + + def intersection_update(self, other): + """Update self to include only the intersection with other.""" + other = set(other) + indices_to_delete = set() + for i, elem in enumerate(self): + if elem not in other: + indices_to_delete.add(i) + if indices_to_delete: + self._delete_values_by_index(indices_to_delete) + + def symmetric_difference_update(self, other): + """Update self to include only the symmetric difference with other.""" + other = setlist(other) + indices_to_delete = set() + for i, item in enumerate(self): + if item in other: + indices_to_delete.add(i) + for item in other: + self.add(item) + self._delete_values_by_index(indices_to_delete) + + def __isub__(self, other): + self._check_type(other, '-=') + self.difference_update(other) + return self + + def __iand__(self, other): + self._check_type(other, '&=') + self.intersection_update(other) + return self + + def __ior__(self, other): + self._check_type(other, '|=') + self.update(other) + return self + + def __ixor__(self, other): + self._check_type(other, '^=') + self.symmetric_difference_update(other) + return self + + # New methods + def shuffle(self, random=None): + """Shuffle all of the elements in self randomly.""" + random_.shuffle(self._list, random=random) + for i, elem in enumerate(self._list): + self._dict[elem] = i + + def sort(self, *args, **kwargs): + """Sort this setlist in place.""" + self._list.sort(*args, **kwargs) + for index, value in enumerate(self._list): + self._dict[value] = index + + +class frozensetlist(_basesetlist, Hashable): + """An immutable (hashable) setlist.""" + + def __hash__(self): + if not hasattr(self, '_hash_value'): + self._hash_value = _util.hash_iterable(self) + return self._hash_value diff --git a/bundle/EntranceRandomizer.spec b/bundle/EntranceRandomizer.spec index c01d61556c..308a3ba912 100644 --- a/bundle/EntranceRandomizer.spec +++ b/bundle/EntranceRandomizer.spec @@ -24,7 +24,7 @@ exe = EXE(pyz, debug=False, strip=False, upx=False, - icon='data/ER.ico', + icon='../data/ER.ico', console=is_win ) coll = COLLECT(exe, a.binaries, @@ -35,5 +35,5 @@ coll = COLLECT(exe, name='EntranceRandomizer') app = BUNDLE(coll, name ='EntranceRandomizer.app', - icon = 'data/ER.icns', + icon = '../data/ER.icns', bundle_identifier = None) diff --git a/data/sprites/official/toadette.1.zspr b/data/sprites/official/Toadette.2.zspr similarity index 98% rename from data/sprites/official/toadette.1.zspr rename to data/sprites/official/Toadette.2.zspr index f503b383f2..8c6498b2d7 100644 Binary files a/data/sprites/official/toadette.1.zspr and b/data/sprites/official/Toadette.2.zspr differ diff --git a/data/sprites/official/abigail.1.zspr b/data/sprites/official/abigail.1.zspr new file mode 100644 index 0000000000..526990c5ef Binary files /dev/null and b/data/sprites/official/abigail.1.zspr differ diff --git a/data/sprites/official/alice.1.zspr b/data/sprites/official/alice.1.zspr new file mode 100644 index 0000000000..4c673acd71 Binary files /dev/null and b/data/sprites/official/alice.1.zspr differ diff --git a/data/sprites/official/bandit.1.zspr b/data/sprites/official/bandit.1.zspr new file mode 100644 index 0000000000..5b3288f80d Binary files /dev/null and b/data/sprites/official/bandit.1.zspr differ diff --git a/data/sprites/official/batman.1.zspr b/data/sprites/official/batman.1.zspr new file mode 100644 index 0000000000..a4a1e9c0ef Binary files /dev/null and b/data/sprites/official/batman.1.zspr differ diff --git a/data/sprites/official/birb.1.zspr b/data/sprites/official/birb.1.zspr new file mode 100644 index 0000000000..d6d86bb688 Binary files /dev/null and b/data/sprites/official/birb.1.zspr differ diff --git a/data/sprites/official/blackmage.1.zspr b/data/sprites/official/blackmage.1.zspr new file mode 100644 index 0000000000..d9b5628852 Binary files /dev/null and b/data/sprites/official/blackmage.1.zspr differ diff --git a/data/sprites/official/blossom.1.zspr b/data/sprites/official/blossom.1.zspr new file mode 100644 index 0000000000..57f4918c55 Binary files /dev/null and b/data/sprites/official/blossom.1.zspr differ diff --git a/data/sprites/official/bottle_o_goo.1.zspr b/data/sprites/official/bottle_o_goo.1.zspr new file mode 100644 index 0000000000..28ca1f9b69 Binary files /dev/null and b/data/sprites/official/bottle_o_goo.1.zspr differ diff --git a/data/sprites/official/bowser.1.zspr b/data/sprites/official/bowser.1.zspr new file mode 100644 index 0000000000..1cc256d8c3 Binary files /dev/null and b/data/sprites/official/bowser.1.zspr differ diff --git a/data/sprites/official/branch.1.zspr b/data/sprites/official/branch.1.zspr new file mode 100644 index 0000000000..b79264183b Binary files /dev/null and b/data/sprites/official/branch.1.zspr differ diff --git a/data/sprites/official/bubbles.1.zspr b/data/sprites/official/bubbles.1.zspr new file mode 100644 index 0000000000..bbba3b7546 Binary files /dev/null and b/data/sprites/official/bubbles.1.zspr differ diff --git a/data/sprites/official/bullet_bill.1.zspr b/data/sprites/official/bullet_bill.1.zspr new file mode 100644 index 0000000000..5b561b9eee Binary files /dev/null and b/data/sprites/official/bullet_bill.1.zspr differ diff --git a/data/sprites/official/buttercup.1.zspr b/data/sprites/official/buttercup.1.zspr new file mode 100644 index 0000000000..bd066c2743 Binary files /dev/null and b/data/sprites/official/buttercup.1.zspr differ diff --git a/data/sprites/official/clyde.1.zspr b/data/sprites/official/clyde.1.zspr new file mode 100644 index 0000000000..b590a2ef91 Binary files /dev/null and b/data/sprites/official/clyde.1.zspr differ diff --git a/data/sprites/official/cucco.1.zspr b/data/sprites/official/cucco.1.zspr new file mode 100644 index 0000000000..f237de4ab0 Binary files /dev/null and b/data/sprites/official/cucco.1.zspr differ diff --git a/data/sprites/official/drake.1.zspr b/data/sprites/official/drake.1.zspr new file mode 100644 index 0000000000..1be94a7567 Binary files /dev/null and b/data/sprites/official/drake.1.zspr differ diff --git a/data/sprites/official/ezlo.1.zspr b/data/sprites/official/ezlo.1.zspr new file mode 100644 index 0000000000..54596847db Binary files /dev/null and b/data/sprites/official/ezlo.1.zspr differ diff --git a/data/sprites/official/finny_bear.1.zspr b/data/sprites/official/finny_bear.1.zspr new file mode 100644 index 0000000000..9c3a530b10 Binary files /dev/null and b/data/sprites/official/finny_bear.1.zspr differ diff --git a/data/sprites/official/fish_floodgate.1.zspr b/data/sprites/official/fish_floodgate.1.zspr new file mode 100644 index 0000000000..86684e7d8e Binary files /dev/null and b/data/sprites/official/fish_floodgate.1.zspr differ diff --git a/data/sprites/official/frisk.1.zspr b/data/sprites/official/frisk.1.zspr new file mode 100644 index 0000000000..d521cae391 Binary files /dev/null and b/data/sprites/official/frisk.1.zspr differ diff --git a/data/sprites/official/gamer.1.zspr b/data/sprites/official/gamer.1.zspr new file mode 100644 index 0000000000..9f78d894f7 Binary files /dev/null and b/data/sprites/official/gamer.1.zspr differ diff --git a/data/sprites/official/garnet.1.zspr b/data/sprites/official/garnet.1.zspr new file mode 100644 index 0000000000..858497c76f Binary files /dev/null and b/data/sprites/official/garnet.1.zspr differ diff --git a/data/sprites/official/garomaster.1.zspr b/data/sprites/official/garomaster.1.zspr new file mode 100644 index 0000000000..65b9959d47 Binary files /dev/null and b/data/sprites/official/garomaster.1.zspr differ diff --git a/data/sprites/official/gobli.1.zspr b/data/sprites/official/gobli.1.zspr new file mode 100644 index 0000000000..51dd119269 Binary files /dev/null and b/data/sprites/official/gobli.1.zspr differ diff --git a/data/sprites/official/grandpoobear.1.zspr b/data/sprites/official/grandpoobear.2.zspr similarity index 99% rename from data/sprites/official/grandpoobear.1.zspr rename to data/sprites/official/grandpoobear.2.zspr index 857265f9ac..7266368034 100644 Binary files a/data/sprites/official/grandpoobear.1.zspr and b/data/sprites/official/grandpoobear.2.zspr differ diff --git a/data/sprites/official/hardhat_beetle.1.zspr b/data/sprites/official/hardhat_beetle.1.zspr new file mode 100644 index 0000000000..80b63af16f Binary files /dev/null and b/data/sprites/official/hardhat_beetle.1.zspr differ diff --git a/data/sprites/official/hello_kitty.1.zspr b/data/sprites/official/hello_kitty.1.zspr new file mode 100644 index 0000000000..a2f5df063a Binary files /dev/null and b/data/sprites/official/hello_kitty.1.zspr differ diff --git a/data/sprites/official/hint_tile.1.zspr b/data/sprites/official/hint_tile.1.zspr new file mode 100644 index 0000000000..9cfd7e90ce Binary files /dev/null and b/data/sprites/official/hint_tile.1.zspr differ diff --git a/data/sprites/official/ibazly.1.zspr b/data/sprites/official/ibazly.1.zspr new file mode 100644 index 0000000000..01114c9e01 Binary files /dev/null and b/data/sprites/official/ibazly.1.zspr differ diff --git a/data/sprites/official/informant_woman.1.zspr b/data/sprites/official/informant_woman.1.zspr new file mode 100644 index 0000000000..6465a0e9f3 Binary files /dev/null and b/data/sprites/official/informant_woman.1.zspr differ diff --git a/data/sprites/official/jason_frudnick.1.zspr b/data/sprites/official/jason_frudnick.1.zspr new file mode 100644 index 0000000000..2411759c2a Binary files /dev/null and b/data/sprites/official/jason_frudnick.1.zspr differ diff --git a/data/sprites/official/kenny_mccormick.1.zspr b/data/sprites/official/kenny_mccormick.1.zspr new file mode 100644 index 0000000000..c66a74a586 Binary files /dev/null and b/data/sprites/official/kenny_mccormick.1.zspr differ diff --git a/data/sprites/official/king_gothalion.1.zspr b/data/sprites/official/king_gothalion.1.zspr new file mode 100644 index 0000000000..65c73f04d4 Binary files /dev/null and b/data/sprites/official/king_gothalion.1.zspr differ diff --git a/data/sprites/official/lily.1.zspr b/data/sprites/official/lily.1.zspr new file mode 100644 index 0000000000..5cb5d2aa9a Binary files /dev/null and b/data/sprites/official/lily.1.zspr differ diff --git a/data/sprites/official/locke_merchant.1.zspr b/data/sprites/official/locke_merchant.1.zspr new file mode 100644 index 0000000000..bfd87c7da6 Binary files /dev/null and b/data/sprites/official/locke_merchant.1.zspr differ diff --git a/data/sprites/official/lucario.1.zspr b/data/sprites/official/lucario.1.zspr new file mode 100644 index 0000000000..44ce395e48 Binary files /dev/null and b/data/sprites/official/lucario.1.zspr differ diff --git a/data/sprites/official/marin.1.zspr b/data/sprites/official/marin.1.zspr new file mode 100644 index 0000000000..51c27bb698 Binary files /dev/null and b/data/sprites/official/marin.1.zspr differ diff --git a/data/sprites/official/mario_tanooki.1.zspr b/data/sprites/official/mario_tanooki.1.zspr new file mode 100644 index 0000000000..255350dd8c Binary files /dev/null and b/data/sprites/official/mario_tanooki.1.zspr differ diff --git a/data/sprites/official/medallions.1.zspr b/data/sprites/official/medallions.1.zspr new file mode 100644 index 0000000000..dc4b04d170 Binary files /dev/null and b/data/sprites/official/medallions.1.zspr differ diff --git a/data/sprites/official/medli.1.zspr b/data/sprites/official/medli.1.zspr new file mode 100644 index 0000000000..59284a366d Binary files /dev/null and b/data/sprites/official/medli.1.zspr differ diff --git a/data/sprites/official/mikejones.1.zspr b/data/sprites/official/mikejones.1.zspr new file mode 100644 index 0000000000..6b83b72cd8 Binary files /dev/null and b/data/sprites/official/mikejones.1.zspr differ diff --git a/data/sprites/official/minish_link.1.zspr b/data/sprites/official/minish_link.1.zspr new file mode 100644 index 0000000000..4b342c1acb Binary files /dev/null and b/data/sprites/official/minish_link.1.zspr differ diff --git a/data/sprites/official/moosh.1.zspr b/data/sprites/official/moosh.1.zspr new file mode 100644 index 0000000000..0a1e167ae2 Binary files /dev/null and b/data/sprites/official/moosh.1.zspr differ diff --git a/data/sprites/official/nia.1.zspr b/data/sprites/official/nia.1.zspr new file mode 100644 index 0000000000..5d01ba4bd8 Binary files /dev/null and b/data/sprites/official/nia.1.zspr differ diff --git a/data/sprites/official/paula.1.zspr b/data/sprites/official/paula.1.zspr new file mode 100644 index 0000000000..657752ea29 Binary files /dev/null and b/data/sprites/official/paula.1.zspr differ diff --git a/data/sprites/official/peach.1.zspr b/data/sprites/official/peach.1.zspr new file mode 100644 index 0000000000..7973f95299 Binary files /dev/null and b/data/sprites/official/peach.1.zspr differ diff --git a/data/sprites/official/pete.1.zspr b/data/sprites/official/pete.1.zspr new file mode 100644 index 0000000000..a3135615bb Binary files /dev/null and b/data/sprites/official/pete.1.zspr differ diff --git a/data/sprites/official/poppy.1.zspr b/data/sprites/official/poppy.1.zspr new file mode 100644 index 0000000000..80d4ca69ef Binary files /dev/null and b/data/sprites/official/poppy.1.zspr differ diff --git a/data/sprites/official/powerpuff_girl.1.zspr b/data/sprites/official/powerpuff_girl.1.zspr new file mode 100644 index 0000000000..fbf3c69467 Binary files /dev/null and b/data/sprites/official/powerpuff_girl.1.zspr differ diff --git a/data/sprites/official/pridelink.1.zspr b/data/sprites/official/pridelink.2.zspr similarity index 99% rename from data/sprites/official/pridelink.1.zspr rename to data/sprites/official/pridelink.2.zspr index 310a6b7565..662310133a 100644 Binary files a/data/sprites/official/pridelink.1.zspr and b/data/sprites/official/pridelink.2.zspr differ diff --git a/data/sprites/official/primm.1.zspr b/data/sprites/official/primm.1.zspr new file mode 100644 index 0000000000..e9ff2d0566 Binary files /dev/null and b/data/sprites/official/primm.1.zspr differ diff --git a/data/sprites/official/rick.1.zspr b/data/sprites/official/rick.1.zspr new file mode 100644 index 0000000000..93a163f669 Binary files /dev/null and b/data/sprites/official/rick.1.zspr differ diff --git a/data/sprites/official/rocko.1.zspr b/data/sprites/official/rocko.1.zspr new file mode 100644 index 0000000000..ab34f63576 Binary files /dev/null and b/data/sprites/official/rocko.1.zspr differ diff --git a/data/sprites/official/rottytops.1.zspr b/data/sprites/official/rottytops.1.zspr new file mode 100644 index 0000000000..d4007ffbd5 Binary files /dev/null and b/data/sprites/official/rottytops.1.zspr differ diff --git a/data/sprites/official/samus_classic.1.zspr b/data/sprites/official/samus_classic.1.zspr new file mode 100644 index 0000000000..6559e25ce6 Binary files /dev/null and b/data/sprites/official/samus_classic.1.zspr differ diff --git a/data/sprites/official/sevens1ns.1.zspr b/data/sprites/official/sevens1ns.1.zspr new file mode 100644 index 0000000000..d59a1b529f Binary files /dev/null and b/data/sprites/official/sevens1ns.1.zspr differ diff --git a/data/sprites/official/shadow.1.zspr b/data/sprites/official/shadow.1.zspr new file mode 100644 index 0000000000..fcd0d49b60 Binary files /dev/null and b/data/sprites/official/shadow.1.zspr differ diff --git a/data/sprites/official/solaire.1.zspr b/data/sprites/official/solaire.1.zspr new file mode 100644 index 0000000000..e216a7d922 Binary files /dev/null and b/data/sprites/official/solaire.1.zspr differ diff --git a/data/sprites/official/sora_kh1.1.zspr b/data/sprites/official/sora_kh1.1.zspr new file mode 100644 index 0000000000..e77c922d20 Binary files /dev/null and b/data/sprites/official/sora_kh1.1.zspr differ diff --git a/data/sprites/official/stalfos.1.zspr b/data/sprites/official/stalfos.1.zspr new file mode 100644 index 0000000000..d4787a3b03 Binary files /dev/null and b/data/sprites/official/stalfos.1.zspr differ diff --git a/data/sprites/official/stick_man.1.zspr b/data/sprites/official/stick_man.1.zspr new file mode 100644 index 0000000000..b891586f4b Binary files /dev/null and b/data/sprites/official/stick_man.1.zspr differ diff --git a/data/sprites/official/superbomb.1.zspr b/data/sprites/official/superbomb.1.zspr new file mode 100644 index 0000000000..1ed38ae3ec Binary files /dev/null and b/data/sprites/official/superbomb.1.zspr differ diff --git a/data/sprites/official/tetra.1.zspr b/data/sprites/official/tetra.1.zspr new file mode 100644 index 0000000000..77525f08a9 Binary files /dev/null and b/data/sprites/official/tetra.1.zspr differ diff --git a/data/sprites/official/toadette_captain.1.zspr b/data/sprites/official/toadette_captain.1.zspr new file mode 100644 index 0000000000..e69f74a71c Binary files /dev/null and b/data/sprites/official/toadette_captain.1.zspr differ diff --git a/data/sprites/official/two_faced.1.zspr b/data/sprites/official/two_faced.1.zspr new file mode 100644 index 0000000000..d504c321ad Binary files /dev/null and b/data/sprites/official/two_faced.1.zspr differ diff --git a/data/sprites/official/wario.1.zspr b/data/sprites/official/wario.1.zspr new file mode 100644 index 0000000000..f1a5aab774 Binary files /dev/null and b/data/sprites/official/wario.1.zspr differ diff --git a/data/sprites/official/yoshi.1.zspr b/data/sprites/official/yoshi.1.zspr new file mode 100644 index 0000000000..189ea3901d Binary files /dev/null and b/data/sprites/official/yoshi.1.zspr differ diff --git a/data/sprites/official/zebraunicorn.1.zspr b/data/sprites/official/zebraunicorn.1.zspr new file mode 100644 index 0000000000..c06130ff7a Binary files /dev/null and b/data/sprites/official/zebraunicorn.1.zspr differ