mirror of
https://github.com/sui-feng-cb/AzurLaneAutoScript1.git
synced 2026-07-06 13:09:46 +08:00
Add: submarine call timing
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import color_similar, crop, get_color, image_color_count
|
||||
from module.combat.assets import *
|
||||
from module.logger import logger
|
||||
|
||||
# BOSS detection areas
|
||||
# Classic UI: BOSS avatar frame right border
|
||||
BOSS_AVATAR_FRAME_RIGHT = (301, 13, 303, 89)
|
||||
BOSS_AVATAR_FRAME_COLOR = (24, 28, 24)
|
||||
# New UI: BOSS HP bar bottom border, middle-left portion
|
||||
# Color targets deep blue themes; need adjustment for other color schemes
|
||||
BOSS_HP_BAR_BORDER = (420, 48, 620, 50)
|
||||
BOSS_HP_BAR_COLOR = (31, 39, 61)
|
||||
|
||||
|
||||
class SubmarineCall(ModuleBase):
|
||||
submarine_call_flag = False
|
||||
@@ -16,6 +26,20 @@ class SubmarineCall(ModuleBase):
|
||||
self.submarine_call_timer.reset()
|
||||
self.submarine_call_flag = False
|
||||
|
||||
def boss_appeared(self):
|
||||
"""
|
||||
Detect whether BOSS has appeared by checking stable BOSS UI elements.
|
||||
"""
|
||||
# New UI: BOSS HP bar bottom border
|
||||
avg = get_color(self.device.image, BOSS_HP_BAR_BORDER)
|
||||
if color_similar(avg, BOSS_HP_BAR_COLOR, threshold=40):
|
||||
return True
|
||||
# Classic UI: BOSS avatar frame right border
|
||||
frame = crop(self.device.image, BOSS_AVATAR_FRAME_RIGHT, copy=False)
|
||||
if image_color_count(frame, color=BOSS_AVATAR_FRAME_COLOR, count=55):
|
||||
return True
|
||||
return False
|
||||
|
||||
def handle_submarine_call(self, call_mode='do_not_use', is_boss=False):
|
||||
"""
|
||||
Args:
|
||||
@@ -31,6 +55,10 @@ class SubmarineCall(ModuleBase):
|
||||
self.submarine_call_flag = True
|
||||
return False
|
||||
|
||||
if self.config.Submarine_Timing == 'wait_for_boss' and is_boss:
|
||||
if not self.boss_appeared():
|
||||
self.submarine_call_timer.reset()
|
||||
return False
|
||||
if self.submarine_call_timer.reached():
|
||||
logger.info('Submarine call timer reached')
|
||||
self.submarine_call_flag = True
|
||||
|
||||
Reference in New Issue
Block a user