检查是否在冷却中, :return: 如果是冷却中, 返回剩余时间, 否则返回False
(self)
| 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: |
no test coverage detected