space-game-proto/obj/inventory.py

25 lines
726 B
Python
Raw Normal View History

2021-05-11 14:58:22 -04:00
from obj.item import Item
from obj.inventorySlot import InventorySlot
class Inventory:
'Object to hold items and quantity'
def __init__(self):
#TODO Make limited slots
# __init__(self, numberOfSlots)
self.items = []
2021-05-11 14:58:22 -04:00
def addItem(self, item, quantity):
self.items.append(InventorySlot(item, quantity))
2021-05-11 14:58:22 -04:00
def printInventory(self):
print("Items: ")
print(f"{'Name' : <15}{'- - - - - | - - - - -' : ^10}{'Quantity' : >8}")
print()
for slot in self.items:
print(f"{slot.getName() : <15}{'* * * * * | * * * * *' : ^10}{str(slot.getQuantity()) : >5}")
print()
def getInventory(self):
return self.items