Example #1
0
def write_world_list(world_list: WorldList) -> list:
    errors = []
    known_indices = {}

    worlds = []
    for world in world_list.worlds:
        try:
            worlds.append(write_world(world))

            for node in world.all_nodes:
                if isinstance(node, PickupNode):
                    name = world_list.node_name(node, with_world=True, distinguish_dark_aether=True)
                    if node.pickup_index in known_indices:
                        errors.append(f"{name} has {node.pickup_index}, "
                                      f"but it was already used in {known_indices[node.pickup_index]}")
                    else:
                        known_indices[node.pickup_index] = name

        except ValueError as e:
            errors.append(str(e))

    if errors:
        raise ValueError("\n\n".join(errors))

    return worlds
Example #2
0
def _pickup_assignment_to_item_locations(
    world_list: WorldList,
    pickup_assignment: PickupAssignment,
    num_players: int,
) -> Dict[str, Dict[str, str]]:
    items_locations: DefaultDict[str,
                                 Dict[str,
                                      str]] = collections.defaultdict(dict)

    for world, area, node in world_list.all_worlds_areas_nodes:
        if not node.is_resource_node or not isinstance(node, PickupNode):
            continue

        if node.pickup_index in pickup_assignment:
            target = pickup_assignment[node.pickup_index]
            if num_players > 1:
                item_name = f"{target.pickup.name} for Player {target.player + 1}"
            else:
                item_name = f"{target.pickup.name}"
        else:
            item_name = _ETM_NAME

        world_name = world.dark_name if area.in_dark_aether else world.name
        items_locations[world_name][world_list.node_name(node)] = item_name

    return {
        world:
        {area: item
         for area, item in sorted(items_locations[world].items())}
        for world in sorted(items_locations.keys())
    }
Example #3
0
def pretty_print_node_type(node: Node, world_list: WorldList):
    if isinstance(node, DockNode):
        try:
            other = world_list.node_by_identifier(node.default_connection)
            other_name = world_list.node_name(other)
        except IndexError as e:
            other_name = (f"(Area {node.default_connection.area_name}, "
                          f"index {node.default_connection.node_name}) [{e}]")

        return f"{node.default_dock_weakness.name} to {other_name}"

    elif isinstance(node, TeleporterNode):
        other = world_list.area_by_area_location(node.default_connection)
        return f"Teleporter to {world_list.area_name(other)}"

    elif isinstance(node, PickupNode):
        return f"Pickup {node.pickup_index.index}; Major Location? {node.major_location}"

    elif isinstance(node, EventNode):
        return f"Event {node.event.long_name}"

    elif isinstance(node, ConfigurableNode):
        return f"Configurable Node"

    elif isinstance(node, LogbookNode):
        message = ""
        if node.lore_type == LoreType.REQUIRES_ITEM:
            message = f" ({node.required_translator.long_name})"
        return f"Logbook {node.lore_type.long_name}{message} for {node.string_asset_id:x}"

    elif isinstance(node, PlayerShipNode):
        unlocked_pretty = list(pretty_print_requirement(node.is_unlocked))
        if len(unlocked_pretty) > 1:
            unlocked_by = "Complex requirement"
        else:
            unlocked_by = unlocked_pretty[0][1]
        return f"Player Ship (Unlocked by {unlocked_by})"

    return ""