From 2faaa2b2ad97a002f40fad939ad7a794f306363f Mon Sep 17 00:00:00 2001 From: yanyihui <3325444627@qq.com> Date: Fri, 17 Dec 2021 19:15:45 +0800 Subject: [PATCH] fix: merge func TryRestart into HandleError --- alas.py | 22 ++++++++++++---------- config/template.json | 3 +-- module/config/argument/args.json | 4 ---- module/config/argument/argument.yaml | 1 - module/config/config_generated.py | 1 - module/config/i18n/en-US.json | 6 +----- module/config/i18n/zh-CN.json | 6 +----- module/config/i18n/zh-TW.json | 6 +----- 8 files changed, 16 insertions(+), 33 deletions(-) diff --git a/alas.py b/alas.py index 1bcecd4f5..49affe3a6 100644 --- a/alas.py +++ b/alas.py @@ -70,21 +70,16 @@ class AzurLaneAutoScript: except ScriptError as e: logger.critical(e) logger.critical('This is likely to be a mistake of developers, but sometimes just random issues') - if self.config.Error_TryRestart: - self.config.Scheduler_Enable = False - self.config.task_call('Restart') - self.device.sleep(10) - return False - else: - exit(1) + exit(1) except RequestHumanTakeover: logger.critical('Request human takeover') exit(1) except Exception as e: logger.exception(e) self.save_error_log() - if self.config.Error_TryRestart: + if self.config.Error_HandleError: self.config.Scheduler_Enable = False + logger.warning(f'Try restarting, {self.config.Emulator_PackageName} will be restarted in 10 seconds') self.config.task_call('Restart') self.device.sleep(10) return False @@ -366,8 +361,15 @@ class AzurLaneAutoScript: "Please read the help text of the options.") logger.critical("Possible reason: There is a problem with this task. " "Please contact developers or try to fix it yourself.") - logger.critical('Request human takeover') - exit(1) + if self.config.Error_HandleError: + self.config.Scheduler_Enable = False + logger.warning(f'Try restarting, {self.config.Emulator_PackageName} will be restarted in 10 seconds') + self.config.task_call('Restart') + self.device.sleep(10) + return False + else: + logger.critical('Request human takeover') + exit(1) if success: del self.__dict__['config'] diff --git a/config/template.json b/config/template.json index f7a0061e6..4525cb0bd 100644 --- a/config/template.json +++ b/config/template.json @@ -10,8 +10,7 @@ "Error": { "HandleError": true, "SaveError": true, - "ScreenshotLength": 1, - "TryRestart": false + "ScreenshotLength": 1 }, "Optimization": { "CombatScreenshotInterval": 1.0, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index d5610c6ab..b9b2cbd3b 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -50,10 +50,6 @@ "ScreenshotLength": { "type": "input", "value": 1 - }, - "TryRestart": { - "type": "checkbox", - "value": false } }, "Optimization": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 97ce8feb7..47b79182d 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -29,7 +29,6 @@ Error: HandleError: true SaveError: true ScreenshotLength: 1 - TryRestart: false Optimization: CombatScreenshotInterval: 1.0 TaskHoardingDuration: 0 diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 61696430f..02dcdbea9 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -28,7 +28,6 @@ class GeneratedConfig: Error_HandleError = True Error_SaveError = True Error_ScreenshotLength = 1 - Error_TryRestart = False # Group `Optimization` Optimization_CombatScreenshotInterval = 1.0 diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 924f03c30..63ddbbfd4 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -296,7 +296,7 @@ }, "HandleError": { "name": "Enable Exception Handling", - "help": "Handles select exceptions, will retreat if in battle" + "help": "Handles select exceptions, will retreat if in battle\nIn some tasks, will disable the error task and try restarting" }, "SaveError": { "name": "Record Exception", @@ -305,10 +305,6 @@ "ScreenshotLength": { "name": "Record Screenshot(s)", "help": "Number of screenshots saved when exception occurs" - }, - "TryRestart": { - "name": "Try Restart", - "help": "Handle some exceptions,will disable the error task and try restarting" } }, "Optimization": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 30aed9ea9..36139a22e 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -296,7 +296,7 @@ }, "HandleError": { "name": "启用异常处理", - "help": "处理部分异常,运行出错时撤退" + "help": "处理部分异常,运行出错时撤退\n部分任务中,会将出错的任务移出列表,并重启游戏" }, "SaveError": { "name": "出错时,保存 Log 和截图", @@ -305,10 +305,6 @@ "ScreenshotLength": { "name": "出错时,保留最后 X 张截图", "help": "" - }, - "TryRestart": { - "name": "出错时,尝试重启(未完成)", - "help": "处理部分异常,将出错的任务移出列表,并重启游戏" } }, "Optimization": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 4b0d901ea..197fbfaa6 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -296,7 +296,7 @@ }, "HandleError": { "name": "啟用異常處理", - "help": "處理部分異常,執行出錯時撤退" + "help": "處理部分異常,執行出錯時撤退\n部分任務中,會將出錯的任務移出列表,並重啟遊戲" }, "SaveError": { "name": "出錯時,保存 Log 和截圖", @@ -305,10 +305,6 @@ "ScreenshotLength": { "name": "出錯時,保留最後 X 張截圖", "help": "" - }, - "TryRestart": { - "name": "出錯時,嘗試重啟(未完成)", - "help": "處理部分異常,將出錯的任務移出列表,並重啟遊戲" } }, "Optimization": {