2023-12-26 15:44:20 +00:00
|
|
|
from module.base.timer import Timer
|
2024-01-17 10:53:33 +00:00
|
|
|
from module.daemon.daemon_base import DaemonBase
|
2024-01-17 11:08:16 +00:00
|
|
|
from module.device.method import maatouch
|
2023-12-26 15:44:20 +00:00
|
|
|
from module.logger import logger
|
|
|
|
from tasks.base.assets.assets_base_daemon import *
|
|
|
|
from tasks.base.main_page import MainPage
|
|
|
|
from tasks.base.page import page_main, page_rogue
|
|
|
|
from tasks.daily.assets.assets_daily_camera import PICTURE_TAKEN
|
|
|
|
from tasks.map.assets.assets_map_bigmap import TELEPORT_RIGHT
|
2024-01-17 10:53:33 +00:00
|
|
|
from tasks.map.interact.aim import AimDetectorMixin
|
2023-12-26 15:44:20 +00:00
|
|
|
from tasks.rogue.route.base import RouteBase
|
|
|
|
|
|
|
|
|
2024-01-17 11:08:16 +00:00
|
|
|
class SecondaryMaatouchBuilder(maatouch.MaatouchBuilder):
|
|
|
|
def __init__(self, device, contact=0, handle_orientation=False):
|
|
|
|
"""
|
|
|
|
Click on secondary contact to avoid interruption of real-person contact
|
|
|
|
"""
|
|
|
|
super().__init__(device, contact=1, handle_orientation=handle_orientation)
|
|
|
|
|
|
|
|
|
|
|
|
maatouch.MaatouchBuilder = SecondaryMaatouchBuilder
|
|
|
|
|
|
|
|
|
2024-01-17 10:53:33 +00:00
|
|
|
class Daemon(RouteBase, DaemonBase, AimDetectorMixin):
|
|
|
|
aim_interval = Timer(0.3, count=1)
|
|
|
|
|
|
|
|
def handle_aim_click(self, item=True, enemy=True):
|
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
item:
|
|
|
|
enemy:
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool: If clicked
|
|
|
|
"""
|
|
|
|
if not item and not enemy:
|
|
|
|
return False
|
|
|
|
if not self.is_in_main():
|
|
|
|
return False
|
|
|
|
|
|
|
|
if self.aim_interval.reached_and_reset():
|
|
|
|
self.aim.predict(self.device.image, item=item, enemy=enemy)
|
|
|
|
if self.aim.aimed_enemy:
|
|
|
|
if self.handle_map_A():
|
|
|
|
return True
|
|
|
|
if self.aim.aimed_item:
|
|
|
|
if self.handle_map_A():
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2023-12-26 15:44:20 +00:00
|
|
|
def run(self):
|
|
|
|
# Rebind daemon settings along with rogue settings
|
|
|
|
self.config.bind('Daemon', func_list=['Rogue'])
|
2024-01-17 11:08:16 +00:00
|
|
|
# Check contact
|
|
|
|
builder = self.device.maatouch_builder
|
|
|
|
if builder.contact >= 1:
|
|
|
|
logger.info(f'Maatouch contact on {builder.contact}')
|
|
|
|
else:
|
|
|
|
logger.warning(f'Maatouch contact on {builder.contact}, may cause interruptions')
|
2023-12-26 15:44:20 +00:00
|
|
|
|
2024-02-07 00:14:05 +00:00
|
|
|
STORY_OPTION.set_search_offset((-5, -5, 32, 5))
|
|
|
|
INTERACT_COLLECT.set_search_offset((-5, -5, 32, 5))
|
|
|
|
INTERACT_INVESTIGATE.set_search_offset((-5, -5, 32, 5))
|
|
|
|
INTERACT_TREASURE.set_search_offset((-5, -5, 32, 5))
|
|
|
|
|
2023-12-26 15:44:20 +00:00
|
|
|
teleport_confirm = Timer(1, count=5)
|
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# Check lang
|
|
|
|
if not MainPage._lang_checked and self.ui_page_appear(page_main, interval=5):
|
|
|
|
self.handle_lang_check(page=page_main)
|
|
|
|
# Check again
|
|
|
|
if not MainPage._lang_check_success:
|
|
|
|
MainPage._lang_checked = False
|
|
|
|
# Story
|
|
|
|
if self.appear_then_click(STORY_NEXT, interval=0.7):
|
|
|
|
self.interval_reset(STORY_OPTION)
|
2024-01-12 15:58:22 +00:00
|
|
|
# self.interval_reset(INTERACT_INVESTIGATE)
|
2023-12-26 15:44:20 +00:00
|
|
|
continue
|
|
|
|
if self.appear_then_click(STORY_OPTION, interval=1):
|
2024-01-12 15:58:22 +00:00
|
|
|
# self.interval_reset(INTERACT_INVESTIGATE)
|
2024-01-07 02:44:20 +00:00
|
|
|
continue
|
|
|
|
# Map interact
|
|
|
|
if self.appear_then_click(INTERACT_TREASURE, interval=1):
|
|
|
|
continue
|
2024-01-12 15:58:22 +00:00
|
|
|
# if self.appear_then_click(INTERACT_INVESTIGATE, interval=2):
|
|
|
|
# continue
|
2024-01-07 02:44:20 +00:00
|
|
|
if self.appear_then_click(INTERACT_COLLECT, interval=1):
|
2023-12-26 15:44:20 +00:00
|
|
|
continue
|
|
|
|
# Story teleport
|
|
|
|
if self.appear_then_click(TELEPORT_RIGHT, interval=3):
|
|
|
|
teleport_confirm.reset()
|
|
|
|
continue
|
|
|
|
if teleport_confirm.started() and not teleport_confirm.reached():
|
|
|
|
if self.handle_popup_confirm():
|
|
|
|
logger.info(f'{TELEPORT_RIGHT} -> popup')
|
|
|
|
continue
|
|
|
|
# Chat
|
|
|
|
if self.appear_then_click(CHAT_OPTION, interval=3):
|
|
|
|
continue
|
|
|
|
if self.appear_then_click(CHAT_CLOSE, interval=3):
|
|
|
|
continue
|
|
|
|
# Popup
|
|
|
|
if self.handle_reward(interval=1.5):
|
|
|
|
continue
|
|
|
|
if self.handle_ui_close(PICTURE_TAKEN, interval=1):
|
|
|
|
continue
|
|
|
|
# Rogue
|
|
|
|
if self.handle_blessing():
|
|
|
|
continue
|
|
|
|
if self.ui_page_appear(page_rogue):
|
|
|
|
if self.handle_event_continue():
|
|
|
|
continue
|
|
|
|
if self.handle_event_option():
|
|
|
|
continue
|
2024-01-17 10:53:33 +00:00
|
|
|
# Aim click
|
|
|
|
if self.handle_aim_click(
|
|
|
|
item='item' in self.config.Daemon_AimClicker,
|
|
|
|
enemy='enemy' in self.config.Daemon_AimClicker,
|
|
|
|
):
|
|
|
|
continue
|