forked from AdriaGual/marvel-snap-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_agatha.py
77 lines (63 loc) · 2.27 KB
/
start_agatha.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
from utils import android_connection, global_utils
import logging
import info
import hand_cards
import time
import config
import turn
import clear_tmp
import sys
logging.basicConfig(
filename=config.project_path + "\\log.txt",
filemode="w",
format="%(asctime)s %(message)s",
datefmt="%m/%d/%Y %I:%M:%S %p",
level=logging.DEBUG,
)
logging.getLogger().addHandler(logging.StreamHandler())
android_connection.connect()
counter = 0
last_move = [0, 0, 0]
while 1:
global_utils.click([284, 46])
# Take a screenhot and get its dimensions
screenshot = global_utils.take_screenshot("tmp\\" + str(counter) + ".png")
screenshot_dimensions = screenshot.shape
# Click the icon menu to go to play if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\go_to_play_button.png", screenshot
)
# Click the play button if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\play_button.png", screenshot
)
# Click the next button if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\next_button.png", screenshot
)
# Click the collect rewards button if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\turns\\collect_rewards.png", screenshot
)
# Get the turn information, 0 if not found
player_turn = turn.get_turn(screenshot, screenshot_dimensions, False)
# While turn not found
while player_turn == 0:
# Take a screenshot of the actual field
screenshot = global_utils.take_screenshot("tmp\\" + str(counter) + ".png")
screenshot_dimensions = screenshot.shape
# Get the turn information, 0 if not found
player_turn = turn.get_turn(screenshot, screenshot_dimensions, False)
# Click the play button if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\play_button.png", screenshot
)
# Click the next button if its in the screen
global_utils.find_and_click(
config.project_path + "\\images\\next_button.png", screenshot
)
# Click the End Turn button
global_utils.click([755, 1487])
counter += 1
# if False:
clear_tmp.clear()