mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 09:01:45 +00:00
8ce405f28a
- 增加处理踩问号是会刷物资船的情况 - 增加对物资船的缺失预测 - 收完菜后出击, 会重新检查舰队 因为离开出击界面后, 出击舰队会重置为游戏默认的 - 修复了部分偏红的过场图, 会被认作索敌的问题
67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
from module.base.timer import Timer
|
|
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
|
|
|
|
|
|
class EnemySearchingHandler(InfoBarHandler):
|
|
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.5 # Usually (0.70, 0.80).
|
|
MAP_ENEMY_SEARCHING_TIMEOUT_SECOND = 4
|
|
|
|
def _color_initial(self):
|
|
MAP_ENEMY_SEARCHING.load_color(self.device.image)
|
|
|
|
def enemy_searching_appear(self):
|
|
return red_overlay_transparency(
|
|
MAP_ENEMY_SEARCHING.color, get_color(self.device.image, MAP_ENEMY_SEARCHING.area)
|
|
) > self.MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD
|
|
|
|
def handle_enemy_flashing(self):
|
|
self.device.sleep(1)
|
|
|
|
def handle_in_stage(self):
|
|
if self.appear(IN_STAGE_RED) or self.appear(IN_STAGE_BLUE):
|
|
logger.info('In stage.')
|
|
# self.device.sleep(0.5)
|
|
self.ensure_no_info_bar(timeout=0.6)
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def is_in_map(self):
|
|
return self.appear(IN_MAP)
|
|
|
|
def handle_in_map_with_enemy_searching(self):
|
|
if not self.is_in_map():
|
|
return False
|
|
|
|
timeout = Timer(self.MAP_ENEMY_SEARCHING_TIMEOUT_SECOND)
|
|
appeared = False
|
|
while 1:
|
|
timeout.start()
|
|
if self.enemy_searching_appear():
|
|
appeared = True
|
|
else:
|
|
if appeared:
|
|
self.handle_enemy_flashing()
|
|
self.device.sleep(0.3)
|
|
logger.info('In map.')
|
|
break
|
|
self._color_initial()
|
|
|
|
if timeout.reached():
|
|
# logger.warning('Enemy searching timeout.')
|
|
logger.info('Enemy searching timeout.')
|
|
break
|
|
|
|
self.device.screenshot()
|
|
return True
|
|
|
|
def handle_in_map(self):
|
|
if not self.is_in_map():
|
|
return False
|
|
|
|
self.device.sleep((1, 1.2))
|
|
return True
|