-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
317 lines (291 loc) · 8.13 KB
/
game.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
__author__ = 'Colby'
# execfile('game.py') to import into python console to use
# get_cords for gettings game button x and y positions
from gameCoordinates import *
from mouseEvents import *
from imageTools import *
"""
Recipes:
onigiri: 2 rice, 1 nori
caliroll: 1 rice, 1 nori, 1 roe
gunkan: 1 roce, 1 nori, 2 roe
"""
# starting ingredient numbers
foodStock = {
'rice': 10,
'nori': 10,
'roe': 10
}
# sushi order grayscale sum values
sushiValue = {
7577: 'gunkan',
9762: 'onigiri',
13109: 'caliroll'
}
# blank seats values
blankSeats = {
'seatOne': 15727,
'seatTwo': 18607,
'seatThree': 23474,
'seatFour': 23658,
'seatFive': 20130,
'seatSix': 17072
}
####################################
def foldMat():
mousePos((557, 839))
leftClick()
time.sleep(0.5)
####################################
def makeFood(food):
if food == 'caliroll':
print("making calirol")
foodStock['rice'] -= 1;
foodStock['nori'] -= 1;
foodStock['roe'] -= 1;
mousePos(Cord.f_rice)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_nori)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_roe)
leftClick()
time.sleep(0.5)
foldMat()
time.sleep(2)
elif food == 'onigiri':
print("making onigiri")
foodStock['rice'] -= 2
foodStock['nori'] -= 1
mousePos(Cord.f_rice)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_rice)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_nori)
leftClick()
time.sleep(0.5)
foldMat()
time.sleep(2)
elif food == 'gunkan':
print("making gunkan")
foodStock['rice'] -= 1
foodStock['nori'] -= 1
foodStock['roe'] -= 2
mousePos(Cord.f_rice)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_nori)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_roe)
leftClick()
time.sleep(0.5)
mousePos(Cord.f_roe)
leftClick()
time.sleep(0.5)
foldMat()
time.sleep(2)
###############################################################
def clearTables():
mousePos((204, 500))
leftClick()
mousePos((458, 516))
leftClick()
mousePos((710, 519))
leftClick()
mousePos((968, 518))
leftClick()
mousePos((1209, 528))
leftClick()
mousePos((1475, 527))
leftClick()
time.sleep(2)
################################################################
def buyFood(food):
if food == 'rice':
mousePos(Cord.phone)
time.sleep(.5)
leftClick()
mousePos(Cord.menu_rice)
time.sleep(0.5)
leftClick()
im = screenGrab()
time.sleep(0.5)
if im.getpixel(Cord.buy_rice) != (127, 127, 127):
print('rice is AVAILABLE')
mousePos(Cord.buy_rice)
time.sleep(.5)
leftClick()
mousePos(Cord.delivery_norm)
print('BUYING RICE')
foodStock['rice'] += 10
time.sleep(.5)
leftClick()
time.sleep(3)
else:
print('rice is NOT AVAILABLE')
mousePos(Cord.t_exit)
leftClick()
time.sleep(2)
buyFood(food)
if food == 'nori':
mousePos(Cord.phone)
time.sleep(.5)
leftClick()
mousePos(Cord.menu_toppings)
time.sleep(0.5)
leftClick()
im = screenGrab()
time.sleep(0.5)
if im.getpixel(Cord.t_nori) != (33, 30, 11):
print('nori is AVAILABLE')
mousePos(Cord.t_nori)
time.sleep(.5)
leftClick()
mousePos(Cord.delivery_norm)
foodStock['nori'] += 10
time.sleep(.5)
leftClick()
time.sleep(3)
else:
print('nori is NOT AVAILABLE')
mousePos(Cord.t_exit)
leftClick()
time.sleep(2)
buyFood(food)
if food == 'roe':
mousePos(Cord.phone)
time.sleep(.5)
leftClick()
mousePos(Cord.menu_toppings)
time.sleep(0.5)
leftClick()
im = screenGrab()
time.sleep(0.5)
if im.getpixel(Cord.t_roe) != (109, 123, 127):
print('roe is AVAILABLE')
mousePos(Cord.t_roe)
time.sleep(.5)
leftClick()
mousePos(Cord.delivery_norm)
foodStock['roe'] += 10
time.sleep(.5)
leftClick()
time.sleep(3)
else:
print('roe is NOT AVAILABLE')
mousePos(Cord.t_exit)
leftClick()
time.sleep(2)
buyFood(food)
####################################################################
def checkFood():
for i, j in foodStock.items():
if j <= 4:
print('%s is running low, please order' % i)
buyFood(i)
####################################################################
def startGame():
# first play button
mousePos((883, 524))
leftClick()
time.sleep(1)
# second continue button
mousePos((887, 971))
leftClick()
time.sleep(2)
# third continue button
mousePos((925, 1020))
leftClick()
time.sleep(2)
# fourth skip button
mousePos((1477, 1154))
leftClick()
time.sleep(2)
# final continue button
mousePos((906, 928))
leftClick()
time.sleep(2)
def playGame():
checkFood()
orderOne = grabOrderOne() # this is a grayscale sum value
if orderOne != blankSeats['seatOne']:
if sushiValue.has_key(orderOne):
sushiOrder = sushiValue[orderOne]
print('Table One is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table One')
clearTables()
checkFood()
orderTwo = grabOrderTwo() # this is a grayscale sum value
if orderTwo != blankSeats['seatTwo']:
if sushiValue.has_key(orderTwo):
sushiOrder = sushiValue[orderTwo]
print('Table Two is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table Two')
clearTables()
checkFood()
orderThree = grabOrderOne() # this is a grayscale sum value
if orderThree != blankSeats['seatThree']:
if sushiValue.has_key(orderThree):
sushiOrder = sushiValue[orderThree]
print('Table Three is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table Three')
clearTables()
checkFood()
orderFour = grabOrderFour() # this is a grayscale sum value
if orderFour != blankSeats['seatFour']:
if sushiValue.has_key(orderFour):
sushiOrder = sushiValue[orderFour]
print('Table Four is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table Four')
clearTables()
checkFood()
orderFive = grabOrderFive() # this is a grayscale sum value
if orderFive != blankSeats['seatFive']:
if sushiValue.has_key(orderFive):
sushiOrder = sushiValue[orderFive]
print('Table Five is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table Five')
clearTables()
checkFood()
orderSix = grabOrderSix() # this is a grayscale sum value
if orderSix != blankSeats['seatSix']:
if sushiValue.has_key(orderSix):
sushiOrder = sushiValue[orderSix]
print('Table Five is ordering %s' % sushiOrder)
makeFood(sushiOrder)
else:
print('Sushi order not found')
else:
print('No one is at Table Six')
clearTables()
def main():
startGame()
while True:
playGame()
# Python convention to check if script is top level (only executes if ran by itself)
if __name__ == '__main__':
main()