From 78c2a9bfe909eec059f906d9cbcae24527c8c65b Mon Sep 17 00:00:00 2001 From: W1NDes Date: Sun, 8 Feb 2026 01:51:50 +0800 Subject: [PATCH] =?UTF-8?q?Fix(raid):=20=E6=B7=BB=E5=8A=A0=E5=85=B1?= =?UTF-8?q?=E6=96=97=E6=B4=BB=E5=8A=A8=E4=BD=8E=E5=BF=83=E6=83=85=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/raid/run.py | 54 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/module/raid/run.py b/module/raid/run.py index 8dd66abd9..5c6e21fb6 100644 --- a/module/raid/run.py +++ b/module/raid/run.py @@ -1,6 +1,6 @@ from module.base.timer import Timer from module.campaign.campaign_event import CampaignEvent -from module.exception import ScriptEnd, ScriptError +from module.exception import ScriptEnd, ScriptError, GameStuckError from module.logger import logger from module.raid.assets import RAID_REWARDS from module.raid.raid import Raid, raid_ocr @@ -65,6 +65,55 @@ class RaidRun(Raid, CampaignEvent): return remain + def detect_low_emotion(self): + from module.base.button import Button + from module.ocr.ocr import Ocr + from module.exception import GamePageUnknownError + from module.handler.assets import LOW_EMOTION_LEFT + EMOTION_TIP_L1 = Button(area=(352, 311, 929, 348), color=(), button=(352, 311, 929, 348)) + EMOTION_TIP_L2 = Button(area=(352, 350, 929, 387), color=(), button=(352, 350, 929, 387)) + EMOTION_TIP_L3 = Button(area=(352, 390, 929, 427), color=(), button=(352, 390, 929, 427)) + result = Ocr(EMOTION_TIP_L1, lang='cnocr').ocr(self.device.image) + result += Ocr(EMOTION_TIP_L2, lang='cnocr').ocr(self.device.image) + result += Ocr(EMOTION_TIP_L3, lang='cnocr').ocr(self.device.image) + logger.info(result) + if "强制" in result or "继续出击" in result: + logger.warning("舰队心情低") + else: + logger.info("开始第二轮心情OCR识别") + EMOTION_TIP_L4 = Button(area=(352, 290, 929, 325), color=(), button=(352, 290, 929, 325)) + EMOTION_TIP_L5 = Button(area=(352, 325, 929, 360), color=(), button=(352, 325, 929, 360)) + EMOTION_TIP_L6 = Button(area=(352, 360, 929, 395), color=(), button=(352, 360, 929, 395)) + result2 = Ocr(EMOTION_TIP_L4, lang='cnocr').ocr(self.device.image) + result2 += Ocr(EMOTION_TIP_L5, lang='cnocr').ocr(self.device.image) + result2 += Ocr(EMOTION_TIP_L6, lang='cnocr').ocr(self.device.image) + if "强制" in result2 or "继续出击" in result2: + logger.warning("舰队心情低") + else: + logger.warning("Game stuck, but not emotion error") + raise GameStuckError('Wait too long but not emotion error') + logger.warning(f"Raid emotion recorded is: {self.emotion.fleet_1.current}") + if self.emotion.fleet_1.current > 75: + from module.notify import handle_notify + handle_notify( + self.config.Error_OnePushConfig, + title=f"Alas <{self.config.config_name}> Raid Emotion calculate error ", + content=f"<{self.config.config_name}> fleet_1 recorded is {self.emotion.fleet_1.current},Emotion calculate error" + ) + self.emotion.fleet_1.current = 0 + self.emotion.record() + self.emotion.show() + try: + self.emotion.check_reduce(battle=1) + except ScriptEnd as e: + logger.hr('Script end') + logger.info(str(e)) + if self.appear_then_click(LOW_EMOTION_LEFT, offset=(30, 30), interval=3): + return True + else: + raise GamePageUnknownError('LOW EMOTION TIP FOUND, BUT NO LEFT button') + return False + def run(self, name='', mode='', total=0): """ Args: @@ -129,6 +178,9 @@ class RaidRun(Raid, CampaignEvent): logger.hr('Script end') logger.info(str(e)) break + except GameStuckError as e: + if self.detect_low_emotion(): + break # After run self.run_count += 1