diff --git a/config/template.json b/config/template.json index 32e3802..3cf7232 100644 --- a/config/template.json +++ b/config/template.json @@ -70,6 +70,9 @@ "Command": "Bounty", "ServerUpdate": "04:00" }, + "Bounty": { + "OnError": "skip" + }, "Highway": { "Stage": 1, "Count": 2 diff --git a/module/config/argument/args.json b/module/config/argument/args.json index db609e0..d92674e 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -283,6 +283,16 @@ "display": "hide" } }, + "Bounty": { + "OnError": { + "type": "select", + "value": "skip", + "option": [ + "stop", + "skip" + ] + } + }, "Highway": { "Stage": { "type": "select", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index eda1b66..33ea74c 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -81,6 +81,11 @@ Cafe: AutoAdjust: true SecondCafe: true +Bounty: + OnError: + value: skip + option: [ stop, skip ] + Highway: Stage: value: 1 diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index b37f270..e6ce8a0 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -31,6 +31,7 @@ Daily: - Scheduler Bounty: - Scheduler + - Bounty - Highway - DesertRailroad - Schoolhouse diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 876f2b0..9b787b5 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -45,6 +45,9 @@ class GeneratedConfig: Cafe_AutoAdjust = True Cafe_SecondCafe = True + # Group `Bounty` + Bounty_OnError = 'skip' # stop, skip + # Group `Highway` Highway_Stage = 1 # 1, 2, 3, 4, 5, 6, 7, 8, 9 Highway_Count = 2 diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 4073d47..ee222bc 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -213,6 +213,18 @@ "help": "JP server only\nEnable auto switch to second floor and perform interaction" } }, + "Bounty": { + "_info": { + "name": "Bounty Settings", + "help": "" + }, + "OnError": { + "name": "Error Handling", + "help": "Perform the selected action when an error occurs (ticket not enough or any invalid setting)", + "stop": "Stop script", + "skip": "Skip current task" + } + }, "Highway": { "_info": { "name": "Overpass", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index ba97986..1f6dd05 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -213,6 +213,18 @@ "help": "仅支持日服\n自动切换第二咖啡厅进行互动点击" } }, + "Bounty": { + "_info": { + "name": "悬赏通缉设置", + "help": "" + }, + "OnError": { + "name": "错误处理", + "help": "当出现票券不足或设置有误等错误时,执行该操作", + "stop": "停止脚本运行", + "skip": "跳过当前任务" + } + }, "Highway": { "_info": { "name": "高架公路", diff --git a/tasks/bounty/bounty.py b/tasks/bounty/bounty.py index 9798453..0f29f76 100644 --- a/tasks/bounty/bounty.py +++ b/tasks/bounty/bounty.py @@ -33,9 +33,16 @@ class Bounty(BountyUI): task = list(self.bounty_info) if not task: logger.warning('Bounty enabled but no task set') + self.error_handler() + return task + + def error_handler(self): + action = self.config.Bounty_OnError + if action == 'stop': + raise RequestHumanTakeover + elif action == 'skip': self.config.task_delay(server_update=True) self.config.task_stop() - return task @property def is_ticket_enough(self) -> bool: @@ -67,7 +74,7 @@ class Bounty(BountyUI): case BountyStatus.SELECT: if not self.is_ticket_enough: logger.warning('Bounty ticket not enough') - raise RequestHumanTakeover + self.error_handler() if self.select_bounty(*self.current_bounty): return BountyStatus.ENTER case BountyStatus.ENTER: