-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHero_inventory.py
More file actions
71 lines (54 loc) · 2.68 KB
/
Hero_inventory.py
File metadata and controls
71 lines (54 loc) · 2.68 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
inventory = ["Sword", "Armor", "Shield"]
print("Hero's Inventory:\n\nWhere you can exchange and add your tools and weapons to get the items you want to use to fight the enemy\n")
print("Current Hero's Inventory:\n")
for i in range(len(inventory)):
print(f"{i + 1}: {inventory[i]}\n\n")
trade = input("Would you like to trade your item for anything else?\nType (y) for yes or (n) for no: ").upper()
print()
if trade == "Y":
item_number_index = int(input(
"What item do you want to remove from your current inventory?\nPlease enter the number of the item see above: ")) - 1
print()
print(f"What item would you like to replace your {inventory[item_number_index]}")
new_item = int(
input("Choose the number from the options below:\n1-Magic Potion\t2-Battle Axe\t3-Liquid Metal Shield: "))
print()
if new_item == 1:
print("Item to add Magic Potion\n")
inventory[item_number_index] = "Magic Potion"
elif new_item == 2:
print("Item to add Battle Axe\n")
inventory[item_number_index] = "Battle Axe"
else:
print("Item to add Liquid Metal Shield\n")
inventory[item_number_index] = "Liquid Metal Shield"
os.system('cls')
print("The items in your current inventory are:\n")
for i in range(len(inventory)):
print(f"{i + 1}: {inventory[i]}")
print()
add_items = input("Would you like to to add items to your inventory? (y) Yes or (n) No: ").lower()
os.system('cls')
if add_items == "y":
while len(inventory) < 5:
print(f"There is room to add {5 - len(inventory)} items to your inventory\n")
item_to_add = input("What item would you like to add? ")
print()
inventory.append(item_to_add)
os.system('cls')
print("Your inventory is now currently filled!\nYour current inventory is:")
for i in range(len(inventory)):
print(f"{i + 1}: {inventory[i]}\n\n")
final_swap = input("Would you like to make a final swap in your inventory? (y) for Yes (n) for No: ").lower()
print()
if final_swap == "y":
final_swap_item = input(
"What item do you want to swap out? (Type the item the way it is seen in the inventory) ")
item_to_place = input("What item do you want to replace it with? ")
inventory[inventory.index(final_swap_item)] = item_to_place
os.system('cls')
print("Here is your final inventory:")
for i in range(len(inventory)):
print(f"{i + 1}: {inventory[i]}")
print("Thank you for visiting the Hero's Inventory")