1414 Screen ,
1515 select_opponent ,
1616 touch_escape ,
17+ touch_escape_after_wait ,
1718 touch_escape_wait ,
1819 touch_img ,
1920 touch_img_wait ,
2021 touch_img_when_visible ,
2122 touch_img_when_visible_after_wait ,
2223 touch_img_when_visible_while_visible ,
2324 touch_xy ,
25+ touch_xy_after_wait ,
2426 touch_xy_wait ,
2527 wait ,
2628 wait_until_img_visible ,
@@ -36,43 +38,37 @@ def collect_afk_rewards() -> None:
3638 logger .info ("Collecting AFK rewards..." )
3739 reset_to_screen ()
3840
39- touch_xy_wait (550 , 1550 )
40- touch_img_wait ("buttons/collect" )
41- touch_xy_wait (550 , 1800 ) # Click campaign in case we level up
42- touch_xy_wait (550 , 1800 ) # again for the time limited deal popup
41+ touch_xy_after_wait (550 , 1550 , seconds = 0.1 )
42+ touch_img_when_visible ("buttons/collect" )
4343 logger .info ("AFK rewards collected!" )
4444
45+ touch_escape_after_wait () # In case we level up
46+ touch_img_when_visible ("labels/tap-anywhere-to-close" , timeout_s = 3 )
47+
4548
46- # TODO: Check if mail. If not, we do not need to touch_escape.
4749def collect_mail () -> None :
4850 logger .info ("Collecting mail..." )
4951 reset_to_screen ()
5052
51- if not (
52- touch_img_when_visible ("buttons/mail" )
53- and touch_img_when_visible ("buttons/collect_all" )
54- ):
55- logger .error ("Mail not found" )
56- else :
57- touch_escape ()
58- logger .info ("Mail collected!" )
53+ touch_img_when_visible ("buttons/mail" )
54+ touch_img_when_visible ("buttons/collect_all" )
55+ logger .info ("Mail collected!" )
5956
60- touch_img_when_visible_while_visible ("buttons/back" )
57+ # Note that if there is no mail we only need to escape once (no rewards)
58+ touch_escape_after_wait (0.1 ) # Clear rewards
59+ touch_escape_after_wait (0.1 ) # Exit
6160
6261
6362def send_and_receive_companion_points (mercs = False ) -> None :
6463 logger .info ("Sending/receiving companion points..." )
6564 reset_to_screen ()
6665
67- if not (
68- touch_img_when_visible ("buttons/friends" )
69- and touch_img_when_visible ("buttons/sendandreceive" )
70- ):
71- logger .error ("No friends" )
72- else :
73- logger .info ("Companion points sent/received" )
66+ touch_img_when_visible ("buttons/friends" )
67+ touch_img_when_visible ("buttons/sendandreceive" )
68+ logger .info ("Companion points sent/received" )
7469
7570 if mercs :
71+ logger .info ("Lending out mercs..." )
7672 touch_xy_wait (720 , 1760 ) # Short term
7773 touch_xy_wait (990 , 190 ) # Manage
7874 touch_xy_wait (630 , 1590 ) # Apply
@@ -93,17 +89,18 @@ def collect_fast_rewards(settings: CollectFastRewardsSettings) -> None:
9389 reset_to_screen ()
9490
9591 # Check whether the pixel where the notification dot is has a high enough red value
92+ wait_until_img_visible ("buttons/fastrewards" )
9693 if not check_pixel (980 , 1620 , 0 ) > 220 :
97- logger .warning ("Fast Rewards already done " )
94+ logger .warning ("Fast Rewards already collected " )
9895 return
9996
100- touch_xy_wait ( 950 , 1660 )
101- for i in range (settings ["times" ]):
102- touch_xy_wait (710 , 1260 , seconds = 3 )
103- touch_xy_wait ( 550 , 1800 )
97+ touch_img ( "buttons/fastrewards" )
98+ for _ in range (settings ["times" ]):
99+ touch_xy_after_wait (710 , 1260 ) # Button changes depending on use
100+ touch_escape_after_wait () # Clear rewards
104101 logger .info ("Fast rewards collected" )
105102
106- touch_img_wait ("buttons/close" )
103+ touch_img_when_visible ("buttons/close" )
107104
108105
109106# Loads and exits a campaign abttle for dailies quest
@@ -117,14 +114,12 @@ def attempt_campaign() -> None:
117114 # use location
118115 wait_until_img_visible ("buttons/formations" )
119116 touch_xy (700 , 1850 )
120- # Actions to exit an active fight and back out to the Campaign screen
121- # 3 retries as ulting heroes can cover the button
117+ logger . info ( " Campaign battle attempted" )
118+
122119 touch_img_when_visible ("buttons/pause" )
123120 touch_img_when_visible ("buttons/exitbattle" )
124121 touch_img_when_visible ("buttons/back" , timeout_s = 3 )
125122
126- logger .info ("Campaign battle attempted" )
127-
128123
129124class SoloBountySettings (TypedDict ):
130125 dust : bool
@@ -144,28 +139,26 @@ class DispatchBountiesSettings(DispatchSoloBountiesSettings):
144139 team_bounties : bool
145140
146141
147- # Handles the Bounty Board, calls dispatch_solo_bounties() to handle solo dust/diamond recognition and dispatching
148142def dispatch_bounties (settings : DispatchBountiesSettings ) -> None :
149143 logger .info ("Dispatching bounties..." )
150144 reset_to_screen (Screen .DARK_FOREST )
151145
152- touch_xy_wait (600 , 1320 ) # Open bounty board
146+ touch_xy_after_wait (600 , 1320 , seconds = 0.1 )
153147
154- if not locate_img ("labels/bountyboard" , retry = 3 ):
155- logger .error ("Bounty board not found" )
156- reset_to_screen (Screen .DARK_FOREST )
157- return
148+ wait_until_img_visible ("labels/bountyboard" )
158149
159150 if settings ["solo_bounties" ]:
160- touch_xy_wait (650 , 1700 ) # Solo tab
161- touch_img_wait ("buttons/collect_all" , seconds = 3 )
151+ touch_xy (650 , 1700 ) # Solo tab
152+ touch_img_when_visible_after_wait (
153+ "buttons/collect_all" , timeout_s = 1 , seconds = 0.1
154+ )
162155 dispatch_solo_bounties (settings )
163156
164157 if settings ["team_bounties" ]:
165- touch_xy_wait (950 , 1700 ) # Team tab
166- touch_img_wait ("buttons/collect_all" , seconds = 2 )
167- touch_img_wait ("buttons/dispatch" , confidence = 0.8 , grayscale = True )
168- touch_img_wait ("buttons/confirm" )
158+ touch_xy_after_wait (950 , 1700 , seconds = 0.1 ) # Team tab
159+ touch_img_when_visible ("buttons/collect_all" , timeout_s = 1 )
160+ touch_img_when_visible ("buttons/dispatch" )
161+ touch_img_when_visible ("buttons/confirm" )
169162
170163 # TODO::imgs-untested
171164 if settings ["event_bounties" ]:
@@ -178,7 +171,7 @@ def dispatch_bounties(settings: DispatchBountiesSettings) -> None:
178171
179172 logger .info ("Bounties dispatched" )
180173
181- touch_img_wait ("buttons/back" )
174+ touch_img_when_visible ("buttons/back" )
182175
183176
184177# Loops through the bounty board returning found Dispatch buttons for dispatcher() to handle
@@ -235,9 +228,6 @@ def dispatcher(dispatches, settings: SoloBountySettings) -> None:
235228 break # done processing this dispatch button
236229
237230
238- # TODO::imgs-untested below
239-
240-
241231class ChallengeSettings (TypedDict ):
242232 battles : int
243233
0 commit comments