From 5e4abc147e354d4efab1a83c3a42f7d312e262f2 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 20 Nov 2023 16:50:18 +0800 Subject: [PATCH] feat(bounty): detect ticket and end when zero --- tasks/bounty/bounty.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tasks/bounty/bounty.py b/tasks/bounty/bounty.py index 9e85db9..a848167 100644 --- a/tasks/bounty/bounty.py +++ b/tasks/bounty/bounty.py @@ -39,7 +39,7 @@ class Bounty(BountyUI): @property def is_ticket_enough(self) -> bool: - return self.config.stored.BountyTicket.value >= self.current_count + return self.current_ticket >= self.current_count @property def current_bounty(self): @@ -53,6 +53,10 @@ class Bounty(BountyUI): def current_count(self): return self.task[0][3] + @property + def current_ticket(self): + return self.config.stored.BountyTicket.value + def handle_bounty(self, status): match status: case BountyStatus.OCR: @@ -60,6 +64,9 @@ class Bounty(BountyUI): return BountyStatus.SELECT case BountyStatus.SELECT: if not self.is_ticket_enough: + if self.current_ticket == 0: + logger.info('Bounty ticket empty') + return BountyStatus.FINISH logger.warning('Bounty ticket not enough') raise RequestHumanTakeover if self.select_bounty(*self.current_bounty):