mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: state loop
This commit is contained in:
parent
aaa3c5badb
commit
bbe7d10746
@ -3,7 +3,9 @@ from module.logger import logger
|
||||
from module.ocr.ocr import Digit
|
||||
from tasks.base.assets.assets_base_popup import POPUP_CONFIRM, POPUP_CANCEL
|
||||
from tasks.base.ui import UI
|
||||
from tasks.combat.assets.assets_combat_finish import COMBAT_AGAIN
|
||||
from tasks.combat.assets.assets_combat_prepare import (
|
||||
COMBAT_PREPARE,
|
||||
EXTRACT_RESERVED_TRAILBLAZE_POWER,
|
||||
FUEL,
|
||||
FUEL_SELECTED,
|
||||
@ -15,6 +17,14 @@ from tasks.combat.assets.assets_combat_prepare import (
|
||||
|
||||
|
||||
class Fuel(UI):
|
||||
def _use_fuel_finish(self):
|
||||
"""
|
||||
Two possible finish states after using fuel/extract trailblaze power:
|
||||
1. COMBAT_PREPARE
|
||||
2. COMBAT_AGAIN
|
||||
"""
|
||||
return self.appear(COMBAT_PREPARE) or self.appear(COMBAT_AGAIN)
|
||||
|
||||
def extract_reserved_trailblaze_power(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Extract reserved trailblaze power from previous combat.
|
||||
@ -34,6 +44,9 @@ class Fuel(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self._use_fuel_finish():
|
||||
break
|
||||
|
||||
if self.appear_then_click(EXTRACT_RESERVED_TRAILBLAZE_POWER):
|
||||
continue
|
||||
if self.appear_then_click(RESERVED_TRAILBLAZE_POWER_ENTRANCE):
|
||||
@ -41,7 +54,7 @@ class Fuel(UI):
|
||||
if self.appear_then_click(POPUP_CONFIRM):
|
||||
continue
|
||||
if self.handle_reward():
|
||||
break
|
||||
continue
|
||||
|
||||
def use_fuel(self, skip_first_screenshot=True):
|
||||
logger.info("Use Fuel")
|
||||
@ -51,7 +64,7 @@ class Fuel(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if not self.appear(FUEL) and not self.appear(FUEL_SELECTED):
|
||||
if self.appear(POPUP_CONFIRM) and not (self.appear(FUEL_SELECTED) and self.appear(FUEL)):
|
||||
logger.info("No fuel found")
|
||||
return
|
||||
if self.appear(FUEL_SELECTED):
|
||||
@ -60,8 +73,6 @@ class Fuel(UI):
|
||||
continue
|
||||
if self.appear_then_click(FUEL_ENTRANCE):
|
||||
continue
|
||||
if self.handle_reward():
|
||||
break
|
||||
|
||||
offset = FUEL_SELECTED.button_offset
|
||||
count = Digit(OCR_FUEL).ocr_single_line(crop(self.device.image, area_offset(OCR_FUEL.area, offset)),
|
||||
@ -81,8 +92,11 @@ class Fuel(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.handle_reward():
|
||||
if self._use_fuel_finish():
|
||||
break
|
||||
|
||||
if self.handle_reward():
|
||||
continue
|
||||
# by default, use one fuel each time
|
||||
if self.appear_then_click(POPUP_CONFIRM):
|
||||
continue
|
Loading…
Reference in New Issue
Block a user