mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-30 11:19:30 +00:00
8ec5099b58
- 修复UI导致的动态边缘识别出错 - 修复只识别出一队时的处理逻辑 - 修复处理战斗结束后跳出的剧情 - 修复辅助点击报CampaignEnd - 修复游戏出现白屏bug时, 连续点击使用紧急维修 - 增加地图全清时, 使用二队打BOSS, 忽略FLEET_BOSS - 增加被精英抓住的识别, 暂时还用不到
132 lines
3.6 KiB
Python
132 lines
3.6 KiB
Python
from module.base.base import ModuleBase
|
|
from module.base.timer import Timer
|
|
from module.handler.assets import *
|
|
from module.logger import logger
|
|
|
|
|
|
class InfoHandler(ModuleBase):
|
|
"""
|
|
Class to handle all kinds of message.
|
|
"""
|
|
"""
|
|
Info bar
|
|
"""
|
|
def info_bar_count(self):
|
|
if self.appear(INFO_BAR_3):
|
|
return 3
|
|
elif self.appear(INFO_BAR_2):
|
|
return 2
|
|
elif self.appear(INFO_BAR_1):
|
|
return 1
|
|
else:
|
|
return 0
|
|
|
|
def handle_info_bar(self):
|
|
if self.info_bar_count():
|
|
self.wait_until_disappear(INFO_BAR_1)
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def ensure_no_info_bar(self, timeout=0.6):
|
|
timeout = Timer(timeout)
|
|
timeout.start()
|
|
while 1:
|
|
self.device.screenshot()
|
|
self.handle_info_bar()
|
|
|
|
if timeout.reached():
|
|
break
|
|
|
|
"""
|
|
Popup info
|
|
"""
|
|
_popup_offset = (3, 30)
|
|
|
|
def handle_popup_confirm(self):
|
|
if self.appear(POPUP_CANCEL, offset=self._popup_offset) \
|
|
and self.appear(POPUP_CONFIRM, offset=self._popup_offset, interval=2):
|
|
self.device.click(POPUP_CONFIRM)
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def handle_popup_cancel(self):
|
|
if self.appear(POPUP_CONFIRM, offset=self._popup_offset) \
|
|
and self.appear(POPUP_CANCEL, offset=self._popup_offset, interval=2):
|
|
self.device.click(POPUP_CANCEL)
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def handle_urgent_commission(self, save_get_items=None):
|
|
"""
|
|
Args:
|
|
save_get_items (bool):
|
|
|
|
Returns:
|
|
bool:
|
|
"""
|
|
if save_get_items is None:
|
|
save_get_items = self.config.ENABLE_SAVE_GET_ITEMS
|
|
|
|
appear = self.appear(GET_MISSION, offset=True, interval=2)
|
|
if appear:
|
|
logger.info('Get urgent commission')
|
|
if save_get_items:
|
|
self.handle_info_bar()
|
|
self.device.save_screenshot('get_mission')
|
|
self.device.click(GET_MISSION)
|
|
return appear
|
|
|
|
def handle_combat_low_emotion(self):
|
|
if not self.config.IGNORE_LOW_EMOTION_WARN:
|
|
return False
|
|
|
|
return self.handle_popup_confirm()
|
|
|
|
"""
|
|
Story
|
|
"""
|
|
def story_skip(self):
|
|
if self.handle_popup_confirm():
|
|
return True
|
|
if self.appear_then_click(STORY_SKIP, offset=True, interval=2):
|
|
return True
|
|
if self.appear(STORY_LETTER_BLACK) and self.appear_then_click(STORY_LETTERS_ONLY, offset=True, interval=2):
|
|
return True
|
|
if self.appear_then_click(STORY_CHOOSE, offset=True, interval=2):
|
|
return True
|
|
if self.appear_then_click(STORY_CHOOSE_2, offset=True, interval=2):
|
|
return True
|
|
|
|
return False
|
|
|
|
def handle_story_skip(self):
|
|
if not self.config.ENABLE_MAP_CLEAR_MODE:
|
|
return False
|
|
|
|
return self.story_skip()
|
|
|
|
def ensure_no_story(self, skip_first_screenshot=True):
|
|
logger.info('Ensure no story')
|
|
story_timer = Timer(5, count=4)
|
|
story_timer.start()
|
|
while 1:
|
|
if skip_first_screenshot:
|
|
skip_first_screenshot = False
|
|
else:
|
|
self.device.screenshot()
|
|
|
|
if self.story_skip():
|
|
story_timer.reset()
|
|
|
|
if story_timer.reached():
|
|
break
|
|
|
|
def handle_map_after_combat_story(self):
|
|
if not self.config.MAP_HAS_MAP_STORY:
|
|
return False
|
|
|
|
self.ensure_no_story()
|