-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
52 lines (39 loc) · 1.26 KB
/
player.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
40
41
42
43
44
45
46
47
48
49
50
51
52
class Inventory(object):
def __init__(self):
self.inventory = []
def main(self):
print("What would you like to do")
print("[Management, Drop an item]")
inv_choice = input().lower()
print("")
if inv_choice == "management" or inv_choice == "manage":
print("You are in possession of:")
self.print_list()
else:
self.minus_inventory()
def add_inventory(self, item):
self.inventory.append(item)
def minus_inventory(self):
print("What would you like to drop?")
print("[Type the item name]")
self.print_list()
inv_choice = input().lower()
print("")
self.inventory.remove(inv_choice)
print("You have removed:")
print("[%s]" % inv_choice.capitalize())
print("Your new inventory is:")
self.print_list()
def print_list(self):
x = 1
for i in range(len(self.inventory)):
print("%s: %s" % (str(x), str(self.inventory[i]).capitalize()))
x += 1
class Player(object):
def __init__(self):
self.hp = 100
player_inv = Inventory()
player_inv.add_inventory("apple")
player_inv.add_inventory("gun")
player_inv.add_inventory("tank")
player_inv.main()