2021-11-08 20:14:07 +08:00
|
|
|
from module.combat.assets import EXP_INFO_C, EXP_INFO_D
|
2021-10-25 18:49:56 +08:00
|
|
|
from module.daemon.daemon_base import DaemonBase
|
|
|
|
from module.exception import CampaignEnd
|
2021-09-27 15:01:53 +08:00
|
|
|
from module.logger import logger
|
2022-05-16 00:26:53 +08:00
|
|
|
from module.os.config import OSConfig
|
|
|
|
from module.os.fleet import OSFleet
|
|
|
|
from module.os_combat.combat import ContinuousCombat
|
2021-11-08 20:14:07 +08:00
|
|
|
from module.os_handler.assets import AUTO_SEARCH_REWARD
|
2022-04-15 03:37:54 +08:00
|
|
|
from module.os_handler.port import PORT_ENTER, PortHandler
|
2020-12-23 18:48:41 +08:00
|
|
|
|
|
|
|
|
2022-05-16 00:26:53 +08:00
|
|
|
class AzurLaneDaemon(DaemonBase, OSFleet, PortHandler):
|
2021-11-15 00:38:15 +08:00
|
|
|
def _os_combat_expected_end(self):
|
2022-05-31 23:04:40 +08:00
|
|
|
if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=2):
|
2021-11-15 00:38:15 +08:00
|
|
|
return False
|
|
|
|
|
|
|
|
return super()._os_combat_expected_end()
|
|
|
|
|
2021-10-25 18:49:56 +08:00
|
|
|
def run(self):
|
2022-05-16 00:26:53 +08:00
|
|
|
self.config.merge(OSConfig())
|
|
|
|
self.config.override(HOMO_EDGE_DETECT=False)
|
2020-12-23 18:48:41 +08:00
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# If is running a combat, do nothing.
|
|
|
|
if self.is_combat_executing():
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Combat
|
|
|
|
if self.combat_appear():
|
|
|
|
self.combat_preparation()
|
|
|
|
try:
|
2021-10-25 18:49:56 +08:00
|
|
|
if self.handle_battle_status():
|
|
|
|
self.combat_status(expected_end='no_searching')
|
2020-12-23 18:48:41 +08:00
|
|
|
continue
|
2021-03-31 17:13:11 +08:00
|
|
|
except (CampaignEnd, ContinuousCombat):
|
2020-12-23 18:48:41 +08:00
|
|
|
continue
|
2021-11-08 20:14:07 +08:00
|
|
|
if self.appear_then_click(EXP_INFO_C, interval=2):
|
|
|
|
continue
|
|
|
|
if self.appear_then_click(EXP_INFO_D, interval=2):
|
|
|
|
continue
|
2020-12-23 18:48:41 +08:00
|
|
|
|
2021-10-25 18:49:56 +08:00
|
|
|
# Map events
|
|
|
|
if self.handle_map_event():
|
2022-05-16 00:26:53 +08:00
|
|
|
self._nearest_object_click_timer.clear()
|
2020-12-23 18:48:41 +08:00
|
|
|
continue
|
2022-05-31 23:04:40 +08:00
|
|
|
if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=2):
|
2021-11-08 20:14:07 +08:00
|
|
|
continue
|
2020-12-23 18:48:41 +08:00
|
|
|
|
2021-09-27 15:01:53 +08:00
|
|
|
# Port repair
|
2021-10-25 18:49:56 +08:00
|
|
|
if self.config.OpsiDaemon_RepairShip:
|
|
|
|
if self.appear(PORT_ENTER, offset=(20, 20), interval=30):
|
|
|
|
self.port_enter()
|
|
|
|
self.port_dock_repair()
|
|
|
|
self.port_quit()
|
|
|
|
self.interval_reset(PORT_ENTER)
|
|
|
|
logger.info('Port repair finished, '
|
|
|
|
'please move your fleet out of the port in 30s to avoid repairing again')
|
2021-09-27 15:01:53 +08:00
|
|
|
|
2022-05-16 00:26:53 +08:00
|
|
|
if self.config.OpsiDaemon_SelectEnemy:
|
|
|
|
if self.click_nearest_object():
|
|
|
|
continue
|
|
|
|
|
2020-12-23 18:48:41 +08:00
|
|
|
# End
|
|
|
|
# No end condition, stop it manually.
|
|
|
|
|
2021-09-27 15:01:53 +08:00
|
|
|
return True
|
2021-10-25 18:49:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
b = AzurLaneDaemon('alas', task='OpsiDaemon')
|
|
|
|
b.run()
|