mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 06:18:21 +08:00
Fix: Oil limit not working in raid
- Add wait_until_stable - Add ensure_combat_oil_loaded - Add grid_location_to_screen_point
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from module.campaign.run import OCR_OIL
|
||||
from module.combat.assets import *
|
||||
from module.combat.combat import Combat
|
||||
from module.logger import logger
|
||||
@@ -6,6 +7,10 @@ from module.raid.assets import *
|
||||
from module.ui.assets import RAID_CHECK
|
||||
|
||||
|
||||
class OilExhausted(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Raid(MapOperation, Combat):
|
||||
def combat_preparation(self, balance_hp=False, emotion_reduce=False, auto=True, fleet_index=1):
|
||||
"""
|
||||
@@ -16,6 +21,7 @@ class Raid(MapOperation, Combat):
|
||||
fleet_index (int):
|
||||
"""
|
||||
logger.info('Combat preparation.')
|
||||
oil_checked = False
|
||||
|
||||
if emotion_reduce:
|
||||
self.emotion.wait(fleet=fleet_index)
|
||||
@@ -26,6 +32,13 @@ class Raid(MapOperation, Combat):
|
||||
if self.appear(BATTLE_PREPARATION):
|
||||
if self.handle_combat_automation_set(auto=auto):
|
||||
continue
|
||||
if not oil_checked and self.config.STOP_IF_OIL_LOWER_THAN:
|
||||
self.ensure_combat_oil_loaded()
|
||||
oil = OCR_OIL.ocr(self.device.image)
|
||||
oil_checked = True
|
||||
if oil < self.config.STOP_IF_OIL_LOWER_THAN:
|
||||
logger.hr('Triggered oil limit')
|
||||
raise OilExhausted()
|
||||
if self.handle_raid_ticket_use():
|
||||
continue
|
||||
if self.handle_retirement():
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from module.campaign.run import CampaignRun
|
||||
from module.exception import ScriptEnd
|
||||
from module.logger import logger
|
||||
from module.raid.raid import Raid
|
||||
from module.raid.raid import Raid, OilExhausted
|
||||
from module.ui.page import page_raid
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class RaidRun(Raid, CampaignRun):
|
||||
if not name or not mode:
|
||||
logger.warning(f'RaidRun arguments unfilled. name={name}, mode={mode}')
|
||||
|
||||
self.config.STOP_IF_OIL_LOWER_THAN = 0 # No oil shows on page_raid
|
||||
self.campaign = self # A trick to call CampaignRun
|
||||
self.campaign_name_set(f'{name}_{mode}')
|
||||
|
||||
@@ -43,7 +42,10 @@ class RaidRun(Raid, CampaignRun):
|
||||
logger.info(f'Count: [{self.run_count}]')
|
||||
|
||||
# End
|
||||
if self.triggered_stop_condition():
|
||||
oil_backup, self.config.STOP_IF_OIL_LOWER_THAN = self.config.STOP_IF_OIL_LOWER_THAN, 0
|
||||
triggered = self.triggered_stop_condition()
|
||||
self.config.STOP_IF_OIL_LOWER_THAN = oil_backup
|
||||
if triggered:
|
||||
break
|
||||
|
||||
# UI ensure
|
||||
@@ -52,6 +54,9 @@ class RaidRun(Raid, CampaignRun):
|
||||
# Run
|
||||
try:
|
||||
self.raid_execute_once(mode=mode if mode else self.config.RAID_MODE)
|
||||
except OilExhausted:
|
||||
self.ui_goto_main()
|
||||
break
|
||||
except ScriptEnd as e:
|
||||
logger.hr('Script end')
|
||||
logger.info(str(e))
|
||||
|
||||
Reference in New Issue
Block a user