mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:07:36 +08:00
Chore: [ALAS] Move func methods to the Alas class
This commit is contained in:
parent
6365693cef
commit
5f56a2bdb7
20
alas.py
20
alas.py
@ -394,6 +394,26 @@ class AzurLaneAutoScript:
|
||||
GemsFarming(config=self.config, device=self.device).run(
|
||||
name=self.config.Campaign_Name, folder=self.config.Campaign_Event, mode=self.config.Campaign_Mode)
|
||||
|
||||
def daemon(self):
|
||||
from module.daemon.daemon import AzurLaneDaemon
|
||||
AzurLaneDaemon(config=self.config, device=self.device, task="Daemon").run()
|
||||
|
||||
def opsi_daemon(self):
|
||||
from module.daemon.os_daemon import AzurLaneDaemon
|
||||
AzurLaneDaemon(config=self.config, device=self.device, task="OpsiDaemon").run()
|
||||
|
||||
def azur_lane_uncensored(self):
|
||||
from module.daemon.uncensored import AzurLaneUncensored
|
||||
AzurLaneUncensored(config=self.config, device=self.device, task="AzurLaneUncensored").run()
|
||||
|
||||
def benchmark(self):
|
||||
from module.daemon.benchmark import run_benchmark
|
||||
run_benchmark(config=self.config)
|
||||
|
||||
def game_manager(self):
|
||||
from module.daemon.game_manager import GameManager
|
||||
GameManager(config=self.config, device=self.device, task="GameManager").run()
|
||||
|
||||
def wait_until(self, future):
|
||||
"""
|
||||
Wait until a specific time.
|
||||
|
@ -34,6 +34,8 @@ class ModuleBase:
|
||||
"""
|
||||
if isinstance(config, AzurLaneConfig):
|
||||
self.config = config
|
||||
if task is not None:
|
||||
self.config.init_task(task)
|
||||
elif isinstance(config, str):
|
||||
self.config = AzurLaneConfig(config, task=task)
|
||||
else:
|
||||
@ -73,6 +75,9 @@ class ModuleBase:
|
||||
if not self.config.is_actual_task:
|
||||
logger.info('No actual task bound, skip early_ocr_import')
|
||||
return
|
||||
if self.config.task.command in ['Daemon', 'OpsiDaemon']:
|
||||
logger.info('No ocr in daemon task, skip early_ocr_import')
|
||||
return
|
||||
|
||||
def do_ocr_import():
|
||||
# Wait first image
|
||||
|
@ -104,17 +104,22 @@ class AzurLaneConfig(ConfigUpdater, ManualConfig, GeneratedConfig, ConfigWatcher
|
||||
logger.info("Using template config, which is read only")
|
||||
self.auto_update = False
|
||||
self.task = name_to_function("template")
|
||||
self.init_task(task)
|
||||
|
||||
def init_task(self, task=None):
|
||||
if self.is_template_config:
|
||||
return
|
||||
|
||||
self.load()
|
||||
if task is None:
|
||||
# Bind `Alas` by default which includes emulator settings.
|
||||
task = name_to_function("Alas")
|
||||
else:
|
||||
self.load()
|
||||
if task is None:
|
||||
# Bind `Alas` by default which includes emulator settings.
|
||||
task = name_to_function("Alas")
|
||||
else:
|
||||
# Bind a specific task for debug purpose.
|
||||
task = name_to_function(task)
|
||||
self.bind(task)
|
||||
self.task = task
|
||||
self.save()
|
||||
# Bind a specific task for debug purpose.
|
||||
task = name_to_function(task)
|
||||
self.bind(task)
|
||||
self.task = task
|
||||
self.save()
|
||||
|
||||
def load(self):
|
||||
self.data = self.read_file(self.config_name)
|
||||
|
@ -13,6 +13,16 @@ MOD_FUNC_DICT = {
|
||||
MOD_CONFIG_DICT = {}
|
||||
|
||||
|
||||
def get_available_func():
|
||||
return (
|
||||
'Daemon',
|
||||
'OpsiDaemon',
|
||||
'AzurLaneUncensored',
|
||||
'Benchmark',
|
||||
'GameManager',
|
||||
)
|
||||
|
||||
|
||||
def get_available_mod():
|
||||
return set(MOD_DICT)
|
||||
|
||||
|
@ -12,7 +12,8 @@ from rich.console import Console, ConsoleRenderable
|
||||
from module.config.utils import filepath_config
|
||||
from module.logger import logger, set_file_logger, set_func_logger
|
||||
from module.submodule.submodule import load_mod
|
||||
from module.submodule.utils import get_available_mod, get_available_mod_func, get_config_mod, get_func_mod, list_mod_instance
|
||||
from module.submodule.utils import get_available_func, get_available_mod, get_available_mod_func, get_config_mod, \
|
||||
get_func_mod, list_mod_instance
|
||||
from module.webui.setting import State
|
||||
|
||||
|
||||
@ -149,26 +150,10 @@ class ProcessManager:
|
||||
if e is not None:
|
||||
AzurLaneAutoScript.stop_event = e
|
||||
AzurLaneAutoScript(config_name=config_name).loop()
|
||||
elif func == "Daemon":
|
||||
from module.daemon.daemon import AzurLaneDaemon
|
||||
elif func in get_available_func():
|
||||
from alas import AzurLaneAutoScript
|
||||
|
||||
AzurLaneDaemon(config=config_name, task="Daemon").run()
|
||||
elif func == "OpsiDaemon":
|
||||
from module.daemon.os_daemon import AzurLaneDaemon
|
||||
|
||||
AzurLaneDaemon(config=config_name, task="OpsiDaemon").run()
|
||||
elif func == "AzurLaneUncensored":
|
||||
from module.daemon.uncensored import AzurLaneUncensored
|
||||
|
||||
AzurLaneUncensored(config=config_name, task="AzurLaneUncensored").run()
|
||||
elif func == "Benchmark":
|
||||
from module.daemon.benchmark import run_benchmark
|
||||
|
||||
run_benchmark(config=config_name)
|
||||
elif func == "GameManager":
|
||||
from module.daemon.game_manager import GameManager
|
||||
|
||||
GameManager(config=config_name, task="GameManager").run()
|
||||
AzurLaneAutoScript(config_name=config_name).run(inflection.underscore(func))
|
||||
elif func in get_available_mod():
|
||||
mod = load_mod(func)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user