Exemplo n.º 1
0
def test_create_message_for_hint_relative_area(echoes_game_patches,
                                               blank_pickup, players_config,
                                               echoes_hint_exporter, offset,
                                               distance_text):
    patches = echoes_game_patches.assign_new_pickups([
        (PickupIndex(5), PickupTarget(blank_pickup, 0)),
    ])

    hint = Hint(
        HintType.LOCATION,
        PrecisionPair(HintLocationPrecision.RELATIVE_TO_AREA,
                      HintItemPrecision.DETAILED,
                      include_owner=False,
                      relative=RelativeDataArea(
                          offset, AreaIdentifier("Torvus Bog", "Great Bridge"),
                          HintRelativeAreaName.NAME)), PickupIndex(5))

    namer = EchoesHintNamer({0: patches}, PlayersConfiguration(0, {0: "You"}))
    exporter = HintExporter(namer, random.Random(0), ["A Joke"])

    # Run
    result = exporter.create_message_for_hint(hint, {0: patches},
                                              players_config, True)

    # Assert
    assert result == (
        f'The &push;&main-color=#FF6705B3;Blank Pickup&pop; can be found '
        f'&push;&main-color=#FF3333;{distance_text} {10 + (offset or 0)} rooms&pop; away from '
        f'Torvus Bog - Great Bridge.')
Exemplo n.º 2
0
def test_create_message_for_hint_relative_item(echoes_game_patches,
                                               blank_pickup, players_config,
                                               distance_precise, distance_text,
                                               reference_precision,
                                               reference_name):
    patches = echoes_game_patches.assign_new_pickups([
        (PickupIndex(5), PickupTarget(blank_pickup, 0)),
        (PickupIndex(15),
         PickupTarget(
             dataclasses.replace(blank_pickup, name="Reference Pickup"), 0)),
    ])

    hint = Hint(
        HintType.LOCATION,
        PrecisionPair(HintLocationPrecision.RELATIVE_TO_INDEX,
                      HintItemPrecision.DETAILED,
                      include_owner=False,
                      relative=RelativeDataItem(distance_precise,
                                                PickupIndex(15),
                                                reference_precision)),
        PickupIndex(5))

    namer = EchoesHintNamer({0: patches}, PlayersConfiguration(0, {0: "You"}))
    exporter = HintExporter(namer, random.Random(0), ["A Joke"])

    # Run
    result = exporter.create_message_for_hint(hint, {0: patches},
                                              players_config, True)

    # Assert
    assert result == (
        f'The &push;&main-color=#FF6705B3;Blank Pickup&pop; can be found '
        f'&push;&main-color=#FF3333;{distance_text} {7 + (distance_precise or 0)} '
        f'rooms&pop; away from {reference_name}.')
Exemplo n.º 3
0
def test_create_hints_item_dark_temple_keys_cross_game(
    blank_pickup,
    echoes_resource_database,
    echoes_game_patches,
    default_echoes_configuration,
    prime_game_patches,
    default_prime_configuration,
):
    # Setup
    players_config = PlayersConfiguration(
        player_index=0,
        player_names={
            0: "Player 1",
            1: "Player 2",
        },
    )

    keys = [
        dataclasses.replace(
            blank_pickup,
            progression=((echoes_resource_database.get_item(item), 1), ))
        for item in echoes_items.DARK_TEMPLE_KEY_ITEMS[1]
    ]

    echoes_patches = dataclasses.replace(
        echoes_game_patches,
        configuration=default_echoes_configuration,
        pickup_assignment={
            PickupIndex(14): PickupTarget(keys[0], 0),
            PickupIndex(80): PickupTarget(keys[2], 0),
        })
    prime_patches = dataclasses.replace(
        prime_game_patches,
        configuration=default_prime_configuration,
        pickup_assignment={
            PickupIndex(23): PickupTarget(keys[1], 0),
        })

    hint = Hint(HintType.RED_TEMPLE_KEY_SET,
                None,
                dark_temple=HintDarkTemple.TORVUS_BOG)

    namer = EchoesHintNamer({
        0: echoes_patches,
        1: prime_patches
    }, players_config)
    exporter = HintExporter(namer, random.Random(0), ["A Joke"])

    # Run
    result = exporter.create_message_for_hint(hint, {
        0: echoes_patches,
        1: prime_patches
    }, players_config, True)

    # Assert
    assert result == (
        'The keys to &push;&main-color=#FF6705B3;Dark Torvus Temple&pop; can be found '
        'in &push;&main-color=#FF3333;Chozo Ruins&pop;, '
        '&push;&main-color=#FF3333;Dark Torvus Bog&pop; and '
        '&push;&main-color=#FF3333;Temple Grounds&pop;.')
Exemplo n.º 4
0
    def update_content(self, configuration: BaseConfiguration,
                       all_patches: dict[int, GamePatches],
                       players: PlayersConfiguration):
        self.tree_widget.clear()
        self.tree_widget.setColumnCount(3)
        self.tree_widget.setHeaderLabels(["Hint", "Pickup", "In-Game Text"])

        game = filtered_database.game_description_for_layout(configuration)
        world_list = game.world_list
        patches = all_patches[players.player_index]

        per_world: dict[str, dict[str,
                                  tuple[str,
                                        str]]] = collections.defaultdict(dict)
        namer = DreadHintNamer(all_patches, players)
        exporter = HintExporter(namer, random.Random(0), ["A joke hint."])

        for identifier, hint in patches.hints.items():
            node = game.world_list.node_by_identifier(identifier)
            source_world = world_list.nodes_to_world(node)
            source_name = world_list.node_name(node)

            hint_text = exporter.create_message_for_hint(
                hint, all_patches, players, False)

            # FIXME: tell the room name instead of the pickup name
            if hint.target is None:
                hinted_pickup = ""
            else:
                target = patches.pickup_assignment.get(hint.target)
                if target is None:
                    hinted_pickup = "Nothing"
                else:
                    hinted_pickup = target.pickup.name
                    if players.is_multiworld:
                        hinted_pickup = f"{players.player_names[target.player]}'s {hinted_pickup}"

            per_world[source_world.name][source_name] = (hint_text,
                                                         hinted_pickup)

        for world_name, world_contents in iterate_key_sorted(per_world):
            world_item = QtWidgets.QTreeWidgetItem(self.tree_widget)
            world_item.setText(0, world_name)
            world_item.setExpanded(True)
            for source_name, content in iterate_key_sorted(world_contents):
                area_item = QtWidgets.QTreeWidgetItem(world_item)
                area_item.setText(0, source_name)
                area_item.setText(1, content[1])
                area_item.setText(2, content[0])

        self.tree_widget.resizeColumnToContents(0)
        self.tree_widget.resizeColumnToContents(1)
        self.tree_widget.resizeColumnToContents(3)
Exemplo n.º 5
0
    def _encode_hints(self) -> list[dict]:
        namer = DreadHintNamer(self.description.all_patches, self.players_config)
        exporter = HintExporter(namer, self.rng, ["A joke hint."])

        return [
            {
                "accesspoint_actor": self._teleporter_ref_for(logbook_node),
                "hint_id": logbook_node.extra["hint_id"],
                "text": exporter.create_message_for_hint(
                    self.patches.hints[self.game.world_list.identifier_for_node(logbook_node)],
                    self.description.all_patches, self.players_config, True
                ),
            }
            for logbook_node in self.game.world_list.all_nodes
            if isinstance(logbook_node, LogbookNode)
        ]
Exemplo n.º 6
0
def get_hints(
    all_patches: dict[int, GamePatches],
    players_config: PlayersConfiguration,
    hint_rng: Random,
) -> dict[NodeIdentifier, str]:
    namer = CSHintNamer(all_patches, players_config)
    exporter = HintExporter(namer, hint_rng, JOKE_HINTS)

    hints_for_asset: dict[NodeIdentifier, str] = {}
    for asset, hint in all_patches[players_config.player_index].hints.items():
        hints_for_asset[asset] = exporter.create_message_for_hint(
            hint, all_patches, players_config, True)

    starts = ["I hear that", "Rumour has it,", "They say"]
    mids = ["can be found", "is", "is hidden"]

    return {
        identifier: hint.format(start=hint_rng.choice(starts),
                                mid=hint_rng.choice(mids))
        for identifier, hint in hints_for_asset.items()
    }
Exemplo n.º 7
0
def create_patches_hints(
    all_patches: Dict[int, GamePatches],
    players_config: PlayersConfiguration,
    world_list: WorldList,
    namer: HintNamer,
    rng: Random,
) -> list:
    exporter = HintExporter(namer, rng, JOKE_HINTS)

    hints_for_asset: dict[NodeIdentifier, str] = {}
    for identifier, hint in all_patches[
            players_config.player_index].hints.items():
        hints_for_asset[identifier] = exporter.create_message_for_hint(
            hint, all_patches, players_config, True)

    return [
        create_simple_logbook_hint(
            logbook_node.string_asset_id,
            hints_for_asset.get(world_list.identifier_for_node(logbook_node),
                                "Someone forgot to leave a message."),
        ) for logbook_node in world_list.iterate_nodes()
        if isinstance(logbook_node, LogbookNode)
    ]
Exemplo n.º 8
0
def test_create_hints_item_dark_temple_keys(echoes_game_patches,
                                            players_config,
                                            echoes_game_description,
                                            blank_pickup, indices,
                                            expected_message, preset_manager):
    # Setup
    db = echoes_game_description.resource_database
    keys = [
        (PickupIndex(index),
         dataclasses.replace(blank_pickup,
                             progression=((db.get_item(item), 1), )))
        for index, item in zip(indices, echoes_items.DARK_TEMPLE_KEY_ITEMS[1])
    ]

    patches = dataclasses.replace(
        echoes_game_patches,
        configuration=preset_manager.default_preset_for_game(
            db.game_enum).get_preset().configuration,
        pickup_assignment={
            pickup_index: PickupTarget(key, 0)
            for pickup_index, key in keys
        })

    hint = Hint(HintType.RED_TEMPLE_KEY_SET,
                None,
                dark_temple=HintDarkTemple.TORVUS_BOG)

    namer = EchoesHintNamer({0: patches}, players_config)
    exporter = HintExporter(namer, random.Random(0), ["A Joke"])

    # Run
    result = exporter.create_message_for_hint(hint, {0: patches},
                                              players_config, True)

    # Assert
    assert result == expected_message
Exemplo n.º 9
0
def _echoes_hint_exporter(echoes_game_patches) -> HintExporter:
    namer = EchoesHintNamer({0: echoes_game_patches},
                            PlayersConfiguration(0, {0: "You"}))
    return HintExporter(namer, random.Random(0), ["A Joke"])