Skip to content

Commit

Permalink
Merge branch 'LmeSzinc:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MengNianxiaoyao committed Mar 12, 2023
2 parents 2443616 + 8811de4 commit e8b15b7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
5 changes: 5 additions & 0 deletions module/os/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ def go_month_boss_room(self, is_normal=True):
def question_goto(self, has_fleet_step=False):
logger.hr('Question goto')
while 1:
# A game bug that AUTO_SEARCH_REWARD from the last cleared zone popups
if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3):
self.device.screenshot()
continue

# Update local view
# Not screenshots taking, reuse the old one
self.update_os()
Expand Down
18 changes: 15 additions & 3 deletions module/os_handler/map_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
from module.statistics.azurstats import DropImage
from module.ui.switch import Switch

fleet_lock = Switch('Fleet_Lock', offset=(10, 120))

class FleetLockSwitch(Switch):
def handle_additional(self, main):
# A game bug that AUTO_SEARCH_REWARD from the last cleared zone popups
if main.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3):
return True
return False


fleet_lock = FleetLockSwitch('Fleet_Lock', offset=(10, 120))
fleet_lock.add_status('on', check_button=OS_FLEET_LOCKED)
fleet_lock.add_status('off', check_button=OS_FLEET_UNLOCKED)

Expand Down Expand Up @@ -160,11 +169,14 @@ def handle_os_in_map(self):
self._os_in_map_confirm_timer.reset()
return False

def ensure_no_map_event(self):
def ensure_no_map_event(self, skip_first_screenshot=True):
self._os_in_map_confirm_timer.reset()

while 1:
self.device.screenshot()
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()

if self.handle_map_event():
continue
Expand Down
14 changes: 14 additions & 0 deletions module/ui/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def get_data(self, status):
logger.warning(f'Switch {self.name} received an invalid status {status}')
raise ScriptError(f'Switch {self.name} received an invalid status {status}')

def handle_additional(self, main):
"""
Args:
main (ModuleBase):
Returns:
bool: If handled
"""
return False

def set(self, status, main, skip_first_screenshot=True):
"""
Args:
Expand All @@ -122,6 +132,10 @@ def set(self, status, main, skip_first_screenshot=True):
current = self.get(main=main)
logger.attr(self.name, current)

# Handle additional popups
if self.handle_additional(main=main):
continue

# End
if current == status:
return changed
Expand Down
17 changes: 16 additions & 1 deletion submodule/AlasMaaBridge/maa.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def asst(self):
self.config.task_stop()

logger.info(f'MAA安装路径:{self.config.MaaEmulator_MaaPath}')
if not os.path.exists(self.config.MaaEmulator_MaaPath):
logger.critical(
f'未找到路径 {self.config.MaaEmulator_MaaPath},请确认MAA已安装在该路径。'
f'如果你是第一次使用MAA插件,需要自选安装MAA,并在 "MAA设置" - "MAA安装路径" 中填入MAA的安装路径')
raise RequestHumanTakeover
try:
incremental_path = [os.path.join(self.config.MaaEmulator_MaaPath, './cache')]
if self.config.MaaEmulator_PackageName in ["YoStarEN", "YoStarJP", "YoStarKR", "txwy"]:
Expand All @@ -63,7 +68,17 @@ def asst(self):
AssistantHandler.load(self.config.MaaEmulator_MaaPath, incremental_path)
except ModuleNotFoundError:
logger.critical('找不到MAA,请检查安装路径是否正确')
exit(1)
raise RequestHumanTakeover
except OSError as e:
# OSError: [WinError 126] 找不到指定的模块。
if '[WinError 126]' in str(e):
logger.exception(e)
logger.critical(
f'无法导入MAA,请确认MAA已正确安装在 {self.config.MaaEmulator_MaaPath}'
)
raise RequestHumanTakeover
else:
raise

@AssistantHandler.Asst.CallBackType
def callback(msg, details, arg):
Expand Down

0 comments on commit e8b15b7

Please sign in to comment.