-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinventory.py
39 lines (36 loc) · 1004 Bytes
/
inventory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import item
class Inventory:
# def add(item, slot, stat, bag):
# bag = {
# "slot": str(slot),
# "stat": int(stat)
# }
# return bag
# ^ old code
def __init__(self, items=[], equip=[]): # Note: Elements of "items" have to be item objects
self.items = items # Bag items
self.equip = equip # Equipped, in the order of: [mainWeapon, offhand, armor, trinket]
def give(self, gifts=None): # Note: Gifts are item objects too!
self.items.append(gifts)
def take(self, rob=[]):
for i in rob:
try:
self.items.remove(i)
except:
print("Error: Item not found in bag.")
pass
def peek(self):
print("You are carrying:")
bag = ""
for i in self.items:
bag += f" - {i.name}, with a number of {i.stats}\n"
def equipThis(self, putOn=[]):
for i in putOn:
if i in self.items:
self.equip.append(i)
def unequip(self, takeOff=[]):
for i in takeOff:
if i in self.equip:
self.equip.remove(i)
def nameList(self):
return [(_.name, _) for _ in self.items]