-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathumamusume.py
505 lines (419 loc) · 19.4 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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# This Python file uses the following encoding: utf-8
# 解像度 960x540 で作ってあるので、実行前にNoxの解像度を変更して下さい。
# pip install -U android-auto-play-opencv
from android_auto_play_opencv import AapoManager
import datetime
import traceback
# ↓複数デバイスを同時に操作したい場合、コメントを外す。
#import inquirer # pip install inquirer
import os
adbpathCandidates = [
'C:\\Program Files\\Nox\\bin\\',
'C:\\Program Files (x86)\\Nox64\\bin\\',
'C:\\Program Files (x86)\\Nox\\bin\\',
'D:\\Program Files\\Nox\\bin\\'
]
ROBY_STABLE = 5 # ロビー安定を判断する回数
aapo: AapoManager = None
# 実行フォルダ取得
file_path: str = os.path.dirname(__file__)
# 実行フォルダが取得できない場合、カレントフォルダを指定
if file_path == '':
file_path = '.'
print('終わらせたい時はCtrl+C')
def main():
global aapo
adbpath: str = None
for i in range(len(adbpathCandidates)):
if(os.path.exists(adbpathCandidates[i]) == True):
adbpath = adbpathCandidates[i]
break
if adbpath is None:
print('adb.exe が見つからないため、終了します。')
return
aapo = AapoManager(adbpath)
mode: int = 0 # モード0(リセット)
folderName: str = ''
stackCount: int = 0
present_ok: bool = False
robyCount: int = 0 # ロビーカウンタ(変数の初期化)
GATYA_INIT_SETTING_IS_PRETTYDARBY = True
# ↓複数デバイスを同時に操作したい場合、コメントを外す。
#devicesselect = [
# inquirer.List(
# "device",
# message="デバイスを選択して下さい。",
# choices=aapo.adbl.devices
# )
#]
#selected = inquirer.prompt(devicesselect)
#aapo.adbl.setdevice(selected['device'])
# スタート
start()
print('■■■ リセマラ 開始 ■■■')
while True:
# 画面キャプチャ
aapo.screencap()
# 早送りボタンは常にタップ
if aapo.touchImg(file_path +'/umamusume/hayaokuri.png'):
# タップ出来たら待機
aapo.sleep(1)
# 通信エラー時は、タイトルへを押す)
elif aapo.chkImg(file_path +'/umamusume/communicationerror.png'):
aapo.touchImg(file_path +'/umamusume/tothetitle.png')
aapo.sleep(1)
# Google Playダイアログが出たら、キャンセルボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/google-play.png'):
aapo.touchImg(file_path +'/umamusume/cancel.png')
aapo.sleep(1)
# アカウント連携ダイアログが出たら、後でするボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/account.png'):
print('■■■ アカウント連携設定のお願い -> 後で ■■■')
aapo.touchImg(file_path +'/umamusume/atode.png')
aapo.sleep(1)
# チュートリアルダイアログが出たら、スキップボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/tutorial.png'):
print('■■■ チュートリアル確認 -> スキップ ■■■')
aapo.touchImg(file_path +'/umamusume/skip.png')
aapo.sleep(1)
# トレーナー登録ダイアログが出たら、
elif aapo.chkImg(file_path +'/umamusume/trainer.png'):
print('■■■ トレーナー登録 開始 ■■■')
# トレーナー名入力の位置をタップ
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)
print('■■■ トレーナー登録 終了 ■■■')
# データダウンロードダイアログが出たら、OKボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/datadownload.png'):
print('■■■ データダウンロード -> OK ■■■')
aapo.touchImg(file_path +'/umamusume/ok.png')
aapo.sleep(1)
# お知らせダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/osirase.png'):
print('■■■ お知らせ -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# おさんぽチュートリアルが出たら、次へボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/osanpo.png'):
print('■■■ おさんぽ 開始 ■■■')
# 次へボタンの位置を3回タップ
aapo.touchPos(270, 900)
aapo.sleep(1)
aapo.touchPos(270, 900)
aapo.sleep(1)
aapo.touchPos(270, 900)
aapo.sleep(1)
print('■■■ おさんぽ 終了 ■■■')
# 外部リンク確認
elif aapo.chkImg(file_path +'/umamusume/gaibulink.png'):
print('■■■ 外部リンク確認 -> キャンセル ■■■')
# キャンセルボタンをタップ
aapo.touchImg(file_path +'/umamusume/cancel.png')
aapo.sleep(1)
# 交換確認
elif aapo.chkImg(file_path +'/umamusume/koukankakunin.png'):
print('■■■ 交換確認 -> 閉じる ■■■')
# 閉じるボタンをタップ
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# 商品追加ダイアログが出たら、キャンセルボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/syohin-tuika.png'):
print('■■■ 商品追加 -> キャンセル ■■■')
aapo.touchImg(file_path +'/umamusume/cancel.png')
aapo.sleep(1)
# ピックアップ選択ダイアログが出たら、キャンセルボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/pickup-sentaku.png'):
print('■■■ ピックアップ選択 -> キャンセル ■■■')
aapo.touchImg(file_path +'/umamusume/cancel.png')
aapo.sleep(1)
# メインストーリー開放ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/main-story.png'):
print('■■■ メインストーリー解放 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# ウマ娘ストーリー開放ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/umamusume-story.png'):
print('■■■ ウマ娘ストーリー解放 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# ウマ娘詳細ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/umamusume-syosai.png'):
print('■■■ ガチャ登場育成ウマ娘詳細 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# 楽曲獲得ダイアログが出たら、閉じるボタンをタップ
elif aapo.chkImg(file_path +'/umamusume/gakkyoku.png'):
print('■■■ 楽曲取得 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# 日付が変わりましたが表示されたら、
elif aapo.chkImg(file_path +'/umamusume/newday.png'):
print('■■■ 日付変更 -> OK ■■■')
aapo.touchImg(file_path +'/umamusume/OK.png')
aapo.sleep(1)
# 受取完了ダイアログが出たら、閉じるの位置をタップ
elif aapo.chkImg(file_path +'/umamusume/uketorikanryo.png'):
print('■■■ 受取完了 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# 衣装獲得ダイアログが出たら、閉じるの位置をタップ
elif aapo.chkImg(file_path +'/umamusume/isyoget.png'):
print('■■■ 衣装獲得 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# ガチャストック通知が出たら、閉じるの位置をタップ
elif aapo.chkImg(file_path +'/umamusume/gatyaStockNotification.png'):
print('■■■ ガチャストック通知 -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# プレゼントダイアログが出たら、一括受取の位置をタップ
elif present_ok == False and aapo.chkImg(file_path +'/umamusume/present.png'):
print('■■■ プレゼント -> 一括受取 ■■■')
aapo.touchImg(file_path +'/umamusume/ikkatuuketori1.png')
present_ok = True
aapo.sleep(1)
# プレゼントを受け取った後で一括受取が押せなくなったら、閉じるの位置をタップ
elif present_ok == True and aapo.chkImg(file_path +'/umamusume/ikkatuuketori2.png'):
print('■■■ プレゼント -> 閉じる ■■■')
aapo.touchImg(file_path +'/umamusume/close.png')
aapo.sleep(1)
# ガチャボタンを見つけたら、ロビーと判断し、プレゼントを受け取っていない場合、
elif present_ok == False and aapo.chkImg(file_path +'/umamusume/roby.png'):
# お知らせが差し込まれる場合があるため、ロビーが安定するまで、robyStable回空ループさせる。
robyCount += 1
if robyCount < ROBY_STABLE:
print(f'■ ロビー待機: {robyCount} -> プレゼント')
aapo.sleep(1) # 小休止を入れる
continue
robyCount = 0
# プレゼントの位置をタップ
aapo.touchPos(490, 680)
aapo.sleep(1)
# ガチャボタンを見つけたら、ロビーと判断し、プレゼントを受け取った後、
elif present_ok == True and aapo.chkImg(file_path +'/umamusume/roby.png'):
# 実績ログが終わるまで待機(メニューボタンが隠れて押せないから)
robyCount += 1
if robyCount < ROBY_STABLE:
print(f'■ ロビー待機: {robyCount} -> データ連携')
aapo.sleep(1) # 小休止を入れる
continue
robyCount = 0
# メニューボタンの位置をタップ
aapo.touchPos(490, 50)
aapo.sleep(2)
print('■■■ データ連携 開始 ■■■')
# データ連携の位置をタップ1
aapo.screencap()
aapo.sleep(1)
aapo.touchImg(file_path +'/umamusume/data-renkei.png')
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()
# フォルダ名がカラの場合セット
now_datatime_string = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
if len(folderName) == 0: folderName = now_datatime_string
# スクショを保存
aapo.imgSave(f'gatya/{folderName}/screenshot_{now_datatime_string}.png')
print('■■■ データ連携 終了 ■■■')
aapo.sleep(1)
# 閉じるの位置をタップ
aapo.touchPos(270, 630)
aapo.sleep(3)
# ガチャボタンの位置をタップ
aapo.touchPos(480, 930)
aapo.sleep(2)
# 無料ガチャボタンがあれば引く。
elif aapo.touchImg(file_path +'/umamusume/onegatyaforfree.png'):
# タップ出来たら待機
aapo.sleep(1)
# ガチャを引く!
elif aapo.touchImg(file_path +'/umamusume/gatyahiku.png'):
print('■■■ ガチャを引く ■■■')
# タップ出来たら待機
aapo.sleep(1)
# もう1回引くボタンをタップ
elif aapo.touchImg(file_path +'/umamusume/pickagain.png'):
print('■■■ もう一回引く ■■■')
# タップ出来たら待機
aapo.sleep(1)
# 購入するボタンが出たら、ガチャ終了
elif aapo.chkImg(file_path +'/umamusume/konyusuru.png'):
print('■■■ リセマラ 終了 ■■■')
# リセット
reset()
# スタート
start()
mode = 0 # モード0(リセット)
folderName = ''
stackCount = 0
robyCount = 0
present_ok = False
# ガチャ結果
elif aapo.chkImg(file_path +'/umamusume/gatya-kekka.png'):
# フォルダ名がカラの場合セット
now_datatime_string = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
if len(folderName) == 0: folderName = now_datatime_string
# スクショを保存
aapo.sleep(1)
aapo.screencap() # スクリーンリフレッシュ(写真が取れない場合がある。ボタン押下時のタイマーよりここのほうが確実な気がする。)
aapo.imgSave(f'gatya/{folderName}/screenshot_{now_datatime_string}.png')
aapo.sleep(2)
# 左上にピンクガチャタイトルが出た時
elif aapo.chkImg(file_path +'/umamusume/gatyaselected.png'):
# 無償の10回引くボタンがあるか?
if aapo.touchImg(file_path +'/umamusume/10-kaihiku.png'):
aapo.sleep(1)
else:
# 無ければ、次のページへ
aapo.touchPos(460, 580)
aapo.sleep(1)
# モードが0(リセット)の場合
elif mode == 0:
# ハンバーガーメニューボタンをタップ
if aapo.touchImg(file_path +'/umamusume/hanba-ga-menu.png'):
print('■■■ ユーザーデータ削除 開始 ■■■')
# タップ出来たら待機
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)
print('■■■ ユーザーデータ削除 終了 ■■■')
# 閉じるの位置をタップ
aapo.touchPos(270, 630)
aapo.sleep(1)
# モードを1(チュートリアル)に変更
mode = 1
# モードが1(チュートリアル)の場合
elif mode == 1:
# ロゴをタップ
if aapo.touchImg(file_path +'/umamusume/logo.png'):
# タップ出来たら待機
aapo.sleep(1)
# 同意をタップ
elif aapo.touchImg(file_path +'/umamusume/doui.png'):
# タップ出来たら待機
aapo.sleep(1)
# スタック対策 起動後STARTが表示されない、アンドロイド画面(アプリが落ちた場合)
if aapo.chkImg(file_path +'/umamusume/stack.png') or \
aapo.chkImg(file_path +'/umamusume/umamusumegameicon.png'):
print(f'スタック: {stackCount}')
aapo.sleep(1)
stackCount = stackCount + 1
if stackCount > 10:
# リセット
reset()
# スタート
start()
mode = 0 # モード0(リセット)
folderName = ''
stackCount = 0
robyCount = 0
present_ok = False
else:
stackCount = 0
def start():
# アプリ起動
aapo.start(
'jp.co.cygames.umamusume/jp.co.cygames.umamusume_activity.UmamusumeActivity')
aapo.sleep(10)
return
def reset():
print('■■■ キャッシュ削除 開始 ■■■')
# ホームキーを押す
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(file_path +'/umamusume/umamusumegameicon.png')
if found:
aapo.longTouchPos(x, y, 1000)
aapo.sleep(1)
# プロパティ表示
aapo.screencap()
aapo.touchImg(file_path +'/umamusume/appproperty.png')
aapo.sleep(1)
# ストレージ表示
aapo.screencap()
aapo.touchImg(file_path +'/umamusume/calculatingstorage.png')
aapo.sleep(1)
# キャッシュを削除
aapo.screencap()
aapo.touchImg(file_path +'/umamusume/clearcache.png')
aapo.sleep(1)
# タスクキーを押す
aapo.inputkeyevent(187)
aapo.sleep(1)
# すべて消去の位置をタップ
aapo.touchPos(700, 55)
aapo.sleep(1)
print('■■■ キャッシュ削除 終了 ■■■')
return
# メイン関数を実行(Ctrl+Cで終了)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
except Exception:
print(traceback.format_exc())
input('エンターキーを押すと終了します。')