| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- # This Python file uses the following encoding: utf-8
- # @author runhey
- # github https://github.com/runhey
- from time import sleep
- from datetime import time, datetime, timedelta
- from module.logger import logger
- from module.exception import TaskEnd
- from module.base.timer import Timer
- from tasks.GameUi.game_ui import GameUi
- from tasks.GameUi.page import page_main, page_delegation
- from tasks.Delegation.config import DelegationConfig
- from tasks.Delegation.assets import DelegationAssets
- class ScriptTask(GameUi, DelegationAssets):
- def run(self):
- self.ui_get_current_page()
- self.ui_goto(page_delegation)
- self.check_reward()
- con: DelegationConfig = self.config.delegation.delegation_config
- if con.miyoshino_painting:
- self.delegate_one('画')
- if con.bird_feather:
- self.delegate_one('鸟羽')
- if con.find_earring:
- self.delegate_one('寻找耳环')
- if con.cat_boss:
- self.delegate_one('猫老大')
- if con.miyoshino:
- self.delegate_one('接送')
- if con.strange_trace:
- self.delegate_one('痕迹')
- self.set_next_run(task='Delegation', success=True, finish=True)
- raise TaskEnd
- def delegate_one(self, name: str) -> bool:
- """
- 委派一个任务
- :param name:
- :return:
- """
- def ui_click(click, stop):
- while 1:
- self.screenshot()
- if self.appear(stop):
- break
- if self.click(click, interval=1.5):
- continue
- logger.hr('Delegation one', 2)
- self.O_D_NAME.keyword = name
- self.screenshot()
- if not self.ocr_appear(self.O_D_NAME):
- logger.warning(f'Delegation: {name} not found')
- return False
- while 1:
- self.screenshot()
- if self.appear(self.I_D_START):
- break
- # 如果出现’召回‘ ’返回‘ 说明这个是现在委派中
- # 需要退出
- if self.appear(self.I_D_BACK):
- logger.warning(f'Delegation: {name} is in delegation')
- self.ui_click_until_disappear(self.I_D_BACK)
- self.wait_until_appear(self.I_REWARDS_MIN)
- return False
- if self.appear_then_click(self.I_D_SKIP, interval=0.8):
- continue
- if self.appear_then_click(self.I_D_CONFIRM, interval=0.8):
- continue
- if self.ocr_appear_click(self.O_D_NAME, interval=1):
- continue
- # 进入委派 fefe e fe
- logger.info(f'Enter Delegation: {name}')
- ui_click(self.C_D_1, self.I_D_SELECT_1)
- ui_click(self.C_D_2, self.I_D_SELECT_2)
- ui_click(self.C_D_3, self.I_D_SELECT_3)
- ui_click(self.C_D_4, self.I_D_SELECT_4)
- # 委派开始
- logger.info(f'Delegation: {name} start')
- while 1:
- self.screenshot()
- if not self.appear(self.I_D_START):
- break
- if self.click(self.C_D_5, interval=0.8):
- continue
- if self.appear_then_click(self.I_D_START, interval=1.8):
- continue
- # ui_click(self.C_D_5, self.I_D_SELECT_5)
- # self.ui_click_until_disappear(self.I_D_START)
- def check_reward(self):
- check_timer = Timer(3)
- check_timer.start()
- while 1:
- self.screenshot()
- if self.appear_then_click(self.I_REWARDS_GET, interval=1):
- check_timer.reset()
- continue
- if self.appear_then_click(self.I_REWARDS_CHAT, interval=1):
- check_timer.reset()
- continue
- if self.appear_then_click(self.I_CHAT_1, interval=1):
- check_timer.reset()
- continue
- if self.appear_then_click(self.I_CHAT_2, interval=1):
- check_timer.reset()
- continue
- if self.appear_then_click(self.I_REWARDS_DONE, interval=1):
- check_timer.reset()
- continue
- if self.appear_then_click(self.I_REWARDS_FALSE, interval=1):
- check_timer.reset()
- continue
- if not self.appear(self.I_REWARDS_MIN):
- continue
- if check_timer.reached():
- break
- if self.ocr_appear_click(self.O_D_DONE, interval=1):
- check_timer.reset()
- continue
- if __name__ == '__main__':
- from module.config.config import Config
- from module.device.device import Device
- c = Config('oas1')
- d = Device(c)
- t = ScriptTask(c, d)
- # t.delegate_one('弥助的画')
- t.run()
|