-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmission_reward_click.py
144 lines (122 loc) · 3.82 KB
/
mission_reward_click.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
import keyboard
import mouse
import pyautogui
import time
from configuration import MouseConfiguration
from controller import click, double_click, focus_cabal
cfg_dict = {
"CHALLENGE_MISSION": {"X": 0, "Y": 0},
"REWARD": {"X": 0, "Y": 0},
"RECEIVE_REWARD": {"X": 0, "Y": 0},
"FIRST_ROW_1": {"X": 0, "Y": 0},
"FIRST_ROW_2": {"X": 0, "Y": 0},
"FIRST_ROW_3": {"X": 0, "Y": 0},
"FIRST_ROW_4": {"X": 0, "Y": 0},
"SECOND_ROW_1": {"X": 0, "Y": 0},
"SECOND_ROW_2": {"X": 0, "Y": 0},
"SECOND_ROW_3": {"X": 0, "Y": 0},
"SECOND_ROW_4": {"X": 0, "Y": 0},
"THIRD_ROW_1": {"X": 0, "Y": 0},
"THIRD_ROW_2": {"X": 0, "Y": 0},
"THIRD_ROW_3": {"X": 0, "Y": 0},
"THIRD_ROW_4": {"X": 0, "Y": 0},
"SELECT_CHANNEL": {"X": 0, "Y": 0},
"FIRST_CHANNEL": {"X": 0, "Y": 0},
"SECOND_CHANNEL": {"X": 0, "Y": 0},
"CHANGE_CHANNEL_ACCEPT": {"X": 0, "Y": 0},
}
cfg = MouseConfiguration(cfg_dict, "configs/reward_configuration.json")
cfg.load_configuration()
configuration = cfg.configuration
reward_configuration = {
"FIRST_ROW": 1,
"SECOND_ROW": 1,
"THIRD_ROW": 1,
"FOURTH_ROW": 1,
"FIFTH_ROW": 1,
}
CH_CONFIRM_PATH = "pics/mission_reward/channel_change_confirm.png"
F5_KEY = 0x3F
channel = configuration["FIRST_CHANNEL"]
def select_channel():
counter = 0
while True:
keyboard.send("o")
time.sleep(0.3)
click(
configuration["SELECT_CHANNEL"]["X"], configuration["SELECT_CHANNEL"]["Y"]
)
time.sleep(0.3)
decide_channel()
double_click(channel["X"], channel["Y"])
time.sleep(0.3)
try:
if pyautogui.locateOnScreen(CH_CONFIRM_PATH, confidence=0.9) is not None:
break
counter += 1
if counter > 1:
break
except pyautogui.ImageNotFoundException as ex:
print(f"locate on screen - confirm path - exception: {ex}")
def decide_channel():
global channel
if channel == configuration["FIRST_CHANNEL"]:
channel = configuration["SECOND_CHANNEL"]
else:
channel = configuration["FIRST_CHANNEL"]
def collect_rewards(e):
row_1 = configuration[
list(reward_configuration.keys())[0]
+ "_"
+ str(reward_configuration["FIRST_ROW"])
]
row_2 = configuration[
list(reward_configuration.keys())[1]
+ "_"
+ str(reward_configuration["SECOND_ROW"])
]
row_3 = configuration[
list(reward_configuration.keys())[2]
+ "_"
+ str(reward_configuration["THIRD_ROW"])
]
row_4 = configuration[
list(reward_configuration.keys())[2]
+ "_"
+ str(reward_configuration["FOURTH_ROW"])
]
row_5 = configuration[
list(reward_configuration.keys())[2]
+ "_"
+ str(reward_configuration["FIFTH_ROW"])
]
if e.event_type == "down":
click(
configuration["CHALLENGE_MISSION"]["X"],
configuration["CHALLENGE_MISSION"]["Y"],
)
click(configuration["REWARD"]["X"], configuration["REWARD"]["Y"])
click(row_1["X"], row_1["Y"])
click(row_2["X"], row_2["Y"])
click(row_3["X"], row_3["Y"])
mouse.wheel(-1)
time.sleep(0.1)
double_click(row_4["X"], row_4["Y"])
time.sleep(0.1)
mouse.wheel(-1)
double_click(row_5["X"], row_5["Y"])
select_channel()
click(
configuration["RECEIVE_REWARD"]["X"], configuration["RECEIVE_REWARD"]["Y"]
)
click(
configuration["CHANGE_CHANNEL_ACCEPT"]["X"],
configuration["CHANGE_CHANNEL_ACCEPT"]["Y"],
)
def main():
focus_cabal()
keyboard.hook_key(F5_KEY, collect_rewards, suppress=True)
while not keyboard.is_pressed("f12"):
time.sleep(0.5)
if __name__ == "__main__":
main()