-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
194 lines (153 loc) · 5.45 KB
/
main.py
File metadata and controls
194 lines (153 loc) · 5.45 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import random
import forest
from player import currentPlayer
import items
import craft
from shop import Shop
import clock as clock
def main():
runMainMenu()
#Meg's menu system in action
def runMainMenu():
while True:
options = {
1: ("Visit the Forest", "forest"),
2: ("Go to the Field", "field"),
3: ("Go to the Barn", "barn"),
4: ("Open a Vendor Stall", "vendor"),
5: ("Visit the Market", "market"),
6: ("Go to the Crafting Bench", "craft"),
7: ("View Stats", "stats"),
8: ("Quit", "quit")
}
nextAction = displayMenuPrompt(options)
if nextAction == "forest":
#works fine
runForestMenu()
elif nextAction == "field":
#does nothing
runFieldMenu()
elif nextAction == "barn":
#does nothing
runBarnMenu()
elif nextAction == "vendor":
#works
runVendorMenu()
elif nextAction == "market":
#works
runMarketMenu()
elif nextAction == "craft":
#should be working :D
runCraftMenu()
elif nextAction == "stats":
#works fine
print (("It is %s %s in Year %s.") % clock.gameTime.checkClock())
print (("Your money is at %s g, you are at level %s with %s experience and your inventory contains: ") % currentPlayer.printStats())
currentPlayer.inventory.printPretty()
elif nextAction == "quit":
#works!
print ("Goodbye!")
exit(0)
def runForestMenu():
print("The forest is an excellent spot to find items!")
while True:
print("Where do you want to look?")
print(" ")
options = {
1: ("In a wild field", "wild"),
2: ("Under the Sunny Brook Bridge", "bridge"),
3: ("By the Forester's Hut", "hut"),
4: ("Around Pea Bog", "bog"),
5: ("By the old mine", "mine"),
6: ("Go back Home", "home")
}
nextAction = displayMenuPrompt(options)
if nextAction == "wild":
item = forest.wild.search()
print ("You found a %s!" % item.name)
currentPlayer.inventory.add(item)
currentPlayer.addCount(1)
currentPlayer.expGain(1)
elif nextAction == "bridge":
item = forest.bridge.search()
print ("You found a %s!" % item.name)
currentPlayer.inventory.add(item)
currentPlayer.addCount(1)
currentPlayer.expGain(1)
elif nextAction == "hut":
item = forest.hut.search()
print ("You found a %s!" % item.name)
currentPlayer.inventory.add(item)
currentPlayer.addCount(1)
currentPlayer.expGain(1)
elif nextAction == "bog":
item = forest.bog.search()
print ("You found a %s!" % item.name)
currentPlayer.inventory.add(item)
currentPlayer.addCount(1)
currentPlayer.expGain(1)
elif nextAction == "mine":
item = forest.mine.search()
print ("You found a %s!" % item.name)
currentPlayer.inventory.add(item)
currentPlayer.addCount(1)
currentPlayer.expGain(1)
elif nextAction == "home":
print ("You head home.")
return
#doing last
def runFieldMenu():
print ("Nothing Yet")
#also doing last
def runBarnMenu():
print ("Nothing Yet")
def runVendorMenu():
print("You can open a stall to sell goods here.")
Shop.sellPrompt(currentPlayer)
def runMarketMenu():
print ("You can buy many things at the market!")
Shop.buyPrompt(currentPlayer)
def runCraftMenu():
print ("You can craft many things here!")
while True:
options = {
1: ("View all recipes", "recipes"),
2: ("Check inventory", "inventory"),
3: ("Craft!", "create"),
4: ("Go back Home", "home")
}
nextAction = displayMenuPrompt(options)
if nextAction == "recipes":
craft.printRecipes()
elif nextAction == "inventory":
currentPlayer.inventory.printPretty()
elif nextAction == "create":
runCraftCreatePrompt()
elif nextAction == "home":
print ("You head home")
return
def runCraftCreatePrompt():
print ("What do you want to craft?")
itemToCreate = input(">")
if itemToCreate in craft.recipes.keys():
craft.recipes[itemToCreate].craft(currentPlayer.inventory)
else:
print ("Sorry that item doesn't exist.")
return
#Meg's code... makes the numbered menus work
def displayMenuPrompt(options):
while True:
for num, item in options.items():
print (str(num) + " - " + item[0])
choice = input(">")
if not choice.isdigit():
print ("Please pick a number from 1 to %d. \n" % len(options))
continue
choice = int(choice)
if choice > 0 and choice <= len(options):
(optionDisplayText, optionInternalText) = options[choice]
print ("You picked option %d - %s\n" % (choice, optionDisplayText))
return optionInternalText
else:
print("Please pick a number from 1 to %d. \n" % len(options))
main()