1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 19:55:12 +00:00

feat(bounty): add error handler choice

This commit is contained in:
YoursFunny 2023-11-20 17:28:55 +08:00
parent bbf3bf7c36
commit 2c19afdf26
Signed by: YoursFunny
GPG Key ID: 207EDC3CD5B40F9C
8 changed files with 55 additions and 2 deletions

View File

@ -70,6 +70,9 @@
"Command": "Bounty", "Command": "Bounty",
"ServerUpdate": "04:00" "ServerUpdate": "04:00"
}, },
"Bounty": {
"OnError": "skip"
},
"Highway": { "Highway": {
"Stage": 1, "Stage": 1,
"Count": 2 "Count": 2

View File

@ -283,6 +283,16 @@
"display": "hide" "display": "hide"
} }
}, },
"Bounty": {
"OnError": {
"type": "select",
"value": "skip",
"option": [
"stop",
"skip"
]
}
},
"Highway": { "Highway": {
"Stage": { "Stage": {
"type": "select", "type": "select",

View File

@ -81,6 +81,11 @@ Cafe:
AutoAdjust: true AutoAdjust: true
SecondCafe: true SecondCafe: true
Bounty:
OnError:
value: skip
option: [ stop, skip ]
Highway: Highway:
Stage: Stage:
value: 1 value: 1

View File

@ -31,6 +31,7 @@ Daily:
- Scheduler - Scheduler
Bounty: Bounty:
- Scheduler - Scheduler
- Bounty
- Highway - Highway
- DesertRailroad - DesertRailroad
- Schoolhouse - Schoolhouse

View File

@ -45,6 +45,9 @@ class GeneratedConfig:
Cafe_AutoAdjust = True Cafe_AutoAdjust = True
Cafe_SecondCafe = True Cafe_SecondCafe = True
# Group `Bounty`
Bounty_OnError = 'skip' # stop, skip
# Group `Highway` # Group `Highway`
Highway_Stage = 1 # 1, 2, 3, 4, 5, 6, 7, 8, 9 Highway_Stage = 1 # 1, 2, 3, 4, 5, 6, 7, 8, 9
Highway_Count = 2 Highway_Count = 2

View File

@ -213,6 +213,18 @@
"help": "JP server only\nEnable auto switch to second floor and perform interaction" "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": { "Highway": {
"_info": { "_info": {
"name": "Overpass", "name": "Overpass",

View File

@ -213,6 +213,18 @@
"help": "仅支持日服\n自动切换第二咖啡厅进行互动点击" "help": "仅支持日服\n自动切换第二咖啡厅进行互动点击"
} }
}, },
"Bounty": {
"_info": {
"name": "悬赏通缉设置",
"help": ""
},
"OnError": {
"name": "错误处理",
"help": "当出现票券不足或设置有误等错误时,执行该操作",
"stop": "停止脚本运行",
"skip": "跳过当前任务"
}
},
"Highway": { "Highway": {
"_info": { "_info": {
"name": "高架公路", "name": "高架公路",

View File

@ -33,9 +33,16 @@ class Bounty(BountyUI):
task = list(self.bounty_info) task = list(self.bounty_info)
if not task: if not task:
logger.warning('Bounty enabled but no task set') 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_delay(server_update=True)
self.config.task_stop() self.config.task_stop()
return task
@property @property
def is_ticket_enough(self) -> bool: def is_ticket_enough(self) -> bool:
@ -67,7 +74,7 @@ class Bounty(BountyUI):
case BountyStatus.SELECT: case BountyStatus.SELECT:
if not self.is_ticket_enough: if not self.is_ticket_enough:
logger.warning('Bounty ticket not enough') logger.warning('Bounty ticket not enough')
raise RequestHumanTakeover self.error_handler()
if self.select_bounty(*self.current_bounty): if self.select_bounty(*self.current_bounty):
return BountyStatus.ENTER return BountyStatus.ENTER
case BountyStatus.ENTER: case BountyStatus.ENTER: