mirror of
https://github.com/sui-feng-cb/AzurLaneAutoScript1.git
synced 2026-07-19 21:13:19 +08:00
Fix: swipe camera to avoid clicking Akashi grid overlaps with UI button
This commit is contained in:
@@ -2,8 +2,10 @@ import time
|
||||
from sys import maxsize
|
||||
|
||||
import inflection
|
||||
import numpy as np
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import area_cross_area
|
||||
from module.config.utils import get_os_reset_remain
|
||||
from module.exception import CampaignEnd, GameTooManyClickError, MapWalkError, RequestHumanTakeover, ScriptError
|
||||
from module.handler.login import LoginHandler, MAINTENANCE_ANNOUNCE
|
||||
@@ -20,6 +22,10 @@ from module.os_handler.strategic import StrategicSearchHandler
|
||||
from module.ui.assets import GOTO_MAIN
|
||||
from module.ui.page import page_os
|
||||
|
||||
# UI button area where clicking may trigger UI buttons instead of fleet movement
|
||||
# To be replaced with an asset in the future
|
||||
OS_UI_BUTTON_AREA = (1170, 455, 1280, 720)
|
||||
|
||||
|
||||
class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
def os_init(self):
|
||||
@@ -1010,11 +1016,12 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
self.clear_question()
|
||||
self.map_rescan()
|
||||
|
||||
def map_rescan_current(self, drop=None):
|
||||
def map_rescan_current(self, drop=None, _ui_avoid_count=0):
|
||||
"""
|
||||
|
||||
Args:
|
||||
drop:
|
||||
_ui_avoid_count (int): Internal counter for UI button area avoidance attempts
|
||||
|
||||
Returns:
|
||||
bool: If solved a map random event
|
||||
@@ -1036,6 +1043,13 @@ class OSMap(OSFleet, Map, GlobeCamera, StorageHandler, StrategicSearchHandler):
|
||||
logger.info(f'Found Akashi on {grid}')
|
||||
fleet = self.convert_radar_to_local((0, 0))
|
||||
if fleet.distance_to(grid) > 1:
|
||||
# Avoid clicking grid that overlaps with UI button area
|
||||
if _ui_avoid_count < 3 and area_cross_area(grid.button, OS_UI_BUTTON_AREA, threshold=0):
|
||||
logger.info(f'Akashi grid {grid} overlaps with UI button area, swipe camera to avoid')
|
||||
vector = np.array(grid.location) - np.array(fleet.location)
|
||||
vector = tuple((vector // 2).astype(int))
|
||||
self.map_swipe(vector)
|
||||
return self.map_rescan_current(drop=drop, _ui_avoid_count=_ui_avoid_count + 1)
|
||||
self.device.click(grid)
|
||||
with self.config.temporary(STORY_ALLOW_SKIP=False):
|
||||
result = self.wait_until_walk_stable(drop=drop, walk_out_of_step=False)
|
||||
|
||||
Reference in New Issue
Block a user