2022-04-16 16:59:34 -07:00
|
|
|
"""Functions to keep track and alter inventory."""
|
2022-04-10 22:10:01 -03:00
|
|
|
|
|
|
|
|
|
2020-08-03 20:15:59 +02:00
|
|
|
def create_inventory(items):
|
2022-04-16 16:59:34 -07:00
|
|
|
"""Create a dict that tracks the amount (count) of each element on the `items` list.
|
2021-08-31 23:03:37 -07:00
|
|
|
|
|
|
|
|
:param items: list - list of items to create an inventory from.
|
2022-04-10 22:10:01 -03:00
|
|
|
:return: dict - the inventory dictionary.
|
2021-09-05 19:32:25 -07:00
|
|
|
"""
|
2021-08-31 23:11:15 -07:00
|
|
|
|
|
|
|
|
pass
|
2020-08-03 20:15:59 +02:00
|
|
|
|
2020-11-15 22:57:41 +01:00
|
|
|
|
2020-08-03 20:15:59 +02:00
|
|
|
def add_items(inventory, items):
|
2022-04-16 16:59:34 -07:00
|
|
|
"""Add or increment items in inventory using elements from the items `list`.
|
2021-08-31 23:03:37 -07:00
|
|
|
|
|
|
|
|
:param inventory: dict - dictionary of existing inventory.
|
|
|
|
|
:param items: list - list of items to update the inventory with.
|
2022-04-16 16:59:34 -07:00
|
|
|
:return: dict - the inventory updated with the new items.
|
2021-09-05 19:32:25 -07:00
|
|
|
"""
|
2021-08-31 23:11:15 -07:00
|
|
|
|
|
|
|
|
pass
|
2020-08-03 20:15:59 +02:00
|
|
|
|
2020-11-15 22:57:41 +01:00
|
|
|
|
2021-09-07 10:34:02 +05:30
|
|
|
def decrement_items(inventory, items):
|
2022-04-16 16:59:34 -07:00
|
|
|
"""Decrement items in inventory using elements from the `items` list.
|
2021-08-31 23:03:37 -07:00
|
|
|
|
|
|
|
|
:param inventory: dict - inventory dictionary.
|
2021-09-07 10:34:02 +05:30
|
|
|
:param items: list - list of items to decrement from the inventory.
|
2022-04-16 16:59:34 -07:00
|
|
|
:return: dict - updated inventory with items decremented.
|
2021-09-05 19:32:25 -07:00
|
|
|
"""
|
2021-08-31 23:11:15 -07:00
|
|
|
|
|
|
|
|
pass
|
2020-08-03 20:15:59 +02:00
|
|
|
|
2020-11-15 22:57:41 +01:00
|
|
|
|
2021-09-06 13:48:38 +05:30
|
|
|
def remove_item(inventory, item):
|
2022-04-16 16:59:34 -07:00
|
|
|
"""Remove item from inventory if it matches `item` string.
|
2022-04-10 22:10:01 -03:00
|
|
|
|
2021-09-06 13:48:38 +05:30
|
|
|
:param inventory: dict - inventory dictionary.
|
|
|
|
|
:param item: str - item to remove from the inventory.
|
2022-04-16 16:59:34 -07:00
|
|
|
:return: dict - updated inventory with item removed. Current inventory if item does not match.
|
2021-09-07 10:34:02 +05:30
|
|
|
"""
|
2021-09-06 13:48:38 +05:30
|
|
|
|
2022-04-16 17:03:24 -07:00
|
|
|
pass
|
2021-09-06 13:48:38 +05:30
|
|
|
|
|
|
|
|
|
2020-08-03 20:15:59 +02:00
|
|
|
def list_inventory(inventory):
|
2024-04-21 20:55:57 +03:00
|
|
|
"""Create a list containing only available (item_name, item_count > 0) pairs in inventory.
|
2021-08-31 23:03:37 -07:00
|
|
|
|
|
|
|
|
:param inventory: dict - an inventory dictionary.
|
|
|
|
|
:return: list of tuples - list of key, value pairs from the inventory dictionary.
|
2021-09-05 19:32:25 -07:00
|
|
|
"""
|
2021-08-31 23:11:15 -07:00
|
|
|
|
|
|
|
|
pass
|
2023-11-06 22:02:57 -08:00
|
|
|
|