forked from noitaro/python-umamusume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumamusume.py
367 lines (317 loc) · 13.3 KB
/
umamusume.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# This Python file uses the following encoding: utf-8
# 解像度 960x540 で作ってあるので、実行前にNoxの解像度を変更して下さい。
# pip install android-auto-play-opencv
import android_auto_play_opencv as am
import datetime
# import inquirer # pip install inquirer
#adbpath = 'C:\\Program Files\\Nox\\bin\\'
adbpath = 'C:\\Program Files (x86)\\Nox\\bin\\'
aapo = None
#ターゲットガチャの選択
GET_PRETTY_DARBY_GATYA = True #サポートガチャをターゲットにする場合は、Falseにする。
if GET_PRETTY_DARBY_GATYA == True:
#20210828現在、無料ガチャは、プリティガチャの先なので、左から
GATYA_PAGE_FEED_CW = False #サポートガチャをページ送り方向(True:右周り)
else:
GATYA_PAGE_FEED_CW = True #サポートガチャをページ送り方向(False:左周り)
def main():
global aapo
aapo = am.AapoManager(adbpath)
mode = 0 # モード0(リセット)
folderName = ''
stackCount = 0
robyCount = 0 #ロビーカウンタ(変数の初期化)
robyStable = 5 #ロビー安定を判断する回数
# ↓複数デバイスを同時に操作したい場合、コメントを外す。
#devicesselect = [
# inquirer.List(
# "device",
# message="デバイスを選択して下さい。",
# choices=aapo.adbl.devices
# )
#]
#selected = inquirer.prompt(devicesselect)
#aapo.adbl.setdevice(selected['device'])
# スタート
start()
while True:
# 画面キャプチャ
aapo.screencap()
# 早送りボタンは常にタップ
if aapo.touchImg('./umamusume/hayaokuri.png'):
# タップ出来たら待機
aapo.sleep(1)
# Google Playダイアログが出たら、キャンセルの位置をタップ
elif aapo.chkImg('./umamusume/google-play.png'):
aapo.touchPos(135, 630)
aapo.sleep(1)
# アカウント連携ダイアログが出たら、後でするの位置をタップ
elif aapo.chkImg('./umamusume/account.png'):
aapo.touchPos(135, 630)
aapo.sleep(1)
# チュートリアルダイアログが出たら、スキップの位置をタップ
elif aapo.chkImg('./umamusume/tutorial.png'):
aapo.touchPos(270, 630)
aapo.sleep(1)
# トレーナー登録ダイアログが出たら、
elif aapo.chkImg('./umamusume/trainer.png'):
# トレーナー名入力の位置をタップ
aapo.touchPos(405, 430)
aapo.sleep(1)
# abc と入力
aapo.inputtext('abc')
aapo.sleep(1)
# トレーナー名入力の位置をタップ
aapo.touchPos(270, 430)
aapo.sleep(1)
# 登録ボタンの位置をタップ1
aapo.touchPos(270, 630)
aapo.sleep(1)
# 登録ボタンの位置をタップ2
aapo.touchPos(270, 630)
aapo.sleep(1)
# OKボタンの位置をタップ
aapo.touchPos(405, 630)
aapo.sleep(1)
# データダウンロードダイアログが出たら、OKの位置をタップ
elif aapo.chkImg('./umamusume/datadownload.png'):
aapo.touchPos(405, 630)
aapo.sleep(1)
# お知らせダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg('./umamusume/osirase.png'):
aapo.touchImg('./umamusume/close.png')
aapo.sleep(1)
# メインストーリー開放ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg('./umamusume/main-story.png'):
aapo.touchImg('./umamusume/close.png')
aapo.sleep(1)
# ウマ娘ストーリー開放ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg('./umamusume/umamusume-story.png'):
aapo.touchImg('./umamusume/close.png')
aapo.sleep(1)
# ウマ娘詳細ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg('./umamusume/umamusume-syosai.png'):
aapo.touchImg('./umamusume/close.png')
aapo.sleep(1)
#衣装獲得、プレゼント
elif aapo.chkImg('./umamusume/gotClothes.png') or aapo.chkImg('./umamusume/present.png'):
aapo.touchImg('./umamusume/close.png')
aapo.sleep(1)
#通信エラー時は、タイトルへを押す)
elif aapo.chkImg('./umamusume/communicationerror.png') :
aapo.touchImg('./umamusume/tothetitle.png')
aapo.sleep(1)
# ガチャボタンを見つけたら、ロビーと判断
elif aapo.chkImg('./umamusume/roby.png'):
#お知らせが差し込まれる場合があるため、ロービーが安定するまで、robyStable回空ループさせる。
robyCount += 1
if robyCount < robyStable:
aapo.sleep(1) #小休止を入れる
continue
robyCount = 0
# フォルダ名がカラの場合セット
if len(folderName) == 0:
folderName = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
# プレゼントの位置をタップ
aapo.touchPos(490, 680)
aapo.sleep(1)
# 一括受取の位置をタップ
aapo.touchPos(405, 890)
aapo.sleep(1)
# 閉じるの位置をタップ1
aapo.touchPos(270, 890)
aapo.sleep(1)
# 閉じるの位置をタップ2
aapo.touchPos(135, 890)
aapo.sleep(1)
# 実績ログが終わるまで10秒ほど待機(メニューボタンが隠れて押せないから)
aapo.sleep(10)
# メニューボタンの位置をタップ
aapo.touchPos(490, 50)
aapo.sleep(1)
# データ連携の位置をタップ1
aapo.touchPos(410, 640)
aapo.sleep(1)
# データ連携の位置をタップ2
aapo.touchPos(405, 640)
aapo.sleep(1)
# 連携パスワードの位置をタップ
aapo.touchPos(450, 550)
aapo.sleep(1)
# 設定の位置をタップ
aapo.touchPos(405, 640)
aapo.sleep(1)
# 連携パスワード入力の位置をタップ
aapo.touchPos(270, 405)
aapo.sleep(1)
# 1qazXSW2 と入力
aapo.inputtext('1qazXSW2')
aapo.sleep(1)
# 確認入力の位置をタップ1
aapo.touchPos(270, 505)
aapo.sleep(1)
# 確認入力の位置をタップ2
aapo.touchPos(270, 505)
aapo.sleep(1)
# 1qazXSW2 と入力
aapo.inputtext('1qazXSW2')
aapo.sleep(1)
# プライバシーポリシーの位置をタップ1
aapo.touchPos(135, 620)
aapo.sleep(1)
# プライバシーポリシーの位置をタップ2
aapo.touchPos(135, 620)
aapo.sleep(1)
# OKの位置をタップ
aapo.touchPos(405, 680)
aapo.sleep(1)
# 画面キャプチャ
aapo.screencap()
# スクショを保存
aapo.imgSave('gatya/' + folderName + '/screenshot_' +
datetime.datetime.now().strftime('%Y%m%d%H%M%S') + '.png')
aapo.sleep(1)
# 閉じるの位置をタップ
aapo.touchPos(270, 630)
aapo.sleep(3)
# ガチャボタンの位置をタップ
aapo.touchPos(480, 930)
aapo.sleep(2)
# サポートカードの位置をタップ
# aapo.touchPos(460, 580)
# aapo.sleep(1)
# 無料ガチャボタンがあれば引く。
elif aapo.touchImg('./umamusume/onegatyaforfree.png'):
# タップ出来たら待機
aapo.sleep(1)
# ガチャを引く!
elif aapo.touchImg('./umamusume/gatyahiku.png'):
# タップ出来たら待機
aapo.sleep(1)
# ガチャ結果
elif aapo.chkImg('./umamusume/gatya-kekka.png'):
# フォルダ名がカラの場合セット
if len(folderName) == 0:
folderName = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
# スクショを保存
aapo.imgSave('gatya/' + folderName + '/screenshot_' +
datetime.datetime.now().strftime('%Y%m%d%H%M%S') + '.png')
aapo.sleep(1)
# もう1回引くの位置をタップ
if aapo.touchImg('./umamusume/pickagain.png'): #aapo.touchPos(480, 890)
aapo.sleep(1)
# または、okボタン位置をタップ(無料ガチャのケース)
elif aapo.touchImg('./umamusume/ok.png'):
aapo.sleep(1)
# 購入するボタンが出たら、ガチャ終了
elif aapo.chkImg('./umamusume/konyusuru.png'):
# リセット
reset()
# スタート
start()
mode = 0 # モード0(リセット)
folderName = ''
# 左上ピンクのガチャタイトルが出たら、対象ガチャのページに移動、10連ガチャボタンを表示させる
elif aapo.chkImg('./umamusume/gatyaselected.png'):
if GET_PRETTY_DARBY_GATYA:
found = aapo.chkImg('./umamusume/gatyaprettydarby.png')
else:
found = aapo.chkImg('./umamusume/gatyasupportcard.png')
if found:
#10回引く!
aapo.touchImg('./umamusume/10-kaihiku.png')
else:
#次のページへ
if GATYA_PAGE_FEED_CW:
aapo.touchPos(460, 580) # > 右周り
else:
aapo.touchPos( 80, 580) # < 左周り
aapo.sleep(1)
#continue
# モードが0(リセット)の場合
elif mode == 0:
# ハンバーガーメニューボタンをタップ
if aapo.touchImg('./umamusume/hanba-ga-menu.png'):
# タップ出来たら待機
aapo.sleep(1)
# ユーザーデータ削除の位置をタップ1
aapo.touchPos(270, 750)
aapo.sleep(1)
# ユーザーデータ削除の位置をタップ2
aapo.touchPos(405, 630)
aapo.sleep(1)
# ユーザーデータ削除の位置をタップ3
aapo.touchPos(405, 630)
aapo.sleep(1)
# 閉じるの位置をタップ
aapo.touchPos(270, 630)
aapo.sleep(1)
# モードを1(チュートリアル)に変更
mode = 1
# モードが1(チュートリアル)の場合
elif mode == 1:
# ロゴをタップ
if aapo.touchImg('./umamusume/logo.png'):
# タップ出来たら待機
aapo.sleep(1)
# 同意をタップ
elif aapo.touchImg('./umamusume/doui.png'):
# タップ出来たら待機
aapo.sleep(1)
# スタック対策(起動後STARTが表示されない、アンドロイド画面(アプリが落ちた場合))
if aapo.chkImg('./umamusume/stack.png') or aapo.chkImg('./umamusume/umamusumegameicon.png'):
aapo.sleep(1)
stackCount = stackCount + 1
if stackCount > 10:
# リセット
reset()
# スタート
start()
mode = 0 # モード0(リセット)
folderName = ''
stackCount = 0
else:
stackCount = 0
def start():
# アプリ起動
aapo.start(
'jp.co.cygames.umamusume/jp.co.cygames.umamusume_activity.UmamusumeActivity')
aapo.sleep(10)
return
def reset():
# ホームキーを押す
aapo.inputkeyevent(3)
aapo.sleep(1)
# タスクキーを押す
aapo.inputkeyevent(187)
aapo.sleep(1)
# すべて消去の位置をタップ
aapo.touchPos(700, 55)
aapo.sleep(1)
#ウマ娘アイコンを探して、ロングタップ、キャッシュを消す
aapo.screencap()
found, x, y = aapo.chkImg2('./umamusume/umamusumeGameIcon.png')
if found:
aapo.longTouchPos( x,y, 1000 )
aapo.sleep(1)
# プロパティ表示
aapo.screencap()
aapo.touchImg('./umamusume/appproperty.png')
aapo.sleep(1)
# ストレージ表示
aapo.screencap()
aapo.touchImg('./umamusume/calculatingstorage.png')
aapo.sleep(1)
# キャッシュを削除
aapo.screencap()
aapo.touchImg('./umamusume/clearcache.png')
aapo.sleep(1)
# タスクキーを押す
aapo.inputkeyevent(187)
aapo.sleep(1)
# すべて消去の位置をタップ
aapo.touchPos(700, 55)
aapo.sleep(1)
return
if __name__ == '__main__':
main()