Exemplo n.º 1
0
 def _calculate_starting_inventory(self, resources: ResourceCollection):
     result = {}
     for resource, quantity in resources.as_resource_gain():
         try:
             result[_get_item_id_for_item(resource)] = quantity
         except KeyError:
             print(
                 f"Skipping {resource} for starting inventory: no item id")
             continue
     return result
Exemplo n.º 2
0
def additional_starting_items(layout_configuration: BaseConfiguration,
                              resource_database: ResourceDatabase,
                              starting_items: ResourceCollection) -> List[str]:
    initial_items = calculate_pool_results(layout_configuration,
                                           resource_database).initial_resources

    return [
        add_quantity_to_resource(resource_user_friendly_name(item), quantity)
        for item, quantity in sorted(
            starting_items.as_resource_gain(),
            key=lambda a: resource_user_friendly_name(a[0]))
        if 0 < quantity != initial_items[item]
    ]
Exemplo n.º 3
0
def starting_items_for(resources: ResourceCollection,
                       hypermode_original: int) -> str:
    capacity_by_short_name = {
        item.short_name: capacity
        for item, capacity in resources.as_resource_gain()
        if isinstance(item, ItemResourceInfo)
    }
    capacity_by_short_name["HyperModeOriginal"] = hypermode_original

    result_values = [
        capacity_by_short_name.get(STARTING_ITEMS_NAME_ALIAS.get(item, item),
                                   0) for item in STARTING_ITEMS_ORDER
    ]
    return "custom " + "".join([
        "{:02x}".format(value)
        if index in _TWO_BYTE_VALUES else "{:x}".format(value)
        for index, value in enumerate(result_values)
    ])
Exemplo n.º 4
0
def test_add_resource_gain_to_current_resources_convert(blank_resource_db, blank_pickup):
    # Setup
    resource_a = blank_resource_db.get_item("Ammo")
    resource_b = blank_resource_db.item[0]

    pickup = dataclasses.replace(
        blank_pickup,
        progression=(), resource_lock=ResourceLock(resource_b, resource_b, resource_a), unlocks_resource=True,
    )
    current_resources = ResourceCollection()
    current_resources.add_resource_gain([(resource_a, 5)])

    # Run
    current_resources.add_resource_gain(pickup.resource_gain(current_resources))

    # Assert
    assert dict(current_resources.as_resource_gain()) == {
        resource_a: 0,
        resource_b: 5
    }