def roll_settings(weights): ret = argparse.Namespace() if "linked_options" in weights: weights = weights.copy() # make sure we don't write back to other weights sets in same_settings for option_set in weights["linked_options"]: if random.random() < (option_set["percentage"] / 100): weights.update(option_set["options"]) ret.name = get_choice('name', weights) if ret.name: ret.name = handle_name(ret.name) glitches_required = get_choice('glitches_required', weights) if glitches_required not in ['none', 'no_logic', 'overworld_glitches', 'minor_glitches']: logging.warning("Only NMG, OWG and No Logic supported") glitches_required = 'none' ret.logic = {None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', 'minor_glitches' : 'minorglitches'}[ glitches_required] ret.progression_balancing = get_choice('progression_balancing', weights, True) # item_placement = get_choice('item_placement') # not supported in ER dungeon_items = get_choice('dungeon_items', weights) if dungeon_items == 'full' or dungeon_items == True: dungeon_items = 'mcsb' elif dungeon_items == 'standard': dungeon_items = "" elif not dungeon_items: dungeon_items = "" ret.mapshuffle = get_choice('map_shuffle', weights, 'm' in dungeon_items) ret.compassshuffle = get_choice('compass_shuffle', weights, 'c' in dungeon_items) ret.keyshuffle = get_choice('smallkey_shuffle', weights, 's' in dungeon_items) ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights, 'b' in dungeon_items) ret.accessibility = get_choice('accessibility', weights) entrance_shuffle = get_choice('entrance_shuffle', weights) ret.shuffle = entrance_shuffle if entrance_shuffle != 'none' else 'vanilla' goal = get_choice('goals', weights) ret.goal = {'ganon': 'ganon', 'fast_ganon': 'crystals', 'dungeons': 'dungeons', 'pedestal': 'pedestal', 'triforce_hunt': 'triforcehunt', 'triforce-hunt': 'triforcehunt', # deprecated, moving all goals to `_` 'local_triforce_hunt': 'localtriforcehunt', 'ganon_triforce_hunt': 'ganontriforcehunt', 'local_ganon_triforce_hunt': 'localganontriforcehunt' }[goal] ret.openpyramid = goal in ['fast_ganon', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt'] ret.crystals_gt = get_choice('tower_open', weights) ret.crystals_ganon = get_choice('ganon_open', weights) ret.triforce_pieces_available = get_choice('triforce_pieces_available', weights, 30) ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 90) ret.triforce_pieces_required = get_choice('triforce_pieces_required', weights, 20) ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 90) ret.mode = get_choice('world_state', weights) if ret.mode == 'retro': ret.mode = 'open' ret.retro = True ret.hints = get_choice('hints', weights) ret.swords = {'randomized': 'random', 'assured': 'assured', 'vanilla': 'vanilla', 'swordless': 'swordless' }[get_choice('weapons', weights)] ret.difficulty = get_choice('item_pool', weights) ret.item_functionality = get_choice('item_functionality', weights) ret.shufflebosses = {'none': 'none', 'simple': 'basic', 'full': 'normal', 'random': 'chaos' }[get_choice('boss_shuffle', weights)] ret.shuffleenemies = {'none': 'none', 'shuffled': 'shuffled', 'random': 'chaos', 'chaosthieves': 'chaosthieves', 'chaos': 'chaos' }[get_choice('enemy_shuffle', weights)] ret.enemy_damage = {'default': 'default', 'shuffled': 'shuffled', 'random': 'chaos' }[get_choice('enemy_damage', weights)] ret.enemy_health = get_choice('enemy_health', weights) ret.shufflepots = get_choice('pot_shuffle', weights) ret.beemizer = int(get_choice('beemizer', weights, 0)) ret.timer = {'none': False, None: False, False: False, 'timed': 'timed', 'timed_ohko': 'timed-ohko', 'ohko': 'ohko', 'timed_countdown': 'timed-countdown', 'display': 'display'}[get_choice('timer', weights, False)] ret.dungeon_counters = get_choice('dungeon_counters', weights, 'default') ret.progressive = convert_to_on_off(get_choice('progressive', weights, 'on')) inventoryweights = weights.get('startinventory', {}) startitems = [] for item in inventoryweights.keys(): itemvalue = get_choice(item, inventoryweights) if item.startswith(('Progressive ', 'Small Key ', 'Rupee', 'Piece of Heart', 'Boss Heart Container', 'Sanctuary Heart Container', 'Arrow', 'Bombs ', 'Bomb ', 'Bottle')) and isinstance( itemvalue, int): for i in range(int(itemvalue)): startitems.append(item) elif itemvalue: startitems.append(item) ret.startinventory = ','.join(startitems) ret.glitch_boots = get_choice('glitch_boots', weights, True) ret.remote_items = get_choice('remote_items', weights, False) if get_choice("local_keys", weights, "l" in dungeon_items): ret.local_items = item_name_groups["Small Keys"] | item_name_groups["Big Keys"] else: ret.local_items = set() for item_name in weights.get('local_items', []): items = item_name_groups.get(item_name, {item_name}) for item in items: if item in item_table: ret.local_items.add(item) else: raise Exception(f"Could not force item {item} to be world-local, as it was not recognized.") ret.local_items = ",".join(ret.local_items) if 'rom' in weights: romweights = weights['rom'] ret.sprite = get_choice('sprite', romweights) ret.disablemusic = get_choice('disablemusic', romweights) ret.quickswap = get_choice('quickswap', romweights) ret.fastmenu = get_choice('menuspeed', romweights) ret.heartcolor = get_choice('heartcolor', romweights) ret.heartbeep = convert_to_on_off(get_choice('heartbeep', romweights)) ret.ow_palettes = get_choice('ow_palettes', romweights) ret.uw_palettes = get_choice('uw_palettes', romweights) return ret
def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("bosses"))): if "pre_rolled" in weights: pre_rolled = weights["pre_rolled"] if "plando_items" in pre_rolled: pre_rolled["plando_items"] = [ PlandoItem(item["item"], item["location"], item["world"], item["from_pool"], item["force"]) for item in pre_rolled["plando_items"] ] if "items" not in plando_options and pre_rolled["plando_items"]: raise Exception( "Item Plando is turned off. Reusing this pre-rolled setting not permitted." ) if "plando_connections" in pre_rolled: pre_rolled["plando_connections"] = [ PlandoConnection(connection["entrance"], connection["exit"], connection["direction"]) for connection in pre_rolled["plando_connections"] ] if "connections" not in plando_options and pre_rolled[ "plando_connections"]: raise Exception( "Connection Plando is turned off. Reusing this pre-rolled setting not permitted." ) if "bosses" not in plando_options: try: pre_rolled["shufflebosses"] = get_plando_bosses( pre_rolled["shufflebosses"], plando_options) except Exception as ex: raise Exception( "Boss Plando is turned off. Reusing this pre-rolled setting not permitted." ) from ex if pre_rolled.get("plando_texts") and "texts" not in plando_options: raise Exception( "Text Plando is turned off. Reusing this pre-rolled setting not permitted." ) return argparse.Namespace(**pre_rolled) if "linked_options" in weights: weights = roll_linked_options(weights) if "triggers" in weights: weights = roll_triggers(weights) ret = argparse.Namespace() ret.name = get_choice('name', weights) glitches_required = get_choice('glitches_required', weights) if glitches_required not in [ None, 'none', 'no_logic', 'overworld_glitches', 'minor_glitches' ]: logging.warning("Only NMG, OWG and No Logic supported") glitches_required = 'none' ret.logic = { None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', 'minor_glitches': 'minorglitches' }[glitches_required] ret.dark_room_logic = get_choice("dark_room_logic", weights, "lamp") if not ret.dark_room_logic: # None/False ret.dark_room_logic = "none" if ret.dark_room_logic == "sconces": ret.dark_room_logic = "torches" if ret.dark_room_logic not in {"lamp", "torches", "none"}: raise ValueError(f"Unknown Dark Room Logic: \"{ret.dark_room_logic}\"") ret.restrict_dungeon_item_on_boss = get_choice( 'restrict_dungeon_item_on_boss', weights, False) ret.progression_balancing = get_choice('progression_balancing', weights, True) # item_placement = get_choice('item_placement') # not supported in ER dungeon_items = get_choice('dungeon_items', weights) if dungeon_items == 'full' or dungeon_items == True: dungeon_items = 'mcsb' elif dungeon_items == 'standard': dungeon_items = "" elif not dungeon_items: dungeon_items = "" if "u" in dungeon_items: dungeon_items.replace("s", "") ret.mapshuffle = get_choice('map_shuffle', weights, 'm' in dungeon_items) ret.compassshuffle = get_choice('compass_shuffle', weights, 'c' in dungeon_items) ret.keyshuffle = get_choice( 'smallkey_shuffle', weights, 'universal' if 'u' in dungeon_items else 's' in dungeon_items) ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights, 'b' in dungeon_items) ret.accessibility = get_choice('accessibility', weights) entrance_shuffle = get_choice('entrance_shuffle', weights, 'vanilla') if entrance_shuffle.startswith('none-'): ret.shuffle = 'vanilla' else: ret.shuffle = entrance_shuffle if entrance_shuffle != 'none' else 'vanilla' goal = get_choice('goals', weights, 'ganon') ret.goal = { 'ganon': 'ganon', 'fast_ganon': 'crystals', 'dungeons': 'dungeons', 'pedestal': 'pedestal', 'ganon_pedestal': 'ganonpedestal', 'triforce_hunt': 'triforcehunt', 'triforce-hunt': 'triforcehunt', # deprecated, moving all goals to `_` 'local_triforce_hunt': 'localtriforcehunt', 'ganon_triforce_hunt': 'ganontriforcehunt', 'local_ganon_triforce_hunt': 'localganontriforcehunt', 'ice_rod_hunt': 'icerodhunt' }[goal] # TODO consider moving open_pyramid to an automatic variable in the core roller, set to True when # fast ganon + ganon at hole ret.open_pyramid = get_choice('open_pyramid', weights, 'goal') ret.crystals_gt = prefer_int(get_choice('tower_open', weights)) ret.crystals_ganon = prefer_int(get_choice('ganon_open', weights)) extra_pieces = get_choice('triforce_pieces_mode', weights, 'available') ret.triforce_pieces_required = int( get_choice('triforce_pieces_required', weights, 20)) ret.triforce_pieces_required = min( max(1, int(ret.triforce_pieces_required)), 90) # sum a percentage to required if extra_pieces == 'percentage': percentage = max( 100, float(get_choice('triforce_pieces_percentage', weights, 150))) / 100 ret.triforce_pieces_available = int( round(ret.triforce_pieces_required * percentage, 0)) # vanilla mode (specify how many pieces are) elif extra_pieces == 'available': ret.triforce_pieces_available = int( get_choice('triforce_pieces_available', weights, 30)) # required pieces + fixed extra elif extra_pieces == 'extra': extra_pieces = max( 0, int(get_choice('triforce_pieces_extra', weights, 10))) ret.triforce_pieces_available = ret.triforce_pieces_required + extra_pieces # change minimum to required pieces to avoid problems ret.triforce_pieces_available = min( max(ret.triforce_pieces_required, int(ret.triforce_pieces_available)), 90) shuffle_slots = get_choice('shop_shuffle_slots', weights, '0') if str(shuffle_slots).lower() == "random": ret.shop_shuffle_slots = random.randint(0, 30) else: ret.shop_shuffle_slots = int(shuffle_slots) ret.shop_shuffle = get_choice('shop_shuffle', weights, '') if not ret.shop_shuffle: ret.shop_shuffle = '' ret.mode = get_choice('world_state', weights, None) # legacy support if ret.mode == 'retro': ret.mode = 'open' ret.retro = True elif ret.mode is None: ret.mode = get_choice("mode", weights) ret.retro = get_choice("retro", weights) ret.hints = get_choice('hints', weights) ret.swords = { 'randomized': 'random', 'assured': 'assured', 'vanilla': 'vanilla', 'swordless': 'swordless' }[get_choice('weapons', weights, 'assured')] ret.difficulty = get_choice('item_pool', weights) ret.item_functionality = get_choice('item_functionality', weights) boss_shuffle = get_choice('boss_shuffle', weights) ret.shufflebosses = get_plando_bosses(boss_shuffle, plando_options) ret.enemy_shuffle = { 'none': False, 'shuffled': 'shuffled', 'random': 'chaos', 'chaosthieves': 'chaosthieves', 'chaos': 'chaos', True: True, False: False, None: False }[get_choice('enemy_shuffle', weights, False)] ret.killable_thieves = get_choice('killable_thieves', weights, False) ret.tile_shuffle = get_choice('tile_shuffle', weights, False) ret.bush_shuffle = get_choice('bush_shuffle', weights, False) # legacy support for enemy shuffle if type(ret.enemy_shuffle) == str: if ret.enemy_shuffle == 'shuffled': ret.killable_thieves = True elif ret.enemy_shuffle == 'chaos': ret.killable_thieves = True ret.bush_shuffle = True ret.tile_shuffle = True elif ret.enemy_shuffle == "chaosthieves": ret.killable_thieves = bool(random.randint(0, 1)) ret.bush_shuffle = True ret.tile_shuffle = True ret.enemy_shuffle = True # end of legacy block ret.enemy_damage = { None: 'default', 'default': 'default', 'shuffled': 'shuffled', 'random': 'chaos' }[get_choice('enemy_damage', weights)] ret.enemy_health = get_choice('enemy_health', weights) ret.shufflepots = get_choice('pot_shuffle', weights) ret.beemizer = int(get_choice('beemizer', weights, 0)) ret.timer = { 'none': False, None: False, False: False, 'timed': 'timed', 'timed_ohko': 'timed-ohko', 'ohko': 'ohko', 'timed_countdown': 'timed-countdown', 'display': 'display' }[get_choice('timer', weights, False)] ret.countdown_start_time = int( get_choice('countdown_start_time', weights, 10)) ret.red_clock_time = int(get_choice('red_clock_time', weights, -2)) ret.blue_clock_time = int(get_choice('blue_clock_time', weights, 2)) ret.green_clock_time = int(get_choice('green_clock_time', weights, 4)) ret.dungeon_counters = get_choice('dungeon_counters', weights, 'default') ret.progressive = convert_to_on_off( get_choice('progressive', weights, 'on')) ret.shuffle_prizes = get_choice('shuffle_prizes', weights, "g") ret.required_medallions = [ get_choice("misery_mire_medallion", weights, "random"), get_choice("turtle_rock_medallion", weights, "random") ] for index, medallion in enumerate(ret.required_medallions): ret.required_medallions[index] = {"ether": "Ether", "quake": "Quake", "bombos": "Bombos", "random": "random"}\ .get(medallion.lower(), None) if not ret.required_medallions[index]: raise Exception( f"unknown Medallion {medallion} for {'misery mire' if index == 0 else 'turtle rock'}" ) inventoryweights = weights.get('startinventory', {}) startitems = [] for item in inventoryweights.keys(): itemvalue = get_choice(item, inventoryweights) if item.startswith( ('Progressive ', 'Small Key ', 'Rupee', 'Piece of Heart', 'Boss Heart Container', 'Sanctuary Heart Container', 'Arrow', 'Bombs ', 'Bomb ', 'Bottle')) and isinstance(itemvalue, int): for i in range(int(itemvalue)): startitems.append(item) elif itemvalue: startitems.append(item) ret.startinventory = ','.join(startitems) ret.glitch_boots = get_choice('glitch_boots', weights, True) ret.remote_items = get_choice('remote_items', weights, False) if get_choice("local_keys", weights, "l" in dungeon_items): # () important for ordering of commands, without them the Big Keys section is part of the Small Key else ret.local_items = (item_name_groups["Small Keys"] if ret.keyshuffle else set()) \ | item_name_groups["Big Keys"] if ret.bigkeyshuffle else set() else: ret.local_items = set() for item_name in weights.get('local_items', []): items = item_name_groups.get(item_name, {item_name}) for item in items: if item in item_table: ret.local_items.add(item) else: raise Exception( f"Could not force item {item} to be world-local, as it was not recognized." ) ret.local_items = ",".join(ret.local_items) ret.non_local_items = set() for item_name in weights.get('non_local_items', []): items = item_name_groups.get(item_name, {item_name}) for item in items: if item in item_table: ret.non_local_items.add(item) else: raise Exception( f"Could not force item {item} to be world-non-local, as it was not recognized." ) ret.non_local_items = ",".join(ret.non_local_items) ret.plando_items = [] if "items" in plando_options: def add_plando_item(item: str, location: str): if item not in item_table: raise Exception( f"Could not plando item {item} as the item was not recognized" ) if location not in location_table and location not in key_drop_data: raise Exception( f"Could not plando item {item} at location {location} as the location was not recognized" ) ret.plando_items.append( PlandoItem(item, location, location_world, from_pool, force)) options = weights.get("plando_items", []) for placement in options: if roll_percentage(get_choice("percentage", placement, 100)): from_pool = get_choice("from_pool", placement, PlandoItem._field_defaults["from_pool"]) location_world = get_choice( "world", placement, PlandoItem._field_defaults["world"]) force = str( get_choice("force", placement, PlandoItem._field_defaults["force"])).lower() if "items" in placement and "locations" in placement: items = placement["items"] locations = placement["locations"] if isinstance(items, dict): item_list = [] for key, value in items.items(): item_list += [key] * value items = item_list if not items or not locations: raise Exception( "You must specify at least one item and one location to place items." ) random.shuffle(items) random.shuffle(locations) for item, location in zip(items, locations): add_plando_item(item, location) else: item = get_choice("item", placement, get_choice("items", placement)) location = get_choice("location", placement) add_plando_item(item, location) ret.plando_texts = {} if "texts" in plando_options: tt = TextTable() tt.removeUnwantedText() options = weights.get("plando_texts", []) for placement in options: if roll_percentage(get_choice("percentage", placement, 100)): at = str(get_choice("at", placement)) if at not in tt: raise Exception(f"No text target \"{at}\" found.") ret.plando_texts[at] = str(get_choice("text", placement)) ret.plando_connections = [] if "connections" in plando_options: options = weights.get("plando_connections", []) for placement in options: if roll_percentage(get_choice("percentage", placement, 100)): ret.plando_connections.append( PlandoConnection( get_choice("entrance", placement), get_choice("exit", placement), get_choice("direction", placement, "both"))) if 'rom' in weights: romweights = weights['rom'] ret.sprite_pool = romweights[ 'sprite_pool'] if 'sprite_pool' in romweights else [] ret.sprite = get_choice('sprite', romweights, "Link") if 'random_sprite_on_event' in romweights: randomoneventweights = romweights['random_sprite_on_event'] if get_choice('enabled', randomoneventweights, False): ret.sprite = 'randomon' ret.sprite += '-hit' if get_choice( 'on_hit', randomoneventweights, True) else '' ret.sprite += '-enter' if get_choice( 'on_enter', randomoneventweights, False) else '' ret.sprite += '-exit' if get_choice( 'on_exit', randomoneventweights, False) else '' ret.sprite += '-slash' if get_choice( 'on_slash', randomoneventweights, False) else '' ret.sprite += '-item' if get_choice( 'on_item', randomoneventweights, False) else '' ret.sprite += '-bonk' if get_choice( 'on_bonk', randomoneventweights, False) else '' ret.sprite = 'randomonall' if get_choice( 'on_everything', randomoneventweights, False) else ret.sprite ret.sprite = 'randomonnone' if ret.sprite == 'randomon' else ret.sprite if (not ret.sprite_pool or get_choice('use_weighted_sprite_pool', randomoneventweights, False)) \ and 'sprite' in romweights: # Use sprite as a weighted sprite pool, if a sprite pool is not already defined. for key, value in romweights['sprite'].items(): if key.startswith('random'): ret.sprite_pool += ['random'] * int(value) else: ret.sprite_pool += [key] * int(value) ret.disablemusic = get_choice('disablemusic', romweights, False) ret.triforcehud = get_choice('triforcehud', romweights, 'hide_goal') ret.quickswap = get_choice('quickswap', romweights, True) ret.fastmenu = get_choice('menuspeed', romweights, "normal") ret.reduceflashing = get_choice('reduceflashing', romweights, False) ret.heartcolor = get_choice('heartcolor', romweights, "red") ret.heartbeep = convert_to_on_off( get_choice('heartbeep', romweights, "normal")) ret.ow_palettes = get_choice('ow_palettes', romweights, "default") ret.uw_palettes = get_choice('uw_palettes', romweights, "default") ret.hud_palettes = get_choice('hud_palettes', romweights, "default") ret.sword_palettes = get_choice('sword_palettes', romweights, "default") ret.shield_palettes = get_choice('shield_palettes', romweights, "default") ret.link_palettes = get_choice('link_palettes', romweights, "default") else: ret.quickswap = True ret.sprite = "Link" return ret
def roll_settings(weights): ret = argparse.Namespace() if "linked_options" in weights: weights = weights.copy( ) # make sure we don't write back to other weights sets in same_settings for option_set in weights["linked_options"]: if "name" not in option_set: raise ValueError( "One of your linked options does not have a name.") try: if random.random() < (float(option_set["percentage"]) / 100): weights.update(option_set["options"]) except Exception as e: raise ValueError( f"Linked option {option_set['name']} is destroyed. " f"Please fix your linked option.") from e ret.name = get_choice('name', weights) if ret.name: ret.name = handle_name(ret.name) glitches_required = get_choice('glitches_required', weights) if glitches_required not in [ None, 'none', 'no_logic', 'overworld_glitches', 'minor_glitches' ]: logging.warning("Only NMG, OWG and No Logic supported") glitches_required = 'none' ret.logic = { None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', 'minor_glitches': 'minorglitches' }[glitches_required] ret.dark_room_logic = get_choice("dark_room_logic", weights, "lamp") if not ret.dark_room_logic: # None/False ret.dark_room_logic = "none" if ret.dark_room_logic == "sconces": ret.dark_room_logic = "torches" if ret.dark_room_logic not in {"lamp", "torches", "none"}: raise ValueError(f"Unknown Dark Room Logic: \"{ret.dark_room_logic}\"") ret.restrict_dungeon_item_on_boss = get_choice( 'restrict_dungeon_item_on_boss', weights, False) ret.progression_balancing = get_choice('progression_balancing', weights, True) # item_placement = get_choice('item_placement') # not supported in ER dungeon_items = get_choice('dungeon_items', weights) if dungeon_items == 'full' or dungeon_items == True: dungeon_items = 'mcsb' elif dungeon_items == 'standard': dungeon_items = "" elif not dungeon_items: dungeon_items = "" if "u" in dungeon_items: dungeon_items.replace("s", "") ret.mapshuffle = get_choice('map_shuffle', weights, 'm' in dungeon_items) ret.compassshuffle = get_choice('compass_shuffle', weights, 'c' in dungeon_items) ret.keyshuffle = get_choice( 'smallkey_shuffle', weights, 'universal' if 'u' in dungeon_items else 's' in dungeon_items) ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights, 'b' in dungeon_items) ret.accessibility = get_choice('accessibility', weights) entrance_shuffle = get_choice('entrance_shuffle', weights) ret.shuffle = entrance_shuffle if entrance_shuffle != 'none' else 'vanilla' goal = get_choice('goals', weights, 'ganon') ret.goal = { 'ganon': 'ganon', 'fast_ganon': 'crystals', 'dungeons': 'dungeons', 'pedestal': 'pedestal', 'ganon_pedestal': 'ganonpedestal', 'triforce_hunt': 'triforcehunt', 'triforce-hunt': 'triforcehunt', # deprecated, moving all goals to `_` 'local_triforce_hunt': 'localtriforcehunt', 'ganon_triforce_hunt': 'ganontriforcehunt', 'local_ganon_triforce_hunt': 'localganontriforcehunt' }[goal] # TODO consider moving open_pyramid to an automatic variable in the core roller, set to True when # fast ganon + ganon at hole ret.open_pyramid = goal in { 'fast_ganon', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal' } ret.crystals_gt = prefer_int(get_choice('tower_open', weights)) ret.crystals_ganon = prefer_int(get_choice('ganon_open', weights)) extra_pieces = get_choice('triforce_pieces_mode', weights, 'available') ret.triforce_pieces_required = int( get_choice('triforce_pieces_required', weights, 20)) ret.triforce_pieces_required = min( max(1, int(ret.triforce_pieces_required)), 90) # sum a percentage to required if extra_pieces == 'percentage': percentage = max( 100, float(get_choice('triforce_pieces_percentage', weights, 150))) / 100 ret.triforce_pieces_available = int( round(ret.triforce_pieces_required * percentage, 0)) # vanilla mode (specify how many pieces are) elif extra_pieces == 'available': ret.triforce_pieces_available = int( get_choice('triforce_pieces_available', weights, 30)) # required pieces + fixed extra elif extra_pieces == 'extra': extra_pieces = max( 0, int(get_choice('triforce_pieces_extra', weights, 10))) ret.triforce_pieces_available = ret.triforce_pieces_required + extra_pieces # change minimum to required pieces to avoid problems ret.triforce_pieces_available = min( max(ret.triforce_pieces_required, int(ret.triforce_pieces_available)), 90) ret.shop_shuffle = get_choice('shop_shuffle', weights, '') if not ret.shop_shuffle: ret.shop_shuffle = '' ret.mode = get_choice('world_state', weights, None) # legacy support if ret.mode == 'retro': ret.mode = 'open' ret.retro = True elif ret.mode is None: ret.mode = get_choice("mode", weights) ret.retro = get_choice("retro", weights) ret.hints = get_choice('hints', weights) ret.swords = { 'randomized': 'random', 'assured': 'assured', 'vanilla': 'vanilla', 'swordless': 'swordless' }[get_choice('weapons', weights, 'assured')] ret.difficulty = get_choice('item_pool', weights) ret.item_functionality = get_choice('item_functionality', weights) ret.shufflebosses = { None: 'none', 'none': 'none', 'simple': 'basic', 'full': 'normal', 'random': 'chaos', 'singularity': 'singularity', 'duality': 'singularity' }[get_choice('boss_shuffle', weights)] ret.enemy_shuffle = { 'none': False, 'shuffled': 'shuffled', 'random': 'chaos', 'chaosthieves': 'chaosthieves', 'chaos': 'chaos', True: True, False: False, None: False }[get_choice('enemy_shuffle', weights, False)] ret.killable_thieves = get_choice('killable_thieves', weights, False) ret.tile_shuffle = get_choice('tile_shuffle', weights, False) ret.bush_shuffle = get_choice('bush_shuffle', weights, False) # legacy support for enemy shuffle if type(ret.enemy_shuffle) == str: if ret.enemy_shuffle == 'shuffled': ret.killable_thieves = True elif ret.enemy_shuffle == 'chaos': ret.killable_thieves = True ret.bush_shuffle = True ret.tile_shuffle = True elif ret.enemy_shuffle == "chaosthieves": ret.killable_thieves = bool(random.randint(0, 1)) ret.bush_shuffle = True ret.tile_shuffle = True ret.enemy_shuffle = True # end of legacy block ret.enemy_damage = { None: 'default', 'default': 'default', 'shuffled': 'shuffled', 'random': 'chaos' }[get_choice('enemy_damage', weights)] ret.enemy_health = get_choice('enemy_health', weights) ret.shufflepots = get_choice('pot_shuffle', weights) ret.beemizer = int(get_choice('beemizer', weights, 0)) ret.timer = { 'none': False, None: False, False: False, 'timed': 'timed', 'timed_ohko': 'timed-ohko', 'ohko': 'ohko', 'timed_countdown': 'timed-countdown', 'display': 'display' }[get_choice('timer', weights, False)] ret.countdown_start_time = int( get_choice('countdown_start_time', weights, 10)) ret.red_clock_time = int(get_choice('red_clock_time', weights, -2)) ret.blue_clock_time = int(get_choice('blue_clock_time', weights, 2)) ret.green_clock_time = int(get_choice('green_clock_time', weights, 4)) ret.dungeon_counters = get_choice('dungeon_counters', weights, 'default') ret.progressive = convert_to_on_off( get_choice('progressive', weights, 'on')) ret.shuffle_prizes = get_choice('shuffle_prizes', weights, "g") inventoryweights = weights.get('startinventory', {}) startitems = [] for item in inventoryweights.keys(): itemvalue = get_choice(item, inventoryweights) if item.startswith( ('Progressive ', 'Small Key ', 'Rupee', 'Piece of Heart', 'Boss Heart Container', 'Sanctuary Heart Container', 'Arrow', 'Bombs ', 'Bomb ', 'Bottle')) and isinstance(itemvalue, int): for i in range(int(itemvalue)): startitems.append(item) elif itemvalue: startitems.append(item) ret.startinventory = ','.join(startitems) ret.glitch_boots = get_choice('glitch_boots', weights, True) ret.remote_items = get_choice('remote_items', weights, False) if get_choice("local_keys", weights, "l" in dungeon_items): # () important for ordering of commands, without them the Big Keys section is part of the Small Key else ret.local_items = (item_name_groups["Small Keys"] if ret.keyshuffle else set()) \ | item_name_groups["Big Keys"] if ret.bigkeyshuffle else set() else: ret.local_items = set() for item_name in weights.get('local_items', []): items = item_name_groups.get(item_name, {item_name}) for item in items: if item in item_table: ret.local_items.add(item) else: raise Exception( f"Could not force item {item} to be world-local, as it was not recognized." ) ret.local_items = ",".join(ret.local_items) if 'rom' in weights: romweights = weights['rom'] ret.sprite_pool = romweights[ 'sprite_pool'] if 'sprite_pool' in romweights else [] ret.sprite = get_choice('sprite', romweights, "Link") if 'random_sprite_on_event' in romweights: randomoneventweights = romweights['random_sprite_on_event'] if get_choice('enabled', randomoneventweights, False): ret.sprite = 'randomon' ret.sprite += '-hit' if get_choice( 'on_hit', randomoneventweights, True) else '' ret.sprite += '-enter' if get_choice( 'on_enter', randomoneventweights, False) else '' ret.sprite += '-exit' if get_choice( 'on_exit', randomoneventweights, False) else '' ret.sprite += '-slash' if get_choice( 'on_slash', randomoneventweights, False) else '' ret.sprite += '-item' if get_choice( 'on_item', randomoneventweights, False) else '' ret.sprite += '-bonk' if get_choice( 'on_bonk', randomoneventweights, False) else '' ret.sprite = 'randomonall' if get_choice( 'on_everything', randomoneventweights, False) else ret.sprite ret.sprite = 'randomonnone' if ret.sprite == 'randomon' else ret.sprite if (not ret.sprite_pool or get_choice('use_weighted_sprite_pool', randomoneventweights, False)) \ and 'sprite' in romweights: # Use sprite as a weighted sprite pool, if a sprite pool is not already defined. for key, value in romweights['sprite'].items(): if key.startswith('random'): ret.sprite_pool += ['random'] * int(value) else: ret.sprite_pool += [key] * int(value) ret.disablemusic = get_choice('disablemusic', romweights, False) ret.quickswap = get_choice('quickswap', romweights, True) ret.fastmenu = get_choice('menuspeed', romweights, "normal") ret.heartcolor = get_choice('heartcolor', romweights, "red") ret.heartbeep = convert_to_on_off( get_choice('heartbeep', romweights, "normal")) ret.ow_palettes = get_choice('ow_palettes', romweights, "default") ret.uw_palettes = get_choice('uw_palettes', romweights, "default") ret.hud_palettes = get_choice('hud_palettes', romweights, "default") ret.sword_palettes = get_choice('sword_palettes', romweights, "default") ret.shield_palettes = get_choice('shield_palettes', romweights, "default") ret.link_palettes = get_choice('link_palettes', romweights, "default") else: ret.quickswap = True ret.sprite = "Link" return ret