def test_create_hints_light_suit_location(empty_patches, players_config, pickup, item): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace( empty_patches, pickup_assignment={ pickup_index: PickupTarget(pickup, 0), }, hints={ logbook_node.resource(): Hint( HintType.LOCATION, PrecisionPair(HintLocationPrecision.LIGHT_SUIT_LOCATION, item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, 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] }]
def _create_string_patches(hint_config: HintConfiguration, game: GameDescription, all_patches: Dict[int, GamePatches], players_config: PlayersConfiguration, rng: Random, ) -> list: """ :param hint_config: :param game: :param patches: :return: """ patches = all_patches[players_config.player_index] string_patches = [] # Location Hints string_patches.extend( item_hints.create_hints(patches, game.world_list, rng) ) # Sky Temple Keys stk_mode = hint_config.sky_temple_keys if stk_mode == SkyTempleKeyHintMode.DISABLED: string_patches.extend(sky_temple_key_hint.hide_hints()) else: string_patches.extend(sky_temple_key_hint.create_hints(all_patches, players_config, game.world_list, stk_mode == SkyTempleKeyHintMode.HIDE_AREA)) # Elevator Scans string_patches.extend(_create_elevator_scan_port_patches(game.world_list, patches.elevator_connection)) string_patches.extend(_logbook_title_string_patches()) return string_patches
def test_create_hints_nothing(empty_patches, players_config): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace(empty_patches, hints={ logbook_node.resource(): Hint( HintType.LOCATION, PrecisionPair( HintLocationPrecision.DETAILED, HintItemPrecision.DETAILED), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, 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] }]
def test_create_hints_item_location(empty_patches, players_config, pickup, item, location): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace(empty_patches, pickup_assignment={ pickup_index: PickupTarget(pickup, 0), }, hints={ logbook_node.resource(): Hint(HintType.LOCATION, PrecisionPair(location[0], item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, rng) # Assert message = "{} can be found in {}.".format(item[1][0].upper() + item[1][1:], location[1]) # message = "The Flying Ing Cache in {} contains {}.".format(location[1], item[1]) assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def test_create_hints_guardians(empty_patches, pickup_index_and_guardian, pickup, item, players_config): # Setup asset_id = 1000 pickup_index, guardian = pickup_index_and_guardian logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace( empty_patches, pickup_assignment={ pickup_index: PickupTarget(pickup, 0), }, hints={ logbook_node.resource(): Hint(HintType.LOCATION, PrecisionPair(HintLocationPrecision.GUARDIAN, item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, rng) # Assert message = f"{guardian} is guarding {item[1]}." assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def test_create_hints_guardians(empty_patches, pickup_index_and_guardian, pickup, item): # Setup asset_id = 1000 pickup_index, guardian = pickup_index_and_guardian logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace( empty_patches, pickup_assignment={ pickup_index: pickup, }, hints={ logbook_node.resource(): Hint(HintType.GUARDIAN, PrecisionPair(PrecisionPair.detailed(), item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints(patches, world_list, rng) # Assert message = f"{guardian} is guarding {item[1]}." assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def test_create_hints_light_suit_location(empty_patches, pickup, item, location): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace(empty_patches, pickup_assignment={ pickup_index: pickup, }, hints={ logbook_node.resource(): Hint(HintType.LIGHT_SUIT_LOCATION, PrecisionPair(location, item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints(patches, world_list, rng) # Assert if location is HintLocationPrecision.WRONG_GAME and item[ 0] is HintItemPrecision.WRONG_GAME: message = "&push;&main-color=#45F731;You're not authorized to view this hint.&pop;" else: message = f"U-Mos's reward for returning the Sanctuary energy is {item[1]}." assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def test_create_hints_light_suit_location(empty_patches, pickup, item, location): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace(empty_patches, pickup_assignment={ pickup_index: PickupTarget(pickup, 0), }, hints={ logbook_node.resource(): Hint(HintType.LIGHT_SUIT_LOCATION, PrecisionPair(location, item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints(patches, world_list, rng) # Assert if location is HintLocationPrecision.WRONG_GAME and item[ 0] is HintItemPrecision.WRONG_GAME: message = "&push;&main-color=#45F731;Warning! Dark Aether's atmosphere is dangerous!" \ " Energized Safe Zones don't last forever!&pop;" else: message = f"U-Mos's reward for returning the Sanctuary energy is {item[1]}." assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def _create_string_patches( hint_config: HintConfiguration, game: GameDescription, patches: GamePatches, rng: Random, ) -> list: """ :param hint_config: :param game: :param patches: :return: """ string_patches = [] # Location Hints string_patches.extend( item_hints.create_hints(patches, game.world_list, rng)) # Sky Temple Keys stk_mode = hint_config.sky_temple_keys if stk_mode == SkyTempleKeyHintMode.DISABLED: string_patches.extend(sky_temple_key_hint.hide_hints()) else: string_patches.extend( sky_temple_key_hint.create_hints( patches, game.world_list, stk_mode == SkyTempleKeyHintMode.HIDE_AREA)) return string_patches
def test_create_hints_item_location(empty_patches, pickup, item, location, owner, is_multiworld): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) 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 = "Player 1's" patches = dataclasses.replace(empty_patches, pickup_assignment={ pickup_index: PickupTarget(pickup, 0), }, hints={ logbook_node.resource(): Hint( HintType.LOCATION, PrecisionPair(location[0], location_precision, include_owner=owner), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, 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] }]
def test_create_hints_item_joke(empty_patches, players_config, pickup): # Setup asset_id = 1000 logbook_node, _, world_list = _create_world_list(asset_id, PickupIndex(50)) patches = dataclasses.replace( empty_patches, hints={logbook_node.resource(): Hint(HintType.JOKE, None)}) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, rng) # Assert message = ( "&push;&main-color=#45F731;Warning! Dark Aether's atmosphere is dangerous!" " Energized Safe Zones don't last forever!&pop;") assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]
def test_create_hints_item_joke(empty_patches, players_config, pickup): # Setup asset_id = 1000 logbook_node, _, world_list = _create_world_list(asset_id, PickupIndex(50)) patches = dataclasses.replace( empty_patches, hints={logbook_node.resource(): Hint(HintType.JOKE, None)}) rng = MagicMock() # Run result = item_hints.create_hints({0: patches}, players_config, world_list, 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] }]
def test_create_hints_item_detailed(hint_type, empty_patches, pickup, item, location): # Setup asset_id = 1000 pickup_index = PickupIndex(50) logbook_node, _, world_list = _create_world_list(asset_id, pickup_index) patches = dataclasses.replace(empty_patches, pickup_assignment={ pickup_index: pickup, }, hints={ logbook_node.resource(): Hint(hint_type, PrecisionPair(location[0], item[0]), pickup_index) }) rng = MagicMock() # Run result = item_hints.create_hints(patches, world_list, rng) # Assert if location[0] == HintLocationPrecision.WRONG_GAME and item[ 0] == HintItemPrecision.WRONG_GAME: message = "&push;&main-color=#45F731;Warning! Dark Aether's atmosphere is dangerous!" \ " Energized Safe Zones don't last forever!&pop;" elif hint_type == HintType.LOCATION: message = "{} can be found in {}.".format( item[1][0].upper() + item[1][1:], location[1]) elif hint_type == HintType.KEYBEARER: message = "The Flying Ing Cache in {} contains {}.".format( location[1], item[1]) assert result == [{ 'asset_id': asset_id, 'strings': [message, '', message] }]