From 74f9fa91e75b35315eba16e317f4bab18e7f1da8 Mon Sep 17 00:00:00 2001 From: W1NDes Date: Fri, 15 Aug 2025 21:31:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(eventSp):=20=E5=A4=84=E7=90=86=E4=BB=8A?= =?UTF-8?q?=E6=97=A5SP=E5=9B=BE=E6=AC=A1=E6=95=B0=E5=B7=B2=E5=88=B0?= =?UTF-8?q?=E4=B8=8A=E9=99=90=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- campaign/event_20250814_cn/sp.py | 4 +++- module/campaign/campaign_base.py | 8 ++++++-- module/exception.py | 6 +++++- module/map/map_operation.py | 13 +++++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/campaign/event_20250814_cn/sp.py b/campaign/event_20250814_cn/sp.py index 85f3daa74..c5fe53458 100644 --- a/campaign/event_20250814_cn/sp.py +++ b/campaign/event_20250814_cn/sp.py @@ -65,7 +65,9 @@ class Config: STAR_REQUIRE_2 = 0 STAR_REQUIRE_3 = 0 # ===== End of generated config ===== - + MAP_CHAPTER_SWITCH_20241219 = True + # MAP_HAS_MODE_SWITCH = True + STAGE_ENTRANCE = ['half', '20240725'] class Campaign(CampaignBase): MAP = MAP diff --git a/module/campaign/campaign_base.py b/module/campaign/campaign_base.py index 15ebf4783..2cb808b02 100644 --- a/module/campaign/campaign_base.py +++ b/module/campaign/campaign_base.py @@ -1,7 +1,7 @@ from module.base.decorator import Config, cached_property from module.campaign.campaign_ui import CampaignUI from module.combat.auto_search_combat import AutoSearchCombat -from module.exception import CampaignEnd, MapEnemyMoved, ScriptError +from module.exception import CampaignEnd, MapEnemyMoved, ScriptError, SpLimitError from module.logger import logger from module.map.map import Map from module.map.map_base import CampaignMap @@ -122,7 +122,11 @@ class CampaignBase(CampaignUI, Map, AutoSearchCombat): # Enter map self.emotion.check_reduce(self._map_battle) self.ENTRANCE.area = self.ENTRANCE.button - self.enter_map(self.ENTRANCE, mode=self.config.Campaign_Mode) + try: + self.enter_map(self.ENTRANCE, mode=self.config.Campaign_Mode) + except SpLimitError: + logger.warning('Sp limit error') + return True # Map init if not self.map_is_auto_search: diff --git a/module/exception.py b/module/exception.py index c2e7248ba..1d5726cc3 100644 --- a/module/exception.py +++ b/module/exception.py @@ -62,4 +62,8 @@ class RequestHumanTakeover(Exception): # Alas is unable to handle such error, probably because of wrong settings. pass class OtherLogin(Exception): - pass \ No newline at end of file + pass + + +class SpLimitError(Exception): + ... \ No newline at end of file diff --git a/module/map/map_operation.py b/module/map/map_operation.py index 4a9de599a..20384ea5d 100644 --- a/module/map/map_operation.py +++ b/module/map/map_operation.py @@ -1,5 +1,5 @@ from module.base.timer import Timer -from module.exception import CampaignEnd, RequestHumanTakeover, ScriptEnd +from module.exception import CampaignEnd, RequestHumanTakeover, ScriptEnd, SpLimitError from module.handler.fast_forward import FastForwardHandler from module.handler.mystery import MysteryHandler from module.logger import logger @@ -132,13 +132,21 @@ class MapOperation(MysteryHandler, FleetPreparation, Retirement, FastForwardHand logger.critical(f"Failed to enter {button}, too many click on {button}") logger.critical("Possible reason #1: You haven't reached the commander level to unlock this stage.") raise RequestHumanTakeover - if fleet_click > 5: + if fleet_click > 4: logger.critical(f"Failed to enter {button}, too many click on FLEET_PREPARATION") logger.critical("Possible reason #1: " "Your fleets haven't satisfied the stat restrictions of this stage.") logger.critical("Possible reason #2: " "This stage can only be farmed once a day, " "but it's the second time that you are entering") + if button == 'sp': + from module.ocr.ocr import Ocr + self.device.sleep(0.5) + self.device.screenshot() + SP_LIMIT_TIP=Button(area=(464, 307, 815, 337), color=(), button=(464, 307, 815, 337)) + result = Ocr(SP_LIMIT_TIP, lang= 'cnocr').ocr(self.device.image) + if "关卡每日" in result or "挑战次数" in result: + raise SpLimitError raise RequestHumanTakeover # Already in map @@ -406,3 +414,4 @@ class MapOperation(MysteryHandler, FleetPreparation, Retirement, FastForwardHand return False return self.fleet_set(index=2) +