mirror of
https://github.com/W1NDes/M-AzurLaneAutoScript.git
synced 2026-05-14 04:08:09 +08:00
Opt(OtherLogin): 优化异地登录处理逻辑
- 根据冲突次数调整冷却时间 - 补全相关异常处理
This commit is contained in:
parent
05145abe09
commit
6c8fcb80f0
32
alas.py
32
alas.py
@ -8,6 +8,7 @@ import inflection
|
||||
from cached_property import cached_property
|
||||
|
||||
from module.base.decorator import del_cached_property
|
||||
from module.base.resource import release_resources
|
||||
from module.config.config import AzurLaneConfig, TaskEnd
|
||||
from module.config.deep import deep_get, deep_set
|
||||
from module.exception import *
|
||||
@ -21,7 +22,7 @@ class AzurLaneAutoScript:
|
||||
AutoRestart_Enabled = False
|
||||
AutoRestart_AttemptsToRestart = 0
|
||||
AutoRestart_NotifyWhenAutoRestart = False
|
||||
|
||||
OtherLoginCount = 0
|
||||
def __init__(self, config_name='alas'):
|
||||
logger.hr('Start', level=0)
|
||||
self.config_name = config_name
|
||||
@ -76,6 +77,23 @@ class AzurLaneAutoScript:
|
||||
logger.exception(e)
|
||||
exit(1)
|
||||
|
||||
def handle_otherlogin(self):
|
||||
self.OtherLoginCount += 1
|
||||
logger.warning(f'OtherLogin_Count: {self.OtherLoginCount}')
|
||||
# self.device.app_stop()
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
# 将Optimization_otherLoginTime字符串转换为列表
|
||||
wait_times = [int(t) for t in self.config.Optimization_otherLoginTime.split(',')]
|
||||
# 根据计数选择等待时间,如果计数超过列表长度,使用最后一个值
|
||||
index = min(self.OtherLoginCount - 1, len(wait_times) - 1)
|
||||
wait_time = wait_times[index]
|
||||
logger.warning(f'Waiting for {wait_time} minutes before restarting')
|
||||
self.device.sleep(60 * wait_time)
|
||||
logger.warning("======OtherLogin_Sleep Over,now restart======")
|
||||
self.config.task_call('Restart')
|
||||
self.device.sleep(10)
|
||||
|
||||
def run(self, command, skip_first_screenshot=False):
|
||||
self.AutoRestart_Enabled = deep_get(self.config.data, "Restart.AutoRestart.Enabled")
|
||||
self.AutoRestart_NotifyWhenAutoRestart = deep_get(self.config.data, "Restart.AutoRestart.NotifyWhenAutoRestart")
|
||||
@ -93,15 +111,19 @@ class AzurLaneAutoScript:
|
||||
logger.warning(e)
|
||||
self.config.task_call('Restart')
|
||||
return False
|
||||
except OtherLogin as e:
|
||||
logger.error(e)
|
||||
self.handle_otherlogin()
|
||||
return False
|
||||
except (GameStuckError, GameTooManyClickError) as e:
|
||||
logger.error(e)
|
||||
self.save_error_log()
|
||||
from module.handler.info_handler import InfoHandler
|
||||
info_handler = InfoHandler(config=self.config,device=self.device)
|
||||
if info_handler.handle_urgent_commission():
|
||||
logger.warning("======OtherLogin_Sleep Over,now restart======")
|
||||
self.config.task_call('Restart')
|
||||
self.device.sleep(10)
|
||||
try:
|
||||
info_handler.handle_urgent_commission()
|
||||
except OtherLogin:
|
||||
self.handle_otherlogin()
|
||||
return False
|
||||
logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds')
|
||||
logger.warning('If you are playing by hand, please stop Alas')
|
||||
|
||||
@ -97,7 +97,8 @@
|
||||
"ScreenshotInterval": 0.3,
|
||||
"CombatScreenshotInterval": 1.0,
|
||||
"TaskHoardingDuration": 0,
|
||||
"WhenTaskQueueEmpty": "goto_main"
|
||||
"WhenTaskQueueEmpty": "goto_main",
|
||||
"otherLoginTime": "15,30,60"
|
||||
},
|
||||
"DropRecord": {
|
||||
"SaveFolder": "./screenshots",
|
||||
|
||||
@ -429,6 +429,10 @@
|
||||
"goto_main",
|
||||
"close_game"
|
||||
]
|
||||
},
|
||||
"otherLoginTime": {
|
||||
"type": "textarea",
|
||||
"value": "15,30,60"
|
||||
}
|
||||
},
|
||||
"DropRecord": {
|
||||
|
||||
@ -151,6 +151,9 @@ Optimization:
|
||||
WhenTaskQueueEmpty:
|
||||
value: goto_main
|
||||
option: [ stay_there, goto_main, close_game ]
|
||||
otherLoginTime:
|
||||
value: 15,30,60
|
||||
type: textarea
|
||||
DropRecord:
|
||||
SaveFolder: ./screenshots
|
||||
AzurStatsID: null
|
||||
|
||||
@ -110,6 +110,7 @@ class GeneratedConfig:
|
||||
Optimization_CombatScreenshotInterval = 1.0
|
||||
Optimization_TaskHoardingDuration = 0
|
||||
Optimization_WhenTaskQueueEmpty = 'goto_main' # stay_there, goto_main, close_game
|
||||
Optimization_otherLoginTime = '15,30,60'
|
||||
|
||||
# Group `DropRecord`
|
||||
DropRecord_SaveFolder = './screenshots'
|
||||
|
||||
@ -779,6 +779,10 @@
|
||||
"stay_there": "Stay There",
|
||||
"goto_main": "Goto Main Page",
|
||||
"close_game": "Close Game"
|
||||
},
|
||||
"otherLoginTime": {
|
||||
"name": "Remote Login Wait Time",
|
||||
"help": "Waiting time (minutes) when another device login is detected, a comma-separated list of numbers, each login detection will use the next value in sequence. Example: 15,30,60"
|
||||
}
|
||||
},
|
||||
"DropRecord": {
|
||||
|
||||
@ -779,6 +779,10 @@
|
||||
"stay_there": "stay_there",
|
||||
"goto_main": "goto_main",
|
||||
"close_game": "close_game"
|
||||
},
|
||||
"otherLoginTime": {
|
||||
"name": "Optimization.otherLoginTime.name",
|
||||
"help": "Optimization.otherLoginTime.help"
|
||||
}
|
||||
},
|
||||
"DropRecord": {
|
||||
|
||||
@ -779,6 +779,10 @@
|
||||
"stay_there": "停在原处",
|
||||
"goto_main": "前往主界面",
|
||||
"close_game": "关闭游戏"
|
||||
},
|
||||
"otherLoginTime": {
|
||||
"name": "异地登录等待时间",
|
||||
"help": "检测到其他设备登录时等待的时间(分钟),逗号分隔的数字列表,每次检测到登录会按顺序使用下一个值。例如: 15,30,60"
|
||||
}
|
||||
},
|
||||
"DropRecord": {
|
||||
|
||||
@ -779,6 +779,10 @@
|
||||
"stay_there": "停在原處",
|
||||
"goto_main": "前往主界面",
|
||||
"close_game": "關閉遊戲"
|
||||
},
|
||||
"otherLoginTime": {
|
||||
"name": "Optimization.otherLoginTime.name",
|
||||
"help": "Optimization.otherLoginTime.help"
|
||||
}
|
||||
},
|
||||
"DropRecord": {
|
||||
|
||||
@ -61,3 +61,5 @@ class RequestHumanTakeover(Exception):
|
||||
# Request human takeover
|
||||
# Alas is unable to handle such error, probably because of wrong settings.
|
||||
pass
|
||||
class OtherLogin(Exception):
|
||||
pass
|
||||
@ -4,7 +4,7 @@ from module.base.base import ModuleBase
|
||||
from module.base.button import Button
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import *
|
||||
from module.exception import GameNotRunningError
|
||||
from module.exception import GameNotRunningError, OtherLogin
|
||||
from module.handler.assets import *
|
||||
from module.logger import logger
|
||||
from module.os_handler.assets import CLICK_SAFE_AREA as OS_CLICK_SAFE_AREA
|
||||
@ -34,7 +34,6 @@ class InfoHandler(ModuleBase):
|
||||
"""
|
||||
Info bar
|
||||
"""
|
||||
|
||||
def info_bar_count(self):
|
||||
"""
|
||||
Detect info bar by the blue lines on the top of it.
|
||||
@ -171,15 +170,8 @@ class InfoHandler(ModuleBase):
|
||||
self._hot_fix_check_wait.reset()
|
||||
return False
|
||||
if appear2 or appear3:
|
||||
from module.base.resource import release_resources
|
||||
logger.warning('Other login in')
|
||||
logger.warning('Other login in')
|
||||
logger.warning('Other login in')
|
||||
self.device.app_stop()
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
self.device.sleep(60*15)
|
||||
return True
|
||||
raise OtherLogin
|
||||
|
||||
# Check game client existence after 3s to 6s
|
||||
# Hot fixes will kill AL if you clicked the confirm button
|
||||
|
||||
@ -141,6 +141,8 @@ class Camera(MapOperation):
|
||||
self.ensure_no_story(skip_first_screenshot=False)
|
||||
return False
|
||||
elif self.appear(GET_MISSION, offset=(20, 20)):
|
||||
logger.warning('GET_MISSION in UPDATE_VIEW')
|
||||
self.handle_urgent_commission()
|
||||
logger.warning('Perspective error caused by GET_MISSION')
|
||||
self.device.click(GET_MISSION)
|
||||
return False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user