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

Method battle_wait

tasks/Orochi/script_task.py:415–472  ·  view source on GitHub ↗

重写战斗等待 # https://github.com/runhey/OnmyojiAutoScript/issues/95 :param random_click_swipt_enable: :return:

(self, random_click_swipt_enable: bool)

Source from the content-addressed store, hash-verified

413 return False
414
415 def battle_wait(self, random_click_swipt_enable: bool) -> bool:
416 """
417 重写战斗等待
418 # https://github.com/runhey/OnmyojiAutoScript/issues/95
419 :param random_click_swipt_enable:
420 :return:
421 """
422 # 重写
423 self.device.stuck_record_add('BATTLE_STATUS_S')
424 self.device.click_record_clear()
425 self.C_REWARD_1.name = 'C_REWARD'
426 self.C_REWARD_2.name = 'C_REWARD'
427 self.C_REWARD_3.name = 'C_REWARD'
428 # 战斗过程 随机点击和滑动 防封
429 logger.info("Start battle process")
430 while 1:
431 self.screenshot()
432 action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
433 if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
434 # 赢的那个鼓
435 continue
436 if self.appear(self.I_GREED_GHOST):
437 # 贪吃鬼
438 logger.info('Win battle')
439 self.wait_until_appear(self.I_REWARD, wait_time=1.5)
440 self.screenshot()
441 if not self.appear(self.I_GREED_GHOST):
442 logger.warning('Greedy ghost disappear. Maybe it is a false battle')
443 continue
444 while 1:
445 self.screenshot()
446 action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
447 if not self.appear(self.I_GREED_GHOST):
448 break
449 if self.click(action_click, interval=1.5):
450 continue
451 return True
452 if self.appear(self.I_REWARD):
453 # 魂
454 logger.info('Win battle')
455 appear_greed_ghost = self.appear(self.I_GREED_GHOST)
456 while 1:
457 self.screenshot()
458 action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
459 if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
460 continue
461 if not self.appear(self.I_REWARD):
462 break
463 return True
464
465 if self.appear(self.I_FALSE):
466 logger.warning('False battle')
467 self.ui_click_until_disappear(self.I_FALSE)
468 return False
469
470 # 如果开启战斗过程随机滑动
471 if random_click_swipt_enable:
472 self.random_click_swipt()

Callers

nothing calls this directly

Calls 9

stuck_record_addMethod · 0.80
click_record_clearMethod · 0.80
appear_then_clickMethod · 0.80
appearMethod · 0.80
wait_until_appearMethod · 0.80
random_click_swiptMethod · 0.80
screenshotMethod · 0.45
clickMethod · 0.45

Tested by

no test coverage detected