From 90c06f905446a809777544a38bded76eea4433a7 Mon Sep 17 00:00:00 2001 From: sui-feng-cb <2518179942@qq.com> Date: Mon, 11 May 2026 16:36:48 +0800 Subject: [PATCH] Upd: exception OilMaxed to control buy food trial --- module/commission/commission.py | 31 ++++++++++++++++++++++++------- module/exception.py | 4 ++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/module/commission/commission.py b/module/commission/commission.py index b259d8e34..195d84a13 100644 --- a/module/commission/commission.py +++ b/module/commission/commission.py @@ -12,7 +12,7 @@ from module.commission.project import COMMISSION_FILTER, Commission from module.config.config_generated import GeneratedConfig from module.config.utils import get_server_last_update, get_server_next_update from module.dorm.dorm import RewardDorm -from module.exception import GameStuckError +from module.exception import GameStuckError, OilMaxed, RequestHumanTakeover from module.handler.info_handler import InfoHandler from module.logger import logger from module.map.map_grids import SelectedGrids @@ -493,7 +493,7 @@ class RewardCommission(UI, InfoHandler): if not self.daily_choose and not self.urgent_choose: logger.info('No commission chose') - def commission_receive(self, skip_first_screenshot=True): + def _commission_receive(self, skip_first_screenshot=True): """ Args: skip_first_screenshot: @@ -559,13 +559,9 @@ class RewardCommission(UI, InfoHandler): # click_timer.reset() continue # handle oil maxed - # run once to prevent accidental oil consumption if self.config.SERVER in ['cn']: if self.appear(OIL_MAXED, offset=(20, 20), interval=3): - logger.info("Oil maxed, buy food to consume oil") - RewardDorm(self.config, self.device).dorm_food_run(amount=10) - self.ui_ensure(page_reward) - continue + raise OilMaxed # Check GET_SHIP at last to handle random white background at page_main for button in [GET_SHIP]: if click_timer.reached() and self.appear(button, interval=1): @@ -583,6 +579,27 @@ class RewardCommission(UI, InfoHandler): return reward + def commission_receive(self): + """ + Returns: + bool: If rewarded. + + Pages: + in: page_reward + out: page_commission + """ + for _ in range(3): + try: + reward = self._commission_receive() + return reward + except OilMaxed: + logger.info("Oil maxed, buy food to consume oil") + RewardDorm(self.config, self.device).dorm_food_run(amount=10) + self.ui_ensure(page_reward) + + logger.critical(f'Failed to handle oil maxed after 3 trial') + raise RequestHumanTakeover + def run(self): """ Pages: diff --git a/module/exception.py b/module/exception.py index e0d3ecf39..2e810c57c 100644 --- a/module/exception.py +++ b/module/exception.py @@ -6,6 +6,10 @@ class OilExhausted(Exception): pass +class OilMaxed(Exception): + pass + + class MapDetectionError(Exception): pass