mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 03:58:22 +08:00
Fix: Re-implement hard mode detection
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import numpy as np
|
||||
from PIL import ImageStat
|
||||
from scipy import signal
|
||||
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.button import Button
|
||||
from module.base.utils import area_offset
|
||||
from module.base.utils import area_offset, color_similarity_2d
|
||||
from module.logger import logger
|
||||
from module.map.assets import *
|
||||
|
||||
@@ -136,6 +137,24 @@ class FleetPreparation(ModuleBase):
|
||||
map_fleet_checked = False
|
||||
map_is_hard_mode = False
|
||||
|
||||
def get_map_is_hard_mode(self):
|
||||
"""
|
||||
Detect how many light orange lines are there.
|
||||
Having lines means current map has stat limits and user has satisfied at least one of them,
|
||||
so this is a hard map.
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
area = (208, 130, 226, 551)
|
||||
image = color_similarity_2d(self.image_area(area), color=(249, 199, 0))
|
||||
height = np.max(image, axis=1)
|
||||
parameters = {'height': 180, 'distance': 5}
|
||||
peaks, _ = signal.find_peaks(height, **parameters)
|
||||
lines = len(peaks)
|
||||
logger.attr('Light_orange_line', lines)
|
||||
return lines > 0
|
||||
|
||||
def fleet_preparation(self):
|
||||
"""Change fleets.
|
||||
|
||||
@@ -145,7 +164,8 @@ class FleetPreparation(ModuleBase):
|
||||
logger.info(f'Using fleet: {[self.config.FLEET_1, self.config.FLEET_2, self.config.SUBMARINE]}')
|
||||
if self.map_fleet_checked:
|
||||
return False
|
||||
self.map_is_hard_mode = self.appear(FLEET_PREPARATION_HARD_1) or self.appear(FLEET_PREPARATION_HARD_2)
|
||||
|
||||
self.map_is_hard_mode = self.get_map_is_hard_mode()
|
||||
if self.map_is_hard_mode:
|
||||
logger.info('Hard Campaign. No fleet preparation')
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user