def test_create_hints_all_placed(hide_area: bool, empty_patches, echoes_game_description): # Setup patches = empty_patches.assign_new_pickups([ (PickupIndex(17 + key), pickup_creator.create_sky_temple_key(key, echoes_game_description.resource_database)) for key in range(9) ]) expected = [ {"asset_id": 0xD97685FE, "strings": _create_hint_text(hide_area, 1, "Sky Temple Grounds - Profane Path")}, {"asset_id": 0x32413EFD, "strings": _create_hint_text(hide_area, 2, "Sky Temple Grounds - Phazon Grounds")}, {"asset_id": 0xDD8355C3, "strings": _create_hint_text(hide_area, 3, "Sky Temple Grounds - Ing Reliquary")}, {"asset_id": 0x3F5F4EBA, "strings": _create_hint_text(hide_area, 4, "Great Temple - Transport A Access")}, {"asset_id": 0xD09D2584, "strings": _create_hint_text(hide_area, 5, "Great Temple - Temple Sanctuary")}, {"asset_id": 0x3BAA9E87, "strings": _create_hint_text(hide_area, 6, "Great Temple - Transport B Access")}, {"asset_id": 0xD468F5B9, "strings": _create_hint_text(hide_area, 7, "Great Temple - Main Energy Controller")}, {"asset_id": 0x2563AE34, "strings": _create_hint_text(hide_area, 8, "Great Temple - Main Energy Controller")}, {"asset_id": 0xCAA1C50A, "strings": _create_hint_text(hide_area, 9, "Agon Wastes - Mining Plaza")}, ] # Run result = sky_temple_key_hint.create_hints(patches, echoes_game_description.world_list, hide_area) # Assert assert result == expected
def add_sky_temple_key_distribution_logic( resource_database: ResourceDatabase, mode: LayoutSkyTempleKeyMode, ) -> PoolResults: """ Adds the given Sky Temple Keys to the item pool :param resource_database: :param mode: :return: """ item_pool: List[PickupEntry] = [] new_assignment: Dict[PickupIndex, PickupEntry] = {} initial_resources: CurrentResources = {} if mode == LayoutSkyTempleKeyMode.ALL_BOSSES or mode == LayoutSkyTempleKeyMode.ALL_GUARDIANS: locations_to_place = _GUARDIAN_INDICES[:] if mode == LayoutSkyTempleKeyMode.ALL_BOSSES: locations_to_place += _SUB_GUARDIAN_INDICES for key_number, location in enumerate(locations_to_place): new_assignment[location] = create_sky_temple_key( key_number, resource_database) first_automatic_key = len(locations_to_place) else: keys_to_place = mode.value if not isinstance(keys_to_place, int): raise InvalidConfiguration( "Unknown Sky Temple Key mode: {}".format(mode)) for key_number in range(keys_to_place): item_pool.append( create_sky_temple_key(key_number, resource_database)) first_automatic_key = keys_to_place for automatic_key_number in range(first_automatic_key, 9): add_resource_gain_to_current_resources( create_sky_temple_key(automatic_key_number, resource_database).all_resources, initial_resources) return PoolResults(item_pool, new_assignment, initial_resources)
def test_sky_temple_key_distribution_logic_with_quantity( echoes_resource_database, quantity: int): # Run results = sky_temple_keys.add_sky_temple_key_distribution_logic( echoes_resource_database, LayoutSkyTempleKeyMode(quantity)) item_pool, pickup_assignment, initial_items = results # Assert assert item_pool == [ pickup_creator.create_sky_temple_key(i, echoes_resource_database) for i in range(quantity) ] assert pickup_assignment == {} assert initial_items == { ItemResourceInfo(f'Sky Temple Key {i}', f'TempleKey{i}', 1, frozendict({"item_id": item_ids[i - 1]})): 1 for i in range(quantity + 1, 10) }
def test_sky_temple_key_distribution_logic_with_quantity( echoes_resource_database, quantity: int): # Run results = sky_temple_keys.add_sky_temple_key_distribution_logic( echoes_resource_database, LayoutSkyTempleKeyMode(quantity)) # ItemResourceInfo(f'Sky Temple Key {i}', , 1, frozendict({"item_id": item_ids[i - 1]})): 1 # Assert assert results.pickups == [ pickup_creator.create_sky_temple_key(i, echoes_resource_database) for i in range(quantity) ] assert results.assignment == {} assert results.initial_resources == ResourceCollection.from_dict( echoes_resource_database, { echoes_resource_database.get_item(f'TempleKey{i}'): 1 for i in range(quantity + 1, 10) })
def test_sky_temple_key_distribution_logic_with_quantity( echoes_resource_database, quantity: int): # Run results = sky_temple_keys.add_sky_temple_key_distribution_logic( echoes_resource_database, LayoutSkyTempleKeyMode(quantity)) item_pool, pickup_assignment, initial_items = results # Assert assert item_pool == [ pickup_creator.create_sky_temple_key(i, echoes_resource_database) for i in range(quantity) ] assert pickup_assignment == {} assert initial_items == { ItemResourceInfo( randovania.games.prime.echoes_items.SKY_TEMPLE_KEY_ITEMS[i - 1], f'Sky Temple Key {i}', f'TempleKey{i}', 1, None): 1 for i in range(quantity + 1, 10) }
def prime2_hint_text(): db = default_database.resource_database_for(RandovaniaGame.METROID_PRIME_ECHOES) result = [] for temple in range(3): key = pickup_creator.create_dark_temple_key(0, temple, db) result.append(( key.name.replace(" 1", "").strip(), key.item_category, key.broad_category, )) key = pickup_creator.create_sky_temple_key(0, db) result.append(( "Sky Temple Key", key.item_category, key.broad_category, )) return result
def test_create_hints_all_placed(hide_area: bool, multiworld: bool, empty_patches, default_echoes_configuration, default_prime_configuration): # Setup echoes_game = default_database.game_description_for( RandovaniaGame.METROID_PRIME_ECHOES) players_config = PlayersConfiguration(0, { 0: "you", 1: "them" } if multiworld else {0: "you"}) patches = empty_patches.assign_new_pickups([ (PickupIndex(17 + key), PickupTarget( pickup_creator.create_sky_temple_key( key, echoes_game.resource_database), 0)) for key in range(5 if multiworld else 9) ]) patches = dataclasses.replace(patches, configuration=default_echoes_configuration) other_patches = empty_patches.assign_new_pickups([ (PickupIndex(17 + key), PickupTarget( pickup_creator.create_sky_temple_key( key, echoes_game.resource_database), 0)) for key in range(5, 9) ]) other_patches = dataclasses.replace( other_patches, configuration=default_prime_configuration) assets = [ 0xD97685FE, 0x32413EFD, 0xDD8355C3, 0x3F5F4EBA, 0xD09D2584, 0x3BAA9E87, 0xD468F5B9, 0x2563AE34, 0xCAA1C50A ] locations = [ "Sky Temple Grounds - Profane Path", "Sky Temple Grounds - Phazon Grounds", "Sky Temple Grounds - Ing Reliquary", "Great Temple - Transport A Access", "Great Temple - Temple Sanctuary", "Great Temple - Transport B Access", "Great Temple - Main Energy Controller", "Great Temple - Main Energy Controller", "Agon Wastes - Mining Plaza", ] other_locations = [ "Chozo Ruins - Watery Hall Access", "Chozo Ruins - Watery Hall", "Chozo Ruins - Watery Hall", "Chozo Ruins - Dynamo", ] if multiworld: locations[-len(other_locations):] = other_locations expected = [{ "asset_id": asset_id, "strings": _create_hint_text(hide_area, multiworld, i + 1, text) } for i, (asset_id, text) in enumerate(zip(assets, locations))] namer = EchoesHintNamer({0: patches, 1: other_patches}, players_config) # Run result = randovania.games.prime2.exporter.hints.create_stk_hints( { 0: patches, 1: other_patches } if multiworld else {0: patches}, players_config, echoes_game.resource_database, namer, hide_area) # Assert assert result == expected
def test_create_hints_all_placed(hide_area: bool, multiworld: bool, empty_patches, echoes_game_description): # Setup hint_creator = LocationHintCreator(echoes_game_description.world_list, None, None) players_config = PlayersConfiguration(0, { 0: "you", 1: "them" } if multiworld else {0: "you"}) patches = empty_patches.assign_new_pickups([ (PickupIndex(17 + key), PickupTarget( pickup_creator.create_sky_temple_key( key, echoes_game_description.resource_database), 0)) for key in range(5 if multiworld else 9) ]) other_patches = empty_patches.assign_new_pickups([ (PickupIndex(17 + key), PickupTarget( pickup_creator.create_sky_temple_key( key, echoes_game_description.resource_database), 0)) for key in range(5, 9) ]) expected = [ { "asset_id": 0xD97685FE, "strings": _create_hint_text(hide_area, multiworld, 1, "Sky Temple Grounds - Profane Path") }, { "asset_id": 0x32413EFD, "strings": _create_hint_text(hide_area, multiworld, 2, "Sky Temple Grounds - Phazon Grounds") }, { "asset_id": 0xDD8355C3, "strings": _create_hint_text(hide_area, multiworld, 3, "Sky Temple Grounds - Ing Reliquary") }, { "asset_id": 0x3F5F4EBA, "strings": _create_hint_text(hide_area, multiworld, 4, "Great Temple - Transport A Access") }, { "asset_id": 0xD09D2584, "strings": _create_hint_text(hide_area, multiworld, 5, "Great Temple - Temple Sanctuary") }, { "asset_id": 0x3BAA9E87, "strings": _create_hint_text(hide_area, multiworld, 6, "Great Temple - Transport B Access") }, { "asset_id": 0xD468F5B9, "strings": _create_hint_text(hide_area, multiworld, 7, "Great Temple - Main Energy Controller") }, { "asset_id": 0x2563AE34, "strings": _create_hint_text(hide_area, multiworld, 8, "Great Temple - Main Energy Controller") }, { "asset_id": 0xCAA1C50A, "strings": _create_hint_text(hide_area, multiworld, 9, "Agon Wastes - Mining Plaza") }, ] # Run result = sky_temple_key_hint.create_hints( { 0: patches, 1: other_patches } if multiworld else {0: patches}, players_config, echoes_game_description.resource_database, { 0: hint_creator, 1: hint_creator } if multiworld else {0: hint_creator}, hide_area) # Assert assert result == expected