generated from Code-Institute-Org/python-essentials-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
212 lines (175 loc) · 8.25 KB
/
run.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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
def welcome():
print(" \\ // | ")
print(" \\ // | ")
print(" \\ // ____ | ___ ___ ___ ")
print(" \\ /\ // | | | | | | |\/| | | ")
print(" \\//\\// |____| | | | | | | |___| ")
print(" \/ \/ |____ | |___ |___| | | |___ ")
def cinema():
print(' ====== ')
print('|| ')
print('|| . ')
print('|| _____ ___ __ __ ')
print('|| | | | |___| | | | /\| ')
print('|| | | | | | | | | | ')
print(' ====== | | | |___ | | | \/| ')
def zoo():
print('====== ')
print(' // ')
print(' // ')
print(' // ___ ___ ')
print(' // | | | | ')
print('// | | | | ')
print('====== |___| |___| ')
def flower():
print(' ______ ')
print(' | | ')
print(' |______ | ')
print(' | | ___ ___ ')
print(' | | | | \ / |___| |/\ ')
print(' | | | | \ /\ / | | ')
print(' | | |___| \/ \/ |___ | ')
def chocolate():
print(' _____ ')
print('| | | | ')
print('| | | __|__ ')
print('| |___ ___ ___ ___ | | ___ ')
print('| | | | | | | | | /\| | |___| ')
print('| | | | | | | | | | | | | ')
print('|_____ | | |___| |___ |___| | \/| | |___ ')
def kite():
print(' /|\ ')
print(' /_|_\ ')
print(' \ \ | / ')
print(' \ \|/ ')
print(' \ | ')
print(' \ ___/ ')
def goodbye():
print('_____ ')
print('| | | ')
print('| | | ')
print('| ___ ___ ___ ___| | _ ___ ')
print('| | | | | | / | |/ \ \ / |___| ')
print('| | | | | | | | | | | | ')
print('|____| |___| |___| \__/| |\__/ | |___ ')
words = {
'noun': ['Mountain', 'Ocean', 'Building', 'Playground', 'Animal'],
'adjective': ['Running', 'Walking', 'Cycling', 'Sleeping', 'Eating'],
'person': ['Mother', 'Father', 'Sister', 'Brother', 'Friend', 'Husband'],
'place': ['Farm', 'Beach', 'Work', 'School', 'City'],
'weather': ['Sun', 'Raining', 'Sleat', 'Wind', 'Snow', 'Storm'],
'animal': ['Dog', 'Cat', 'Goldfish', 'Hamster'],
'color': ['red', 'green', 'blue', 'orange', 'purple'],
'bird': ['Robin', 'Blackbird', 'Crow', 'Goldfinch'],
'proverb': ["Every cloud has a silver lining", "No news is good news"],
}
# Dictionary to hold the extended configurations
extended = {
'animal': {
'Dog': "Dog called Bluebell",
'Cat': "Cat called Tinkerbell",
'Goldfish': "Goldfish called Goldie",
'Hamster': "Hanster called Hammie"
},
'color': {
'red': "shiny red",
'green': "bottle green",
'blue': "bright blue",
'orange': "burnt orange",
'purple': "dark purple",
},
}
# Dict for the stories
stories = {
'cinema': "{person}, {animal} and I went to drive in cinema at {place}."
"We could see the {noun} in the distance and the {weather} there."
"A {bird} spend entire film flying in front of {color} screen."
"When the film was over the {proverb} appearered on screen and I woke up.",
'zoo': "I went to the zoo with my {person} and {animal}."
"We were {adjective} near tiger habitat in the {color} {weather}."
"A {bird} were flying around our heads.It was an enjoyable day."
"The announcer on intercom said {proverb} then I woke up.",
'flower': "I was {adjective} by flowers in the {place}."
"The flowers were {color} and had a lovely scent."
"A bird flew past in the direction of the {noun} singing {proverb}"
"and I woke up.",
'chocolate': "! was {adjective} and had chilli flavoured chocolate bar"
" that I shared with my {person}."
"We were at {place} and over looking the {noun}."
"The {color} {weather} was amazing."
"The chocolate bar wrapper had {proverb} written on it and i woke up.",
'kite': "Myself and {animal} were flying a {color} kite at beach."
"When a {bird} flew into it causing it to fall to ground next"
"to my {person} writing {proverb} in the sand it was all a dream.",
}
configuration = {
'story': ['cinema', 'zoo', 'flower', 'chocolate', 'kite'],
'options': ['extended', 'short'],
'titles': {
'cinema': cinema,
'zoo': zoo,
'flower': flower,
'chocolate': chocolate,
'kite': kite
}
}
class StoryManager:
def __init__(self, select_extended=False):
self.selection = {}
self.select_extended = select_extended
self.extended = False
def select_story(self):
return self.select_values('story', configuration)
def print_story_title(self, story):
configuration['titles'][story]()
def select_story_options(self):
selection = self.select_values('options', configuration)
self.extended = True if selection == 'extended' else False
return self.extended
def select_values(self, key, dict_of_values=words):
items = dict_of_values[key]
for count, value in enumerate(items):
print("{}: {}".format(count+1, value))
selection = -1
valid_input = False
item = None
while not valid_input:
input_value = input("Select a '{}' form the list above: [1..{}]: "
.format(key, len(items)))
try:
selection = int(input_value)
item = items[selection-1]
valid_input = True
except (ValueError, IndexError):
valid_input = False
return item
def start(self):
story = self.select_story()
print(story)
self.print_story_title(story)
if self.select_extended:
self.select_story_options()
self.selection = {}
for k, _ in words.items():
value = self.select_values(k)
# If extended is True the current value gets replaced
# by its extended version if exists.
if self.extended is True:
for extended_key, _ in extended.items():
if k == extended_key and value in extended[k].keys():
value = extended[k][value]
self.selection[k] = value
self.print_story(story)
def print_story(self, story):
story_string = stories[story]
print(f"{story_string}".format(**self.selection))
def welcome(self):
welcome()
def goodbye(self):
goodbye()
def main():
story_manager = StoryManager(select_extended=True)
story_manager.welcome()
story_manager.start()
story_manager.goodbye()
main()