Fix: Handle another PAUSE and remove direct use of PAUSE

This commit is contained in:
LmeSzinc 2024-05-09 18:50:32 +08:00
parent 6bd10d1a9d
commit 4e469098e2
3 changed files with 18 additions and 12 deletions

View File

@ -1,6 +1,7 @@
import numpy as np
from module.base.timer import Timer
from module.base.utils import get_color, color_similar
from module.combat.assets import *
from module.combat.combat_auto import CombatAuto
from module.combat.combat_manual import CombatManual
@ -78,7 +79,11 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
Returns:
bool:
"""
return self.appear(PAUSE) and np.max(self.image_crop(PAUSE_DOUBLE_CHECK)) < 153
color = get_color(self.device.image, PAUSE.area)
if color_similar(color, PAUSE.color) or color_similar(color, (238, 244, 248)):
if np.max(self.image_crop(PAUSE_DOUBLE_CHECK)) < 153:
return True
return False
def ensure_combat_oil_loaded(self):
self.wait_until_stable(COMBAT_OIL_LOADING)

View File

@ -6,17 +6,10 @@ from module.exercise.opponent import OPPONENT, OpponentChoose
from module.ui.assets import EXERCISE_CHECK
class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment, Combat):
def _in_exercise(self):
return self.appear(EXERCISE_CHECK, offset=(20, 20))
def is_combat_executing(self):
"""
Returns:
bool:
"""
return self.appear(PAUSE) and np.max(self.image_crop(PAUSE_DOUBLE_CHECK)) < 153
def _combat_preparation(self, skip_first_screenshot=True):
logger.info('Combat preparation')
self.device.stuck_record_clear()
@ -35,7 +28,7 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
continue
# End
if self.appear(PAUSE):
if self.is_combat_executing():
break
def _combat_execute(self):
@ -83,16 +76,19 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
# Quit
if self.appear_then_click(QUIT_CONFIRM, offset=(20, 20), interval=5):
pause_interval.reset()
success = False
end = True
continue
if self.appear_then_click(QUIT_RECONFIRM, offset=(20, 20), interval=5):
self.interval_reset(QUIT_CONFIRM)
pause_interval.reset()
continue
if not end:
if self._at_low_hp(image=self.device.image):
logger.info('Exercise quit')
if pause_interval.reached() and self.appear_then_click(PAUSE):
if pause_interval.reached() and self.is_combat_executing():
self.device.click(PAUSE)
pause_interval.reset()
continue
else:

View File

@ -539,6 +539,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
def interrupt_auto_search(self, skip_first_screenshot=True):
logger.info('Interrupting auto search')
is_loading = False
pause_interval = Timer(0.5, count=1)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -552,14 +553,18 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3):
continue
if self.appear_then_click(PAUSE, interval=0.5):
if pause_interval.reached() and self.is_combat_executing():
self.device.click(PAUSE)
self.interval_reset(MAINTENANCE_ANNOUNCE)
pause_interval.reset()
continue
if self.appear_then_click(QUIT_CONFIRM, offset=(20, 20), interval=5):
self.interval_reset(MAINTENANCE_ANNOUNCE)
pause_interval.reset()
continue
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
self.interval_reset(MAINTENANCE_ANNOUNCE)
pause_interval.reset()
continue
if self.appear_then_click(GOTO_MAIN, offset=(20, 20), interval=3):