feat(eventSp): 处理今日SP图次数已到上限的情况

This commit is contained in:
W1NDes 2025-08-15 21:31:01 +08:00
parent ea1aed4f62
commit 74f9fa91e7
4 changed files with 25 additions and 6 deletions

View File

@ -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

View File

@ -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:

View File

@ -62,4 +62,8 @@ class RequestHumanTakeover(Exception):
# Alas is unable to handle such error, probably because of wrong settings.
pass
class OtherLogin(Exception):
pass
pass
class SpLimitError(Exception):
...

View File

@ -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)