mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 00:52:22 +00:00
Fix: 修复地图特效导致的章节名识别错误和进图等待
- 章节名识别错误时有20次重试的机会 - 进图时不再使用章节图标识别 - 更改了exception文件的位置
This commit is contained in:
parent
f5ee202934
commit
6b56215d71
@ -3,7 +3,7 @@ from module.campaign.campaign_base import CampaignBase
|
||||
from module.hard.equipment import HardEquipment
|
||||
from module.logger import logger
|
||||
from module.map.assets import MAP_PREPARATION, FLEET_PREPARATION
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.exception import CampaignEnd
|
||||
from module.ui.ui import CAMPAIGN_CHECK
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
|
||||
|
@ -2,8 +2,6 @@ from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
from module.map.exception import CampaignEnd
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'G1'
|
||||
|
@ -1,7 +1,7 @@
|
||||
from module.base.button import Button
|
||||
from module.logger import logger
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.map.exception import ScriptError
|
||||
from module.exception import CampaignEnd
|
||||
from module.exception import ScriptError
|
||||
from module.map.map import Map
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.base.decorator import Config
|
||||
|
@ -3,7 +3,7 @@ from module.campaign.campaign_base import CampaignBase
|
||||
from module.hard.equipment import HardEquipment
|
||||
from module.logger import logger
|
||||
from module.map.assets import MAP_PREPARATION, FLEET_PREPARATION
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.exception import CampaignEnd
|
||||
from module.ui.ui import CAMPAIGN_CHECK
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ from module.base.ocr import Ocr
|
||||
from module.base.utils import extract_letters, area_offset
|
||||
from module.logger import logger
|
||||
from module.template.assets import TEMPLATE_STAGE_CLEAR, TEMPLATE_STAGE_PERCENT, Button
|
||||
from module.exception import CampaignNameError
|
||||
|
||||
stage_clear_color = tuple(np.mean(np.mean(TEMPLATE_STAGE_CLEAR.image, axis=0), axis=0))
|
||||
stage_percentage_color = tuple(np.mean(np.mean(TEMPLATE_STAGE_PERCENT.image, axis=0), axis=0))
|
||||
@ -162,6 +163,9 @@ class CampaignOcr:
|
||||
"""
|
||||
A tricky method for ui_ensure_index
|
||||
"""
|
||||
self.get_stage_name(image)
|
||||
try:
|
||||
self.get_stage_name(image)
|
||||
except IndexError:
|
||||
raise CampaignNameError
|
||||
|
||||
return ensure_chapter_index(self.chapter)
|
||||
|
@ -5,6 +5,7 @@ from module.campaign.assets import *
|
||||
from module.campaign.campaign_ocr import CampaignOcr, ensure_chapter_index, separate_name
|
||||
from module.logger import logger
|
||||
from module.ui.ui import UI
|
||||
from module.exception import CampaignNameError
|
||||
|
||||
STAGE_SHOWN_WAIT = (1, 1.2)
|
||||
|
||||
@ -66,6 +67,7 @@ class CampaignUI(UI):
|
||||
"""
|
||||
if name not in self.campaign_ocr.stage:
|
||||
logger.warning(f'Stage not found: {name}')
|
||||
raise CampaignNameError
|
||||
return self.campaign_ocr.stage[name]
|
||||
|
||||
def ensure_campaign_ui(self, name, mode='normal'):
|
||||
|
@ -10,7 +10,7 @@ from module.campaign.campaign_ui import CampaignUI
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.handler.login import LoginHandler
|
||||
from module.logger import logger
|
||||
from module.map.exception import ScriptEnd
|
||||
from module.exception import ScriptEnd, CampaignNameError
|
||||
from module.reward.reward import Reward
|
||||
|
||||
OCR_OIL = Digit(OCR_OIL, letter=(247, 247, 247), back=(33, 36, 49), limit=25000, name='OCR_OIL')
|
||||
@ -138,8 +138,7 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
|
||||
if self.campaign.is_in_map():
|
||||
logger.info('Already in map, skip ensure_campaign_ui.')
|
||||
else:
|
||||
self.ensure_campaign_ui(name=self.stage)
|
||||
self.campaign.ENTRANCE = self.campaign_get_entrance(name=self.stage)
|
||||
self.handle_campaign_ui()
|
||||
if self.commission_notice_show_at_campaign():
|
||||
if self.reward():
|
||||
self.campaign.fleet_checked_reset()
|
||||
@ -164,3 +163,15 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
|
||||
count = 0 if count < 0 else count
|
||||
self.config.config.set('Setting', 'if_count_greater_than', str(count))
|
||||
self.config.save()
|
||||
|
||||
def handle_campaign_ui(self):
|
||||
for n in range(20):
|
||||
try:
|
||||
self.ensure_campaign_ui(name=self.stage)
|
||||
self.campaign.ENTRANCE = self.campaign_get_entrance(name=self.stage)
|
||||
return True
|
||||
except CampaignNameError:
|
||||
continue
|
||||
|
||||
logger.warning('Campaign name error')
|
||||
raise ScriptEnd('Campaign name error')
|
||||
|
@ -1,13 +1,11 @@
|
||||
import time
|
||||
from collections import deque
|
||||
|
||||
from retrying import retry
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import *
|
||||
from module.device.connection import Connection
|
||||
from module.logger import logger
|
||||
from module.map.exception import ScriptError
|
||||
from module.exception import ScriptError
|
||||
|
||||
|
||||
class Control(Connection):
|
||||
|
@ -10,6 +10,10 @@ class MapWalkError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CampaignNameError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ScriptError(Exception):
|
||||
pass
|
||||
|
@ -3,7 +3,8 @@ from module.base.utils import red_overlay_transparency, get_color
|
||||
from module.handler.assets import *
|
||||
from module.handler.info_bar import InfoBarHandler
|
||||
from module.logger import logger
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.exception import CampaignEnd
|
||||
from module.ui.assets import CAMPAIGN_GOTO_DAILY
|
||||
|
||||
|
||||
class EnemySearchingHandler(InfoBarHandler):
|
||||
@ -33,7 +34,7 @@ class EnemySearchingHandler(InfoBarHandler):
|
||||
return False
|
||||
|
||||
def is_in_stage(self):
|
||||
return self.appear(IN_STAGE_RED) or self.appear(IN_STAGE_BLUE)
|
||||
return self.appear(IN_STAGE_RED) or self.appear(IN_STAGE_BLUE) or self.appear(CAMPAIGN_GOTO_DAILY)
|
||||
|
||||
def is_in_map(self):
|
||||
return self.appear(IN_MAP)
|
||||
|
@ -2,7 +2,7 @@ import numpy as np
|
||||
|
||||
from module.handler.info_bar import InfoBarHandler
|
||||
from module.logger import logger
|
||||
from module.map.exception import PerspectiveError
|
||||
from module.exception import PerspectiveError
|
||||
from module.map.grids import Grids, Grid
|
||||
from module.map.map_base import CampaignMap, location2node, location_ensure
|
||||
|
||||
|
@ -4,7 +4,7 @@ from module.base.timer import Timer
|
||||
from module.handler.ambush import AmbushHandler
|
||||
from module.logger import logger
|
||||
from module.map.camera import Camera
|
||||
from module.map.exception import MapWalkError
|
||||
from module.exception import MapWalkError
|
||||
from module.map.grids import Grids
|
||||
from module.map.map_base import SelectedGrids
|
||||
from module.map.map_base import location2node, location_ensure
|
||||
|
@ -6,8 +6,8 @@ from module.handler.story import StoryHandler
|
||||
from module.handler.urgent_commission import UrgentCommissionHandler
|
||||
from module.logger import logger
|
||||
from module.map.assets import *
|
||||
from module.map.exception import CampaignEnd
|
||||
from module.map.exception import ScriptEnd
|
||||
from module.exception import CampaignEnd
|
||||
from module.exception import ScriptEnd
|
||||
from module.map.map_fleet_preparation import FleetPreparation
|
||||
from module.retire.retirement import Retirement
|
||||
|
||||
@ -49,7 +49,8 @@ class MapOperation(UrgentCommissionHandler, MysteryHandler, FleetPreparation, Re
|
||||
checked_in_map = True
|
||||
|
||||
# Enter campaign
|
||||
if campaign_timer.reached() and self.appear_then_click(button):
|
||||
if campaign_timer.reached() and self.is_in_stage():
|
||||
self.device.click(button)
|
||||
campaign_timer.reset()
|
||||
continue
|
||||
|
||||
|
@ -9,7 +9,7 @@ from scipy import signal, optimize
|
||||
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.logger import logger
|
||||
from module.map.exception import PerspectiveError
|
||||
from module.exception import PerspectiveError
|
||||
from module.map.perspective_items import Points, Lines
|
||||
|
||||
warnings.filterwarnings("ignore")
|
||||
|
@ -5,7 +5,7 @@ from module.combat.assets import GET_ITEMS_1
|
||||
from module.handler.info_bar import InfoBarHandler
|
||||
from module.handler.popup import PopupHandler
|
||||
from module.logger import logger
|
||||
from module.map.exception import ScriptError
|
||||
from module.exception import ScriptError
|
||||
from module.retire.assets import *
|
||||
from module.ui.ui import UI
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user