def test_bit_pack_pickup_entry(has_convert: bool, echoes_resource_database):
    # Setup
    name = "Some Random Name"
    if has_convert:
        convert_resources = (ResourceConversion(
            find_resource_info_with_long_name(echoes_resource_database.item,
                                              "Morph Ball"),
            find_resource_info_with_long_name(echoes_resource_database.item,
                                              "Item Percentage")), )
    else:
        convert_resources = ()

    pickup = PickupEntry(
        name=name,
        model_index=26,
        item_category=ItemCategory.TEMPLE_KEY,
        broad_category=ItemCategory.KEY,
        resources=(ConditionalResources(
            "Morph Ball",
            None,
            (
                (find_resource_info_with_long_name(
                    echoes_resource_database.item, "Morph Ball"), 2),
                (find_resource_info_with_long_name(
                    echoes_resource_database.item, "Item Percentage"), 5),
            ),
        ),
                   ConditionalResources(
                       "Grapple Beam",
                       find_resource_info_with_long_name(
                           echoes_resource_database.item, "Morph Ball"),
                       ((find_resource_info_with_long_name(
                           echoes_resource_database.item,
                           "Grapple Beam"), 3), ),
                   )),
        convert_resources=convert_resources)

    # Run
    encoded = bitpacking.pack_value(
        BitPackPickupEntry(pickup, echoes_resource_database))
    decoder = BitPackDecoder(encoded)
    decoded = BitPackPickupEntry.bit_pack_unpack(decoder, name,
                                                 echoes_resource_database)

    # Assert
    assert pickup == decoded
Exemplo n.º 2
0
def test_bit_pack_pickup_entry(has_convert: bool, echoes_resource_database,
                               generic_item_category):
    # Setup
    name = "Some Random Name"
    if has_convert:
        resource_lock = ResourceLock(
            find_resource_info_with_long_name(echoes_resource_database.item,
                                              "Morph Ball"),
            find_resource_info_with_long_name(echoes_resource_database.item,
                                              "Item Percentage"),
            find_resource_info_with_long_name(echoes_resource_database.item,
                                              "Space Jump Boots"),
        )
    else:
        resource_lock = None

    pickup = PickupEntry(
        name=name,
        model=PickupModel(
            game=RandovaniaGame.METROID_PRIME_CORRUPTION,
            name="HyperMissile",
        ),
        item_category=generic_item_category,
        broad_category=generic_item_category,
        progression=(
            (find_resource_info_with_long_name(echoes_resource_database.item,
                                               "Morph Ball"), 1),
            (find_resource_info_with_long_name(echoes_resource_database.item,
                                               "Grapple Beam"), 1),
        ),
        extra_resources=((find_resource_info_with_long_name(
            echoes_resource_database.item, "Item Percentage"), 5), ),
        resource_lock=resource_lock)

    # Run
    encoded = bitpacking.pack_value(
        BitPackPickupEntry(pickup, echoes_resource_database))
    decoder = BitPackDecoder(encoded)
    decoded = BitPackPickupEntry.bit_pack_unpack(decoder,
                                                 echoes_resource_database)

    # Assert
    assert pickup == decoded
Exemplo n.º 3
0
 def _decode_pickup(self, data: bytes) -> PickupEntry:
     decoder = bitpacking.BitPackDecoder(data)
     return BitPackPickupEntry.bit_pack_unpack(decoder,
                                               self._game.resource_database)
Exemplo n.º 4
0
def _decode_pickup(d: str, resource_database):
    decoder = bitpacking.BitPackDecoder(base64.b85decode(d))
    return BitPackPickupEntry.bit_pack_unpack(decoder, resource_database)
Exemplo n.º 5
0
def _decode_pickup(data: bytes,
                   resource_database: ResourceDatabase) -> PickupEntry:
    decoder = bitpacking.BitPackDecoder(data)
    return BitPackPickupEntry.bit_pack_unpack(decoder, resource_database)