@Corsaka/

The Shop

Python

No description

fork
loading
Files
  • main.py
  • Armour.py
  • Foods.py
  • Weapons.py
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# imports
from time import sleep
import Weapons
import Armour
import Foods

# define the list inventory
invetory = ["Brilliant Bananas"]
# define "money"
money = 100000
items = []

print("Hello, and welcome to the shop!\nWhat do you want to do?")
# while loop to prevent bad inputs
while True:
  once = 1
  buy_options = []
  buyable = []  
  print("You have %s Bjorps" % money)
  option = input("You can either Buy, Sell or Leave\nInputs must be exact (with capitals)!\n").lower()
  if option == "buy":
    if len(Armour.armour_items) - 1 > 0:
      buy_options.append("Armour")
    if len(Foods.food_items) - 1 > 0:
      buy_options.append("Food")
    if len(Weapons.weapons_items) - 1 > 0:
      buy_options.append("Weapons")
    print (buy_options) 
    buy = input("What section do you want to look at \n")
    if buy.lower() == "armour":
      print ("This is what we have got:")
      for i in Armour.armour_items:
        if i["amount"] > 0:
          print("%s costing %s Bjorps" %(i["name"], i["cost"]))
      while once == 1:
        bought = input("What do you want to buy?  ")
        for i in Armour.armour_items:
          items.append(i["name"])
        if bought not in items:
          if bought.lower() == "back":
            break
          else:
            print("Sorry we don't have that item. Please choose something\ndifferent.")
            continue
        else: 
          for i in Armour.armour_items:
            if i["name"] == bought:
              i["amount"] -= 1
              money -= i["cost"]
              invetory.append(i["name"])
              print("Bought!")
              once = 2
      continue

    if buy.lower() == "food":
      print ("This is what we have got:")
      for i in Foods.food_items:
        if i["amount"] > 0:
          print("%s costing %s Bjorps" %(i["name"], i["cost"]))
      while once == 1:
        bought = input("What do you want to buy?  ")
        for i in Foods.food_items:
          items.append(i["name"])
        if bought not in items:
          if bought.lower() == "back":
            break
          else:
            print("Sorry we don't have that item. Please choose something\ndifferent.")
            continue
        else: 
          for i in Foods.food_items:
            if i["name"] == bought:
              i["amount"] -= 1
              money -= i["cost"]
              invetory.append(i["name"])
              print("Bought!")
              once = 2
      continue

    if buy.lower() == "weapons":
      print ("This is what we have got:")
      for i in Weapons.weapons_items:
        if i["amount"] > 0:
          print("%s costing %s Bjorps" %(i["name"], i["cost"]))
      while once == 1:
        bought = input("What do you want to buy?  ")
        for i in Weapons.weapons_items:
          items.append(i["name"])
        if bought not in items:
          if bought.lower() == "back":
            once = 2
          else:
            print("Sorry we don't have that item. Please choose something\ndifferent.")
            continue
        else: 
          for i in Weapons.weapons_items:
            if i["name"] == bought:
              i["amount"] -= 1
              money -= i["cost"]
              invetory.append(i["name"])
              print("Bought!")
              once = 2
      continue

    else:
      continue

  elif option == "sell":
    if len(invetory) < 1:
      print("Sorry you have nothing to sell")
    else:
      print("Here is you invetory:")
      print(invetory)
      sold = input("What would you like to sell?\n")
      if sold not in invetory:
        print("You don't even have that to sell")
        continue
      else: 
        for i in Armour.armour_items:
          if i["name"] == sold:
            money += i["cost"] / 3 * 2
            print("Sold!")
            continue
        for i in Foods.food_items:
          if i["name"] == sold:
            money += i["cost"] / 2
            print("Sold!")
            continue
        for i in Weapons.weapons_items:
          if i["name"] == sold:
            money += i["cost"] / 3 * 2
            print("Sold!")
            continue
        continue


  elif option == "leave":
    print("Okay, see you next time!")
    from sys import exit
    exit()
  
  else:
    print("There are three available options. Is it really that hard?")
    continue
  
  break

"""
make dictionaries as lists
class item, give items their correct 

"""