MCPcopy Create free account
hub / github.com/runhey/OnmyojiAutoScript / run

Method run

tasks/CollectiveMissions/script_task.py:47–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 return rule
46
47 def run(self):
48 self.ui_get_current_page()
49 self.ui_goto(page_guild)
50 rule = self.config.collective_missions.missions_config.missions_rule
51 self.ui_click(self.I_CM_SHRINE, self.I_CM_CM)
52 self.ui_click(self.I_CM_CM, self.I_CM_RECORDS)
53 logger.info('Start to detect missions')
54 # 判断今天是否已经完成了, 还是多少次数的任务
55 self.screenshot()
56 current, remain, total = self.O_CM_NUMBER.ocr(self.device.image)
57 if current == total == 30:
58 logger.warning('Today\'s missions have been completed')
59 self.set_next_run(task='CollectiveMissions', success=False, finish=True)
60 raise TaskEnd('CollectiveMissions')
61 # 判断最优的任务是哪一个
62 mission, index = self.detect_best()
63 logger.info(f'Best mission is {mission}')
64 logger.info(f'Best mission index is {index}')
65 if mission == MC.BL:
66 # 契灵单独处理
67 self._bondling_fairyland(index)
68 elif mission == MC.AW1 or mission == MC.AW2 or mission == MC.AW3 \
69 or mission == MC.GR1 or mission == MC.GR2 or mission == MC.GR3:
70 # 其他就捐材料
71 self._donate(index)
72 elif mission == MC.SO1 or mission == MC.SO2:
73 # 御魂就捐御魂
74 self._soul(index)
75
76 # 退出
77 while 1:
78 self.screenshot()
79 if self.appear(self.I_CM_SHRINE) or self.appear(self.I_CHECK_MAIN):
80 break
81 if self.appear_then_click(self.I_UI_BACK_RED, interval=1):
82 continue
83 if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=1):
84 continue
85
86
87 self.set_next_run(task='CollectiveMissions', success=True, finish=True)
88 raise TaskEnd('CollectiveMissions')
89
90
91 def detect_one(self, ocr_1: RuleOcr, ocr_2: RuleOcr) -> MC:

Callers 1

script_task.pyFile · 0.45

Calls 13

ui_clickMethod · 0.95
detect_bestMethod · 0.95
_bondling_fairylandMethod · 0.95
_donateMethod · 0.95
_soulMethod · 0.95
TaskEndClass · 0.90
ui_get_current_pageMethod · 0.80
ui_gotoMethod · 0.80
ocrMethod · 0.80
set_next_runMethod · 0.80
appearMethod · 0.80
appear_then_clickMethod · 0.80

Tested by

no test coverage detected