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

    return [
        "{}{}".format("{} ".format(quantity) if quantity > 1 else "", _resource_user_friendly_name(item))
        for item, quantity in starting_items.items()
        if 0 < quantity != initial_items.get(item, 0)
    ]
Esempio n. 3
0
    def assign_extra_initial_items(
            self, new_resources: CurrentResources) -> "GamePatches":
        current = copy.copy(self.starting_items)

        for resource, quantity in new_resources.items():
            if resource.resource_type != ResourceType.ITEM:
                raise ValueError(
                    "Only ITEM is supported as extra initial items, got {}".
                    format(resource.resource_type))
            current[resource] = current.get(resource, 0) + quantity

        return dataclasses.replace(self, starting_items=current)
Esempio n. 4
0
def additional_starting_items(layout_configuration: BaseConfiguration,
                              resource_database: ResourceDatabase,
                              starting_items: CurrentResources) -> List[str]:
    initial_items = calculate_pool_results(layout_configuration,
                                           resource_database)[2]

    return [
        add_quantity_to_resource(resource_user_friendly_name(item), quantity)
        for item, quantity in sorted(
            starting_items.items(),
            key=lambda a: resource_user_friendly_name(a[0]))
        if 0 < quantity != initial_items.get(item, 0)
    ]
def starting_items_for(resources: CurrentResources) -> str:
    capacity_by_short_name = {
        item.short_name: capacity
        for item, capacity in resources.items()
        if isinstance(item, ItemResourceInfo)
    }

    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)
    ])
Esempio n. 6
0
def _create_starting_popup(layout_configuration: LayoutConfiguration,
                           resource_database: ResourceDatabase,
                           starting_items: CurrentResources) -> list:

    initial_items = pool_creator.calculate_pool_results(
        layout_configuration, resource_database)[2]

    extra_items = [
        "{}{}".format("{} ".format(quantity) if quantity > 1 else "",
                      _resource_user_friendly_name(item))
        for item, quantity in starting_items.items()
        if 0 < quantity != initial_items.get(item, 0)
    ]

    if extra_items:
        return ["Extra starting items:", ", ".join(extra_items)]
    else:
        return []