Пример #1
0
def test_try_randomize_elevators(seed_number: int, expected_ids: List[int],
                                 echoes_game_description):
    # Setup
    rng = Random(seed_number)
    teleporters = [
        echoes_game_description.world_list.identifier_for_node(node)
        for world in echoes_game_description.world_list.worlds
        for area in world.areas for node in area.nodes
        if isinstance(node, TeleporterNode) and node.editable
        and node.extra["teleporter_instance_id"] in expected_ids
    ]
    teleporters.sort()

    # Run
    result = elevator_distributor.try_randomize_elevators(
        rng,
        elevator_distributor.create_elevator_database(
            echoes_game_description.world_list, teleporters))

    connected_ids = [
        echoes_game_description.world_list.node_by_identifier(
            elevator.connected_elevator.teleporter).
        extra["teleporter_instance_id"] for elevator in result
    ]

    # Assert
    assert connected_ids == expected_ids
Пример #2
0
    def add_elevator_connections_to_patches(self, configuration: EchoesConfiguration, rng: Random,
                                            patches: GamePatches) -> GamePatches:
        elevator_connection = copy.copy(patches.elevator_connection)
        elevators = configuration.elevators

        if not elevators.is_vanilla:
            if rng is None:
                raise MissingRng("Elevator")

            world_list = filtered_database.game_description_for_layout(configuration).world_list
            elevator_db = elevator_distributor.create_elevator_database(
                world_list, elevators.editable_teleporters)

            if elevators.mode in {TeleporterShuffleMode.TWO_WAY_RANDOMIZED, TeleporterShuffleMode.TWO_WAY_UNCHECKED}:
                connections = elevator_distributor.two_way_elevator_connections(
                    rng=rng,
                    elevator_database=elevator_db,
                    between_areas=elevators.mode == TeleporterShuffleMode.TWO_WAY_RANDOMIZED
                )
            else:
                connections = elevator_distributor.one_way_elevator_connections(
                    rng=rng,
                    elevator_database=elevator_db,
                    target_locations=elevators.valid_targets,
                    replacement=elevators.mode != TeleporterShuffleMode.ONE_WAY_ELEVATOR,
                )

            elevator_connection.update(connections)

        for teleporter, destination in elevators.static_teleporters.items():
            elevator_connection[teleporter] = destination

        return dataclasses.replace(patches, elevator_connection=elevator_connection)
Пример #3
0
def add_elevator_connections_to_patches(
        layout_configuration: EchoesConfiguration, rng: Random,
        patches: GamePatches) -> GamePatches:
    """
    :param layout_configuration:
    :param rng:
    :param patches:
    :return:
    """
    elevator_connection = copy.copy(patches.elevator_connection)

    if layout_configuration.elevators != LayoutElevators.VANILLA:
        if rng is None:
            raise MissingRng("Elevator")

        world_list = data_reader.decode_data(
            layout_configuration.game_data).world_list
        areas_to_not_change = {
            2278776548,  # Sky Temple Gateway
            2068511343,  # Sky Temple Energy Controller
            3136899603,  # Aerie Transport Station
            1564082177,  # Aerie
        }

        elevator_db = elevator_distributor.create_elevator_database(
            world_list, areas_to_not_change)

        if layout_configuration.elevators in {
                LayoutElevators.TWO_WAY_RANDOMIZED,
                LayoutElevators.TWO_WAY_UNCHECKED
        }:
            connections = elevator_distributor.two_way_elevator_connections(
                rng=rng,
                elevator_database=elevator_db,
                between_areas=layout_configuration.elevators ==
                LayoutElevators.TWO_WAY_RANDOMIZED)
        else:
            connections = elevator_distributor.one_way_elevator_connections(
                rng=rng,
                elevator_database=elevator_db,
                world_list=world_list,
                elevator_target=layout_configuration.elevators !=
                LayoutElevators.ONE_WAY_ANYTHING,
                replacement=layout_configuration.elevators ==
                LayoutElevators.ONE_WAY_ELEVATOR_REPLACEMENT,
            )

        elevator_connection.update(connections)

    if layout_configuration.skip_final_bosses:
        elevator_connection[136970379] = AreaLocation(1006255871, 1393588666)

    return dataclasses.replace(patches,
                               elevator_connection=elevator_connection)
Пример #4
0
def add_elevator_connections_to_patches(
        layout_configuration: LayoutConfiguration, rng: Random,
        patches: GamePatches) -> GamePatches:
    """
    :param layout_configuration:
    :param rng:
    :param patches:
    :return:
    """
    if layout_configuration.elevators != LayoutElevators.VANILLA:
        if rng is None:
            raise MissingRng("Elevator")

        world_list = default_database.default_prime2_game_description(
        ).world_list
        areas_to_not_change = {
            2278776548,  # Sky Temple Gateway
            2068511343,  # Sky Temple Energy Controller
            3136899603,  # Aerie Transport Station
            1564082177,  # Aerie
        }

        elevator_db = elevator_distributor.create_elevator_database(
            world_list, areas_to_not_change)

        if layout_configuration.elevators in {
                LayoutElevators.TWO_WAY_RANDOMIZED,
                LayoutElevators.TWO_WAY_UNCHECKED
        }:
            connections = elevator_distributor.two_way_elevator_connections(
                rng=rng,
                elevator_database=elevator_db,
                between_areas=layout_configuration.elevators ==
                LayoutElevators.TWO_WAY_RANDOMIZED)
        else:
            connections = elevator_distributor.one_way_elevator_connections(
                rng=rng,
                elevator_database=elevator_db,
                world_list=world_list,
                elevator_target=layout_configuration.elevators ==
                LayoutElevators.ONE_WAY_ELEVATOR)

        elevator_connection = copy.copy(patches.elevator_connection)
        elevator_connection.update(connections)
        return dataclasses.replace(patches,
                                   elevator_connection=elevator_connection)
    else:
        return patches
Пример #5
0
def test_try_randomize_elevators(seed_number: int, expected_ids: List[int],
                                 echoes_game_description):
    # Setup
    rng = Random(seed_number)

    # Run
    result = elevator_distributor.try_randomize_elevators(
        rng,
        elevator_distributor.create_elevator_database(
            echoes_game_description.world_list, set()))
    connected_ids = [
        elevator.connected_elevator.instance_id for elevator in result
    ]

    # Assert
    assert connected_ids == expected_ids