From 843360b6d830fc0a0cf47f6d714bc3ae661a4c8a Mon Sep 17 00:00:00 2001 From: W1NDes Date: Mon, 6 Jan 2025 02:18:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(campaign):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BF=83=E6=83=85=E6=A3=80=E6=B5=8B=E9=98=9F=E4=BC=8D=E5=88=A4?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 第一舰队第二舰队不是官方名字,舰队名是可以自定义的,所以现在根据出击方式判断。 --- module/campaign/run.py | 58 +++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/module/campaign/run.py b/module/campaign/run.py index 9b0ef2dd4..01a2b1f06 100644 --- a/module/campaign/run.py +++ b/module/campaign/run.py @@ -342,31 +342,36 @@ class CampaignRun(CampaignEvent, ShopStatus): logger.info(result) if "低心情" in result or "降低好感" in result: logger.warning("舰队心情低") - fleets = { - "第一舰": "fleet_1", - "第二舰": "fleet_2" - } - for key, fleet in fleets.items(): - if key in result: - logger.warning(f"{name} recorded {fleet} is :{getattr(self.campaign.emotion, fleet).current}") - if getattr(self.campaign.emotion, fleet).current > 75: - handle_notify( - self.config.Error_OnePushConfig, - title=f"Alas <{self.config.config_name}> {name} Emotion calculate error ", - content=f"<{self.config.config_name}> {fleet} recorded is {getattr(self.campaign.emotion, fleet).current},Emotion calculate error" - ) - setattr(getattr(self.campaign.emotion, fleet), 'current', 0) - self.campaign.emotion.record() - self.campaign.emotion.show() - try: - self.campaign.emotion.check_reduce(self.campaign._map_battle) - 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): - break - else: - raise GamePageUnknownError(f'LOW EMOTION TIP FOUND, BUT NO LEFT button') + + method = self.config.Fleet_FleetOrder + if method == 'fleet1_mob_fleet2_boss': + fleet = 'fleet_1' + elif method == 'fleet1_boss_fleet2_mob': + fleet = 'fleet_2' + elif method == 'fleet1_all_fleet2_standby': + fleet = 'fleet_1' + elif method == 'fleet1_standby_fleet2_all': + fleet = 'fleet_2' + logger.info(f"now combat is {method}") + logger.warning(f"{name} recorded {fleet} is :{getattr(self.campaign.emotion, fleet).current}") + if getattr(self.campaign.emotion, fleet).current > 75: + handle_notify( + self.config.Error_OnePushConfig, + title=f"Alas <{self.config.config_name}> {name} Emotion calculate error ", + content=f"<{self.config.config_name}> {fleet} recorded is {getattr(self.campaign.emotion, fleet).current},Emotion calculate error" + ) + setattr(getattr(self.campaign.emotion, fleet), 'current', 0) + self.campaign.emotion.record() + self.campaign.emotion.show() + try: + self.campaign.emotion.check_reduce(self.campaign._map_battle) + 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(f'LOW EMOTION TIP FOUND, BUT NO LEFT button') else: logger.warning("Game stuck, but not emotion error") @@ -451,7 +456,8 @@ class CampaignRun(CampaignEvent, ShopStatus): logger.info(str(e)) break except GameStuckError as e: - self.detect_low_emotion(name) + if self.detect_low_emotion(name): + break # Update config if len(self.campaign.config.modified):