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

Method check_cd

tasks/Nian/script_task.py:111–128  ·  view source on GitHub ↗

检查是否在冷却中, :return: 如果是冷却中, 返回剩余时间, 否则返回False

(self)

Source from the content-addressed store, hash-verified

109 raise TaskEnd('Nian')
110
111 def check_cd(self) -> False or timedelta:
112 """
113 检查是否在冷却中,
114 :return: 如果是冷却中, 返回剩余时间, 否则返回False
115 """
116 self.screenshot()
117 if not self.appear(self.I_N_CHECK):
118 return False
119 if not self.ocr_appear(self.O_N_BATTLE_AGAIN):
120 return False
121 # 可以判断是在冷却了
122 result = self.O_N_CD.ocr(self.device.image)
123 if not isinstance(result, str):
124 logger.error(f'OCR error {result}')
125 return False
126 result = re.search(r'(\d+)时(\d+)分后可', result)
127 time_delta = timedelta(hours=int(result.group(1)), minutes=int(result.group(2)))
128 return time_delta
129
130 @cached_property
131 def battle_config(self) -> GeneralBattleConfig:

Callers 1

runMethod · 0.95

Calls 4

appearMethod · 0.80
ocrMethod · 0.80
screenshotMethod · 0.45
ocr_appearMethod · 0.45

Tested by

no test coverage detected