2023-10-14 16:32:40 +00:00
|
|
|
from module.base.timer import Timer
|
|
|
|
from module.logger import logger
|
2023-10-19 02:10:18 +00:00
|
|
|
from tasks.rogue.assets.assets_rogue_weekly import CLAIM_ALL, REWARD_CHECK, REWARD_CLOSE, REWARD_ENTER, REWARD_RED_DOT
|
2023-10-14 16:32:40 +00:00
|
|
|
from tasks.rogue.bleesing.ui import RogueUI
|
|
|
|
|
|
|
|
|
|
|
|
class RogueRewardHandler(RogueUI):
|
|
|
|
def _rogue_reward_appear(self) -> bool:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: is_page_rogue_main()
|
|
|
|
"""
|
|
|
|
if self.image_color_count(REWARD_RED_DOT, color=(214, 45, 47), threshold=221, count=50):
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _rogue_reward_enter(self, skip_first_screenshot=True):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: is_page_rogue_main()
|
|
|
|
out: REWARD_CHECK
|
|
|
|
"""
|
|
|
|
logger.info('Rogue reward enter')
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if self.appear(REWARD_CHECK):
|
|
|
|
break
|
|
|
|
|
|
|
|
if self.appear_then_click(REWARD_ENTER, interval=2):
|
|
|
|
continue
|
|
|
|
|
|
|
|
def _rogue_reward_exit(self, skip_first_screenshot=True):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: REWARD_CHECK
|
|
|
|
out: is_page_rogue_main()
|
|
|
|
"""
|
|
|
|
logger.info('Rogue reward exit')
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if self.is_page_rogue_main():
|
|
|
|
break
|
|
|
|
|
|
|
|
if self.appear_then_click(REWARD_CLOSE, interval=2):
|
|
|
|
continue
|
|
|
|
if self.handle_reward():
|
|
|
|
continue
|
|
|
|
|
|
|
|
def _rogue_reward_claim(self, skip_first_screenshot=True):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: REWARD_CHECK, CLAIM_ALL
|
|
|
|
out: REWARD_CHECK
|
|
|
|
"""
|
|
|
|
logger.info('Rogue reward claim')
|
|
|
|
claimed = False
|
|
|
|
appear = False
|
2023-10-23 14:36:40 +00:00
|
|
|
click_count = 0
|
2023-10-14 16:32:40 +00:00
|
|
|
timeout = Timer(2, count=10).start()
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if claimed:
|
|
|
|
if self.appear(REWARD_CHECK):
|
2023-10-23 14:36:40 +00:00
|
|
|
return True
|
2023-10-14 16:32:40 +00:00
|
|
|
if self.is_page_rogue_main():
|
2023-10-23 14:36:40 +00:00
|
|
|
return True
|
2023-10-14 16:32:40 +00:00
|
|
|
if not appear and timeout.reached():
|
|
|
|
logger.warning('Rogue reward claim timeout, CLAIM_ALL not found')
|
2023-10-23 14:36:40 +00:00
|
|
|
return False
|
|
|
|
if click_count > 3:
|
|
|
|
logger.warning('Failed to claim weekly rewards, probably because immersifier is full')
|
|
|
|
return False
|
2023-10-14 16:32:40 +00:00
|
|
|
|
|
|
|
if self.handle_reward():
|
|
|
|
claimed = True
|
|
|
|
continue
|
|
|
|
if self.interval_is_reached(CLAIM_ALL, interval=1):
|
|
|
|
if self.image_color_count(CLAIM_ALL, color=(255, 199, 89), threshold=221, count=500):
|
|
|
|
self.device.click(CLAIM_ALL)
|
2023-10-18 13:43:26 +00:00
|
|
|
self.interval_reset(CLAIM_ALL, interval=1)
|
2023-10-14 16:32:40 +00:00
|
|
|
appear = True
|
2023-10-23 14:36:40 +00:00
|
|
|
click_count += 1
|
2023-10-14 16:32:40 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
def rogue_reward_claim(self):
|
|
|
|
"""
|
|
|
|
Claim possible rogue rewards.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool: If claimed.
|
|
|
|
|
|
|
|
Pages:
|
|
|
|
in: is_page_rogue_main()
|
|
|
|
out: is_page_rogue_main()
|
|
|
|
"""
|
2023-10-14 20:20:25 +00:00
|
|
|
logger.hr('Rogue reward claim', level=2)
|
2023-10-14 16:32:40 +00:00
|
|
|
if self._rogue_reward_appear():
|
|
|
|
self._rogue_reward_enter()
|
2023-10-23 14:36:40 +00:00
|
|
|
success = self._rogue_reward_claim()
|
2023-10-14 16:32:40 +00:00
|
|
|
self._rogue_reward_exit()
|
2023-10-23 14:36:40 +00:00
|
|
|
return success
|
2023-10-14 16:32:40 +00:00
|
|
|
else:
|
|
|
|
logger.info('No rogue reward')
|
|
|
|
return False
|