mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 05:47:30 +08:00
Fix: 增加连续点击一个按钮时, 停止运行的功能
- 增加靠边缘修正相机位置时的log - 修复了频繁报Enemy searching timeout的问题 - 修复周回模式下, 已经进图时, 会按有伏击运行的问题
This commit is contained in:
parent
012a4decbb
commit
0c5bded2c7
@ -1,4 +1,5 @@
|
||||
import time
|
||||
from collections import deque
|
||||
|
||||
from retrying import retry
|
||||
|
||||
@ -9,6 +10,8 @@ from module.logger import logger
|
||||
|
||||
|
||||
class Control(Connection):
|
||||
click_record = deque(maxlen=15)
|
||||
|
||||
@staticmethod
|
||||
def sleep(second):
|
||||
"""
|
||||
@ -25,6 +28,23 @@ class Control(Connection):
|
||||
def _point2str(x, y):
|
||||
return '(%s,%s)' % (str(int(x)).rjust(4), str(int(y)).rjust(4))
|
||||
|
||||
def click_record_check(self, button):
|
||||
"""
|
||||
Args:
|
||||
button (button.Button): AzurLane Button instance.
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
if sum([1 if str(prev) == str(button) else 0 for prev in self.click_record]) >= 12:
|
||||
logger.warning(f'Too many click for a button: {button}')
|
||||
logger.info(f'History click: {[str(prev) for prev in self.click_record]}')
|
||||
exit(1)
|
||||
else:
|
||||
self.click_record.append(str(button))
|
||||
|
||||
return False
|
||||
|
||||
def click(self, button, adb=False):
|
||||
"""Method to click a button.
|
||||
|
||||
@ -32,6 +52,7 @@ class Control(Connection):
|
||||
button (button.Button): AzurLane Button instance.
|
||||
adb (bool): If use adb.
|
||||
"""
|
||||
self.click_record_check(button)
|
||||
x, y = random_rectangle_point(button.button)
|
||||
logger.info(
|
||||
'Click %s @ %s' % (self._point2str(x, y), button)
|
||||
|
@ -33,7 +33,9 @@ class FastForwardHandler(ModuleBase):
|
||||
if not fleet_lock.appear(main=self):
|
||||
logger.info('No fleet lock option.')
|
||||
return False
|
||||
|
||||
logger.info('fleet_lock')
|
||||
self.config.MAP_HAS_AMBUSH = False
|
||||
status = 'on' if self.config.ENABLE_MAP_FLEET_LOCK else 'off'
|
||||
changed = fleet_lock.set(status=status, main=self)
|
||||
return changed
|
||||
|
@ -105,7 +105,6 @@ class Camera(InfoBarHandler):
|
||||
self.grids.save_error_image()
|
||||
|
||||
# Set camera position
|
||||
|
||||
if self.grids.left_edge:
|
||||
x = 0 + self.grids.center_grid[0]
|
||||
elif self.grids.right_edge:
|
||||
@ -118,11 +117,10 @@ class Camera(InfoBarHandler):
|
||||
y = self.map.shape[1] - self.grids.shape[1] + self.grids.center_grid[1]
|
||||
else:
|
||||
y = self.camera[1]
|
||||
self.camera = (x, y)
|
||||
|
||||
# align_x = self.map.shape[0] - self.grids.shape[0] if self.grids.right_edge else 0
|
||||
# align_y = self.map.shape[1] - self.grids.shape[1] if self.grids.upper_edge else 0
|
||||
# self.camera = np.array((align_x, align_y)) + self.grids.center_grid
|
||||
if self.camera != (x, y):
|
||||
logger.info(f' camera corrected: {location2node(self.camera)} -> {location2node((x, y))}')
|
||||
self.camera = (x, y)
|
||||
self.show_camera()
|
||||
|
||||
def predict(self):
|
||||
@ -203,6 +201,7 @@ class Camera(InfoBarHandler):
|
||||
Args:
|
||||
battle_count:
|
||||
mystery_count:
|
||||
siren_count:
|
||||
"""
|
||||
logger.info('Full scan start')
|
||||
self.map.reset_fleet()
|
||||
|
@ -236,10 +236,10 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
|
||||
self.map.show_cost()
|
||||
|
||||
def _expected_combat_end(self, expected):
|
||||
for data in self.map.spawn_data:
|
||||
for data in self.map._spawn_data_backup:
|
||||
if data.get('battle') == self.battle_count and 'boss' in expected:
|
||||
return 'in_stage'
|
||||
if data.get('battle') == self.battle_count:
|
||||
if data.get('battle') == self.battle_count + 1:
|
||||
if data.get('enemy', 0) + data.get('siren', 0) + data.get('boss', 0) > 0:
|
||||
return 'with_searching'
|
||||
else:
|
||||
|
@ -43,6 +43,7 @@ class Grids(Perspective):
|
||||
np.where(self.vertical.distance_to_point(self.config.SCREEN_CENTER) >= 0)[0][0] - 1,
|
||||
np.where(self.horizontal.distance_to_point(self.config.SCREEN_CENTER) >= 0)[0][0] - 1
|
||||
)
|
||||
logger.info(f' Center grid: {self.center_grid}')
|
||||
self.center_offset = self.grids[self.center_grid].screen_point_to_grid_location(self.config.SCREEN_CENTER)
|
||||
self.shape = np.max(list(self.grids.keys()), axis=0)
|
||||
|
||||
|
@ -42,6 +42,7 @@ class CampaignMap:
|
||||
self._weight_data = ''
|
||||
self._block_data = []
|
||||
self._spawn_data = []
|
||||
self._spawn_data_backup = []
|
||||
self._camera_data = []
|
||||
self.in_map_swipe_preset_data = None
|
||||
|
||||
@ -156,8 +157,8 @@ class CampaignMap:
|
||||
|
||||
@spawn_data.setter
|
||||
def spawn_data(self, data_list):
|
||||
self._spawn_data_backup = data_list
|
||||
spawn = {'battle': 0, 'enemy': 0, 'mystery': 0, 'siren': 0, 'boss': 0}
|
||||
# spawn = {'battle': 0, 'enemy': 0, 'mystery': 0, 'boss': 0}
|
||||
for data in data_list:
|
||||
spawn['battle'] = data['battle']
|
||||
spawn['enemy'] += data.get('enemy', 0) + data.get('siren', 0)
|
||||
|
Loading…
Reference in New Issue
Block a user