-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.py
268 lines (242 loc) · 10.7 KB
/
engine.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
import random
import math
import loading
class Barry:
'Total Badass'
name = "Barry"
BarryCount = 0
def __init__(self, happyness, cash):
self.happyness = happyness
self.cash = cash
def displayHappyness(self):
loading.load_string("Happyness level : " + str(self.happyness), 70)
def displayCash(self):
loading.load_string("Cash : " + str(self.cash), 70)
def changeMeter(self, meter, value):
if meter == 'cash':
self.cash = self.cash + value
loading.load_string("Cash gained/lost: " + str(value), 70)
self.displayCash()
elif meter == 'happy':
self.happyness = self.happyness + value
loading.load_string("Happiness gained/lost: " + str(value), 70)
self.displayHappyness()
else:
print "Invalid input. Cash or Happy"
def continueGame():
print "Continue to tomorrow? Y or N"
valid_input = False
while valid_input == False:
user_input = raw_input()
if user_input == "Y":
valid_input = True
elif user_input == "N":
print "Goodbye!"
exit()
else:
print "Please enter Y or N"
def createEventsList(eventsDict):
events = []
i = 0
while i < 7:
x = random.randint(1, len(eventsDict))
probType = random.randint(1,4)
if eventsDict[str(x)]['selected'] == False:
eventsDict[str(x)]['selected'] = True
i += 1
probDiff = eventsDict[str(x)]['difficulty']
prob, answer = createQAs(probType, probDiff)
events.append([str(x), [prob, answer]])
else:
pass
return events
def createQAs(type, diff):
if type == 1: #multiplication
prob, answer = createMulti(diff)
elif type == 2: # division
prob, answer = createDiv(diff)
elif type == 3: # factorial
prob, answer = createFactorial(diff)
else: # powers
prob, answer = createPowers(diff)
return prob, answer
def createMulti(diff):
num1 = diff * random.randint(9,12)
num2 = diff * random.randint(5,8)
return str(num1) + " * " + str(num2) + " = ?", num1*num2
def createDiv(diff):
# print "Remember to round down."
num1 = diff * random.randint(23, 127)
num2 = random.randint(3, 10)
return str(num1) + " / " + str(num2) + " = ?", num1/num2
def createFactorial(diff):
if diff == 1:
num1 = random.randint(4, 5)
elif diff == 2:
num1 = random.randint(5, 6)
elif diff == 3:
num1 = random.randint(6, 7)
else:
num1 = random.randint(8, 9)
return str(num1) + "!" + " = ?", math.factorial(num1)
def createPowers(diff):
num1 = random.randint(3, 7)
num2 = diff * random.randint(2, 3)
return str(num1) + "^" + str(num2) + " = ?", math.pow(num1, num2)
def playDayAndNight(daysEventsList, barry):
loading.load_string("Welcome to the Life of Barold!", 25)
loading.load_string("You have happiness, you have cash. Make more cash and get more happy by solving problems at work!",40)
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
for i in range(0,7):
print "----" + days[i] +"----"
playDay(barry, daysEventsList[i])
continueGame()
print "End game stats: "
barry.displayHappyness()
barry.displayCash()
def playDay(barry, dayEventValues): # day is an integer value ranging from 0 to 6
loading.load_string("The start of a new day! You roll out of bed, stretching and yawning, preparing yourself to take on the day, whatever it entails. You are on-call this week, so you should be kept busy.", 200)
loading.load_string("You sit at your desk and wait for the work to come...", 50)
loading.loading(1, 3)
loading.load_string("Event!!\n" + dayEvents[dayEventValues[0]]['name'])
loading.load_string(dayEvents[dayEventValues[0]]['descrip'], 80)
loading.load_string("SOLVE THIS PROBLEM: (NO CALCULATORS, USE MENTAL MATH! :-) )", 20)
loading.loading(1, 6)
loading.load_string( dayEventValues[1][0]) # prints math q
answerIsInt = False
while answerIsInt == False:
answer = raw_input()
try:
answer = int(answer)
answerIsInt= True
except:
print "Please enter an integer"
if int(answer) == dayEventValues[1][1]:
loading.playSound('woohoo')
loading.load_string("CORRECT!")
happyChange = dayEvents[dayEventValues[0]]['passEffect'][1]
cashChange = dayEvents[dayEventValues[0]]['passEffect'][0]
barry.changeMeter('cash', cashChange)
barry.changeMeter('happy', happyChange)
else:
loading.playSound('doh')
loading.load_string("WRONGO!")
happyChange = dayEvents[dayEventValues[0]]['failEffect'][1]
cashChange = dayEvents[dayEventValues[0]]['failEffect'][0]
barry.changeMeter('cash', cashChange)
barry.changeMeter('happy', happyChange)
"""DICTIONARIE(S)"""
dayEvents = {
'1': {
'name': 'Emergency meeting! - SERVER UPGRADE GONE ROGUE',
'descrip': 'Your bosses call you and your coworkers for an emergency meeting. Boss B accidentally authorized a server upgrade that hadn\'t been cleared for implementation and now the upgrade is causing havoc on your client\'s servers.\nAfter Boss B passes the blame to the lack of communication skills of an employee on the technical team, they ask you, the "chosen one" to help fix this fiasco.' ,
'difficulty': 4, # 1-3
'passEffect': [300, 25],
'failEffect': [150, -75],
'selected': False
},
'2': {
'name': 'Emergency situation! - DATA LOSS',
'descrip': 'One of your coworkers went out of town while he was on call and didn\'t bring his beeper with him. So when there was a hard drive failure in the RAID 5 array he was supposed to be watching, he was unaware of it and therefore could not take the appropriate course of action nor could he contact someone to take the appropriate course of action. Soon thereafter, another disk failed, resulting in permanent data loss. Explain to your bosses that the data is lost forever.' ,
'difficulty': 3, # 1-3
'passEffect': [150, 0],
'failEffect': [150, -75],
'selected': False
},
'3': {
'name': 'Routine Work - OVERSEAS COWORKERS',
'descrip': 'Some of your coworkers live and work abroad in countries whose populaces struggle heavily with the basics of the English language. Every now and then you have to coordinate with them to complete projects. After having worked with these coworkers a few times now, you\'ve learned that when you ask them if they can do something, they always say yes, regardless of whether or not they can actually do it. If they can\'t do it, then you have to do it. Lucky you, this happens to be one of the instances where they can do what they say they can do.' ,
'difficulty': 1, # 1-3
'passEffect': [200, 25],
'failEffect': [150, -30],
'selected': False
},
'4': {
'name': 'Routine Work - OVERSEAS COWORKERS',
'descrip': 'Some of your coworkers live and work abroad in countries whose populaces struggle heavily with the basics of the English language. Every now and then you have to coordinate with them to complete projects. After having worked with these coworkers a few times now, you\'ve learned that when you ask them if they can do something, they always say yes, regardless of whether or not they can actually do it. If they can\'t do it, then you have to do it. UNLUCKY for you, this is one of those cases where they CANNOT do it.' ,
'difficulty': 3, # 1-3
'passEffect': [300, 25],
'failEffect': [100, -75],
'selected': False
},
'5': {
'name': 'Routine Work - A Okay :)',
'descrip': 'No problems today, everything is running smoothly. You decided to relax and catch up on some tv.' ,
'difficulty': 1, # 1-3
'passEffect': [200, 25],
'failEffect': [150, 0],
'selected': False
},
'6': {
'name': 'Routine Work - A Okay :)',
'descrip': 'No problems today, everything is running smoothly. You decided to relax and catch up on some tv.' ,
'difficulty': 1, # 1-3
'passEffect': [200, 25],
'failEffect': [150, 0],
'selected': False
},
'7': {
'name': 'Special Mission - IN THE CLOUD',
'descrip': 'One of your bosses call you in for a special meeting. They tell you how one of them read an article in People about how the Cloud is an important technology for business that want to stay relevant. He wants you to be in charge of migrating the company\'s data to the cloud. He\'s charted a few airplanes to help you get the data there and gives you a company credit card to buy things you\'ll need for this operation. Figure out how to give him what he wants.' ,
'difficulty': 4, # 1-3
'passEffect': [700, 50],
'failEffect': [150, -25],
'selected': False
},
'8': {
'name': 'Special Mission - SQUARE TRIANGLES',
'descrip': 'Your bosses inform you that one of your clients has requested the production of a square triangle. The square triangle will be used in another project with a completion deadline of 1 month from today. The purpose of the web app is to help users optimize workflow, predict future outcomes, and flourish regardless of future market conditions using the power of the cloud. Figure out how to give them what they want.' ,
'difficulty': 3, # 1-3
'passEffect': [300, 25],
'failEffect': [150, -50],
'selected': False
},
'9': {
'name': 'Routine Work - Maintenance',
'descrip': 'You attempt to perform routine maintenance.' ,
'difficulty': 2, # 1-3
'passEffect': [200, 25],
'failEffect': [150, -25],
'selected': False
},
'10': {
'name': 'Routine Work - Maintenance',
'descrip': 'You attempt to perform routine maintenance.' ,
'difficulty': 2, # 1-3
'passEffect': [200, 25],
'failEffect': [150, -25],
'selected': False
},
'11': {
'name': 'Routine Work - Half Day',
'descrip': 'Some of your bosses rock. Bob, is one of those bosses, tells you that if you can do quick server configuration for a special client, you can take the rest of the day off.' ,
'difficulty': 1, # 1-3
'passEffect': [300, 35],
'failEffect': [150, 0],
'selected': False
},
'12': {
'name': 'Routine Work - Server Upgrade',
'descrip': 'It\'s a routine server upgrade that\'s been tested in a controlled environment. What could possibly go wrong? Murphy\'s law - Whatever can go wrong will go wrong.' ,
'difficulty': 3, # 1-3
'passEffect': [300, 25],
'failEffect': [150, -50],
'selected': False
},
'13': {
'name': 'Routine Work - Maintenance',
'descrip': 'You attempt to perform routine maintenance.' ,
'difficulty': 2, # 1-3
'passEffect': [200, 25],
'failEffect': [150, -25],
'selected': False
},
'14': {
'name': 'Routine Work - Server Upgrade',
'descrip': 'It\'s a routine server upgrade that\'s been tested in a controlled environment. What could possibly go wrong? Murphy\'s law - Whatever can go wrong will go wrong.' ,
'difficulty': 3, # 1-3
'passEffect': [300, 25],
'failEffect': [150, -50],
'selected': False
}
}