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

Method run

tasks/WantedQuests/script_task.py:25–76  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

23class ScriptTask(SecretScriptTask, GeneralInvite, WantedQuestsAssets):
24
25 def run(self):
26 con = self.config
27 self.pre_work()
28 self.screenshot()
29 number_challenge = self.O_WQ_NUMBER.ocr(self.device.image)
30 O_TEXT_COPY_1 = copy.deepcopy(self.O_WQ_TEXT_1)
31 O_TEXT_COPY_2 = copy.deepcopy(self.O_WQ_TEXT_2)
32 O_TEXT_COPY_1.keyword = '封印'
33 O_TEXT_COPY_2.keyword = '封印'
34 ocr_error_count = 0
35 while 1:
36 self.screenshot()
37 if self.appear(self.I_WQ_BOX):
38 self.ui_get_reward(self.I_WQ_BOX)
39 continue
40 if ocr_error_count > 10:
41 logger.warning('OCR failed too many times, exit')
42 break
43 if self.ocr_appear(self.O_WQ_TEXT_1, interval=0.7) or self.ocr_appear(O_TEXT_COPY_1, interval=0.7):
44 cu, re, total = self.O_WQ_NUM_1.ocr(self.device.image)
45 if cu == re == total == 0:
46 logger.warning('OCR failed and skip this round')
47 ocr_error_count += 1
48 if cu > total:
49 logger.warning('Current number of wanted quests is greater than total number')
50 cu = cu % 10
51 if cu < total and re != 0:
52 self.execute_mission(self.O_WQ_TEXT_1, total, number_challenge)
53 continue
54 if self.ocr_appear(self.O_WQ_TEXT_2, interval=0.7) or self.ocr_appear(O_TEXT_COPY_1, interval=0.7):
55 cu, re, total = self.O_WQ_NUM_2.ocr(self.device.image)
56 if cu == re == total == 0:
57 logger.warning('OCR failed and skip this round')
58 ocr_error_count += 1
59 if cu > total:
60 logger.warning('Current number of wanted quests is greater than total number')
61 cu = cu % 10
62 if cu < total and re != 0:
63 self.execute_mission(self.O_WQ_TEXT_2, total, number_challenge)
64 continue
65
66 if self.appear(self.I_WQ_CHECK_TASK):
67 continue
68 sleep(1.5)
69 self.screenshot()
70 if not self.appear(self.I_WQ_CHECK_TASK):
71 logger.info('No wanted quests')
72 break
73
74
75 self.next_run()
76 raise TaskEnd('WantedQuests')
77
78 def next_run(self):
79 before_end: time = self.config.wanted_quests.wanted_quests_config.before_end

Callers 1

script_task.pyFile · 0.45

Calls 9

pre_workMethod · 0.95
execute_missionMethod · 0.95
next_runMethod · 0.95
TaskEndClass · 0.90
ocrMethod · 0.80
appearMethod · 0.80
ui_get_rewardMethod · 0.80
screenshotMethod · 0.45
ocr_appearMethod · 0.45

Tested by

no test coverage detected