Beispiel #1
0
def _sky_temple_key_distribution_logic(
    permalink: Permalink,
    previous_patches: GamePatches,
    available_pickups: List[PickupEntry],
) -> GamePatches:

    mode = permalink.layout_configuration.sky_temple_keys
    new_assignments = {}

    if mode == LayoutSkyTempleKeyMode.VANILLA:
        locations_to_place = _FLYING_ING_CACHES[:]

    elif mode == LayoutSkyTempleKeyMode.ALL_BOSSES or mode == LayoutSkyTempleKeyMode.ALL_GUARDIANS:
        locations_to_place = _GUARDIAN_INDICES[:]
        if mode == LayoutSkyTempleKeyMode.ALL_BOSSES:
            locations_to_place += _SUB_GUARDIAN_INDICES

    elif mode == LayoutSkyTempleKeyMode.FULLY_RANDOM:
        locations_to_place = []

    else:
        raise GenerationFailure("Unknown Sky Temple Key mode: {}".format(mode),
                                permalink)

    for pickup in available_pickups[:]:
        if not locations_to_place:
            break

        if pickup.item_category == "sky_temple_key":
            available_pickups.remove(pickup)
            index = locations_to_place.pop(0)
            if index in previous_patches.pickup_assignment:
                raise GenerationFailure(
                    "Attempted to place '{}' in {}, but there's already '{}' there"
                    .format(pickup, index,
                            previous_patches.pickup_assignment[index]),
                    permalink)
            new_assignments[index] = pickup

    if locations_to_place:
        raise GenerationFailure(
            "Missing Sky Temple Keys in available_pickups to place in all requested boss places",
            permalink)

    return previous_patches.assign_pickup_assignment(new_assignments)
Beispiel #2
0
def calculate_item_pool(
    layout_configuration: LayoutConfiguration,
    resource_database: ResourceDatabase,
    patches: GamePatches,
) -> Tuple[GamePatches, List[PickupEntry]]:
    """
    Creates a GamePatches with all starting items and pickups in fixed locations, as well as a list of
    pickups we should shuffle.
    :param layout_configuration:
    :param resource_database:
    :param patches:
    :return:
    """

    item_pool, pickup_assignment, initial_items = calculate_pool_results(
        layout_configuration, resource_database)
    new_patches = patches.assign_pickup_assignment(
        pickup_assignment).assign_extra_initial_items(initial_items)
    return new_patches, item_pool