示例#1
0
def _create_test_layout_description(
        configuration: LayoutConfiguration,
        pickup_mapping: Iterable[int],
) -> LayoutDescription:
    """
    Creates a LayoutDescription for the given configuration, with the patches being for the given pickup_mapping
    :param configuration:
    :param pickup_mapping:
    :return:
    """
    game = data_reader.decode_data(configuration.game_data)
    pickup_database = game.pickup_database

    return LayoutDescription(
        version=VERSION,
        permalink=Permalink(
            seed_number=0,
            spoiler=True,
            patcher_configuration=PatcherConfiguration.default(),
            layout_configuration=configuration,
        ),
        patches=GamePatches.with_game(game).assign_new_pickups([
            (PickupIndex(i), pickup_database.original_pickup_mapping[PickupIndex(new_index)])
            for i, new_index in enumerate(pickup_mapping)
        ]),
        solver_path=())
示例#2
0
    def read_node(self, data: Dict) -> Node:
        name: str = data["name"]
        heal: bool = data["heal"]
        node_type: int = data["node_type"]

        if node_type == 0:
            self.generic_index += 1
            return GenericNode(name, heal, self.generic_index)

        elif node_type == 1:
            return DockNode(name, heal, data["dock_index"],
                            DockConnection(data["connected_area_asset_id"], data["connected_dock_index"]),
                            self.dock_weakness_database.get_by_type_and_index(DockType(data["dock_type"]),
                                                                              data["dock_weakness_index"]))

        elif node_type == 2:
            return PickupNode(name, heal, PickupIndex(data["pickup_index"]))

        elif node_type == 3:
            instance_id = data["teleporter_instance_id"]

            destination_world_asset_id = data["destination_world_asset_id"]
            destination_area_asset_id = data["destination_area_asset_id"]

            return TeleporterNode(name, heal, instance_id,
                                  AreaLocation(destination_world_asset_id, destination_area_asset_id))

        elif node_type == 4:
            return EventNode(name, heal,
                             self.resource_database.get_by_type_and_index(ResourceType.EVENT, data["event_index"]))

        else:
            raise Exception("Unknown node type: {}".format(node_type))
示例#3
0
def read_pickup_database(
        data: Dict, resource_database: ResourceDatabase) -> PickupDatabase:
    pickups = {
        name: PickupEntry(
            name,
            read_resource_gain_tuple(item["resources"], resource_database),
            item["item_category"],
            item["probability_offset"],
        )
        for name, item in data["pickups"].items()
    }
    original_pickup_mapping = {
        PickupIndex(i): pickups[name]
        for i, name in enumerate(data["original_indices"])
    }
    useless_pickup = pickups[data["useless_pickup"]]

    return PickupDatabase(pickups=pickups,
                          original_pickup_mapping=original_pickup_mapping,
                          useless_pickup=useless_pickup)
示例#4
0
    if permalink.layout_configuration.elevators == LayoutRandomizedFlag.RANDOMIZED:
        return GamePatches(
            patches.pickup_assignment,
            claris_randomizer.elevator_connections_for_seed_number(
                permalink.seed_number),
            patches.dock_connection,
            patches.dock_weakness,
            patches.extra_initial_items,
            patches.starting_location,
        )
    else:
        return patches


_FLYING_ING_CACHES = [
    PickupIndex(45),  # Sky Temple Key 1
    PickupIndex(53),  # Sky Temple Key 2
    PickupIndex(68),  # Sky Temple Key 3
    PickupIndex(91),  # Sky Temple Key 4
    PickupIndex(117),  # Sky Temple Key 5
    PickupIndex(106),  # Sky Temple Key 6
    PickupIndex(19),  # Sky Temple Key 7
    PickupIndex(11),  # Sky Temple Key 8
    PickupIndex(15),  # Sky Temple Key 9
]
_GUARDIAN_INDICES = [
    PickupIndex(43),  # Dark Suit
    PickupIndex(79),  # Dark Visor
    PickupIndex(115),  # Annihilator Beam
]
_SUB_GUARDIAN_INDICES = [
示例#5
0
def test_create_pickup_list(empty_patches):
    # Setup
    useless_resource = SimpleResourceInfo(0, "Useless", "Useless",
                                          ResourceType.ITEM)
    resource_a = SimpleResourceInfo(1, "A", "A", ResourceType.ITEM)
    resource_b = SimpleResourceInfo(2, "B", "B", ResourceType.ITEM)
    pickup_a = PickupEntry("A", ((resource_a, 1), ), "", 0)

    useless_pickup = PickupEntry("Useless", ((useless_resource, 1), ), "", 0)
    pickup_database = PickupDatabase(pickups={},
                                     original_pickup_mapping={
                                         PickupIndex(i): useless_pickup
                                         for i in range(4)
                                     },
                                     useless_pickup=useless_pickup)
    patches = empty_patches.assign_pickup_assignment({
        PickupIndex(0):
        pickup_a,
        PickupIndex(2):
        PickupEntry("B", ((resource_b, 1), (resource_a, 1)), "", 0),
        PickupIndex(3):
        pickup_a,
    })

    # Run
    result = patcher_file._create_pickup_list(patches, pickup_database)

    # Assert
    assert result == [
        {
            "pickup_index": 0,
            "scan": "A",
            "resources": [{
                "index": 1,
                "amount": 1
            }]
        },
        {
            "pickup_index": 1,
            "scan": "Useless",
            "resources": [{
                "index": 0,
                "amount": 1
            }]
        },
        {
            "pickup_index": 2,
            "scan": "B",
            "resources": [{
                "index": 2,
                "amount": 1
            }, {
                "index": 1,
                "amount": 1
            }]
        },
        {
            "pickup_index": 3,
            "scan": "A",
            "resources": [{
                "index": 1,
                "amount": 1
            }]
        },
    ]
示例#6
0
def test_pickup_index_has():
    d = {PickupIndex(1): True}
    assert PickupIndex(1) in d
示例#7
0
def test_pickup_index_equality():
    assert PickupIndex(1) == PickupIndex(1)