Exemplo n.º 1
0
def test_create_hints_item_joke(empty_patches, players_config):
    # Setup
    asset_id = 1000
    logbook_node, _, world_list = _create_world_list(asset_id, PickupIndex(50))

    patches = dataclasses.replace(
        empty_patches,
        hints={
            world_list.identifier_for_node(logbook_node):
            Hint(HintType.JOKE, None)
        })
    rng = MagicMock()
    namer = EchoesHintNamer({0: patches}, players_config)

    # Run
    result = hints.create_patches_hints({0: patches}, players_config,
                                        world_list, namer, rng)

    # Assert
    joke = "While walking, holding L makes you move faster."
    message = f"&push;&main-color=#45F731;{joke}&pop;"
    assert result[0]['strings'][0] == message
    assert result == [{
        'asset_id': asset_id,
        'strings': [message, '', message]
    }]
Exemplo n.º 2
0
def test_create_hints_item_location(echoes_game_patches, blank_pickup, item,
                                    location, owner, is_multiworld,
                                    echoes_game_description, monkeypatch):
    # Setup
    asset_id = 1000
    pickup_index = PickupIndex(50)
    logbook_node, _, world_list = _create_world_list(asset_id, pickup_index)
    monkeypatch.setattr(echoes_game_description, "world_list", world_list)

    players_config = PlayersConfiguration(
        player_index=0,
        player_names={
            i: f"Player {i + 1}"
            for i in range(int(is_multiworld) + 1)
        },
    )
    location_precision, determiner, item_name = item
    if owner and is_multiworld:
        determiner = "&push;&main-color=#d4cc33;Player 1&pop;'s"

    patches = dataclasses.replace(
        echoes_game_patches,
        pickup_assignment={
            pickup_index: PickupTarget(blank_pickup, 0),
        },
        hints={
            world_list.identifier_for_node(logbook_node):
            Hint(
                HintType.LOCATION,
                PrecisionPair(location[0],
                              location_precision,
                              include_owner=owner),
                pickup_index,
            )
        })
    rng = MagicMock()
    namer = EchoesHintNamer({0: patches}, players_config)

    # Run
    result = hints.create_patches_hints({0: patches}, players_config,
                                        world_list, namer, rng)

    # Assert
    message = "{} {} can be found in {}.".format(determiner, item_name,
                                                 location[1])
    # message = "The Flying Ing Cache in {} contains {}.".format(location[1], item[1])
    assert result[0]['strings'][0] == message
    assert result == [{
        'asset_id': asset_id,
        'strings': [message, '', message]
    }]
Exemplo n.º 3
0
def _create_string_patches(
    hint_config: HintConfiguration,
    game: GameDescription,
    all_patches: dict[int, GamePatches],
    namer: EchoesHintNamer,
    players_config: PlayersConfiguration,
    rng: Random,
) -> list:
    """

    :param hint_config:
    :param game:
    :param all_patches:
    :return:
    """
    patches = all_patches[players_config.player_index]
    string_patches = []

    string_patches.extend(_akul_testament_string_patch(namer))

    # Location Hints
    string_patches.extend(
        hints.create_patches_hints(all_patches, players_config,
                                   game.world_list, namer, rng))

    # Sky Temple Keys
    stk_mode = hint_config.sky_temple_keys
    if stk_mode == SkyTempleKeyHintMode.DISABLED:
        string_patches.extend(
            randovania.games.prime2.exporter.hints.hide_stk_hints(namer))
    else:
        string_patches.extend(
            randovania.games.prime2.exporter.hints.create_stk_hints(
                all_patches,
                players_config,
                game.resource_database,
                namer,
                stk_mode == SkyTempleKeyHintMode.HIDE_AREA,
            ))

    # Elevator Scans
    string_patches.extend(
        _create_elevator_scan_port_patches(game.game, game.world_list,
                                           patches.elevator_connection))

    string_patches.extend(_logbook_title_string_patches())

    return string_patches
Exemplo n.º 4
0
def test_create_hints_light_suit_location(echoes_game_patches, players_config,
                                          blank_pickup, item,
                                          echoes_game_description,
                                          monkeypatch):
    # Setup
    asset_id = 1000
    pickup_index = PickupIndex(50)

    logbook_node, _, world_list = _create_world_list(asset_id, pickup_index)
    monkeypatch.setattr(echoes_game_description, "world_list", world_list)

    patches = dataclasses.replace(
        echoes_game_patches,
        pickup_assignment={
            pickup_index: PickupTarget(blank_pickup, 0),
        },
        hints={
            world_list.identifier_for_node(logbook_node):
            Hint(
                HintType.LOCATION,
                PrecisionPair(HintLocationPrecision.LIGHT_SUIT_LOCATION,
                              item[0],
                              include_owner=False),
                pickup_index,
            )
        })
    rng = MagicMock()
    namer = EchoesHintNamer({0: patches}, players_config)

    # Run
    result = hints.create_patches_hints({0: patches}, players_config,
                                        world_list, namer, rng)

    # Assert
    message = f"U-Mos's reward for returning the Sanctuary energy is {item[1]}."
    assert result == [{
        'asset_id': asset_id,
        'strings': [message, '', message]
    }]
Exemplo n.º 5
0
def test_create_hints_guardians(echoes_game_patches, pickup_index_and_guardian,
                                blank_pickup, item, players_config,
                                echoes_game_description, monkeypatch):
    # Setup
    asset_id = 1000
    pickup_index, guardian = pickup_index_and_guardian

    logbook_node, _, world_list = _create_world_list(asset_id, pickup_index)
    monkeypatch.setattr(echoes_game_description, "world_list", world_list)

    patches = dataclasses.replace(
        echoes_game_patches,
        pickup_assignment={
            pickup_index: PickupTarget(blank_pickup, 0),
        },
        hints={
            world_list.identifier_for_node(logbook_node):
            Hint(
                HintType.LOCATION,
                PrecisionPair(HintLocationPrecision.GUARDIAN,
                              item[0],
                              include_owner=False),
                pickup_index,
            )
        })
    rng = MagicMock()
    namer = EchoesHintNamer({0: patches}, players_config)

    # Run
    result = hints.create_patches_hints({0: patches}, players_config,
                                        world_list, namer, rng)

    # Assert
    message = f"{guardian} is guarding {item[1]}."
    assert result == [{
        'asset_id': asset_id,
        'strings': [message, '', message]
    }]
Exemplo n.º 6
0
def test_create_hints_nothing(echoes_game_patches, players_config, monkeypatch,
                              echoes_game_description):
    # Setup
    asset_id = 1000
    pickup_index = PickupIndex(0)

    logbook_node, _, world_list = _create_world_list(asset_id, pickup_index)
    monkeypatch.setattr(echoes_game_description, "world_list", world_list)

    patches = dataclasses.replace(
        echoes_game_patches,
        hints={
            world_list.identifier_for_node(logbook_node):
            Hint(
                HintType.LOCATION,
                PrecisionPair(HintLocationPrecision.DETAILED,
                              HintItemPrecision.DETAILED,
                              include_owner=False),
                pickup_index,
            )
        })
    rng = MagicMock()
    namer = EchoesHintNamer({0: patches}, players_config)

    # Run
    result = hints.create_patches_hints({0: patches}, players_config,
                                        world_list, namer, rng)

    # Assert
    message = (
        "The &push;&main-color=#FF6705B3;Energy Transfer Module&pop; can be found in "
        "&push;&main-color=#FF3333;World - Area&pop;.")
    assert result == [{
        'asset_id': asset_id,
        'strings': [message, '', message]
    }]