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

Method _mail

tasks/DemonEncounter/script_task.py:239–303  ·  view source on GitHub ↗
(self, target_click)

Source from the content-addressed store, hash-verified

237 pass
238
239 def _mail(self, target_click):
240 # 答题,还没有碰到过答题的
241 def answer():
242 click_match = {
243 1: self.C_ANSWER_1,
244 2: self.C_ANSWER_2,
245 3: self.C_ANSWER_3,
246 }
247 index = None
248 self.screenshot()
249 question = self.O_LETTER_QUESTION.detect_text(self.device.image)
250 question = question.replace('?', '').replace('?', '')
251 answer_1 = self.O_LETTER_ANSWER_1.detect_text(self.device.image)
252 answer_2 = self.O_LETTER_ANSWER_2.detect_text(self.device.image)
253 answer_3 = self.O_LETTER_ANSWER_3.detect_text(self.device.image)
254 if answer_1 == '其余选项皆对':
255 index = 1
256 elif answer_2 == '其余选项皆对':
257 index = 2
258 elif answer_3 == '其余选项皆对':
259 index = 3
260 if not index:
261 index = answer_one(question=question, options=[answer_1, answer_2, answer_3])
262 logger.info(f'Question: {question}, Answer: {index}')
263 return click_match[index]
264
265 while 1:
266 self.screenshot()
267 if self.appear(self.I_LETTER_CLOSE):
268 break
269 if self.click(target_click, interval=1):
270 continue
271 logger.info('Question answering Start')
272 for i in range(1,4):
273 # 还未测试题库无法识别的情况
274 logger.hr(f'Answer {i}', 3)
275 answer_click = answer()
276 # self.ui_get_reward(answer())
277 while 1:
278 self.screenshot()
279 if self.ui_reward_appear_click():
280 time.sleep(0.5)
281 while 1:
282 self.screenshot()
283 # 等待动画结束
284 if not self.appear(self.I_UI_REWARD, threshold=0.6):
285 logger.info('Get reward success')
286 break
287 # 一直点击
288 if self.ui_reward_appear_click():
289 continue
290 break
291 # 如果没有出现红色关闭按钮,说明答题结束
292 if not self.appear(self.I_LETTER_CLOSE):
293 time.sleep(0.5)
294 self.screenshot()
295 if self.appear(self.I_LETTER_CLOSE):
296 continue

Callers 1

execute_lanternMethod · 0.95

Calls 5

appearMethod · 0.80
sleepMethod · 0.80
screenshotMethod · 0.45
clickMethod · 0.45

Tested by

no test coverage detected