mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +00:00
Fix: Detect empty fuel
This commit is contained in:
parent
4a9e8066a0
commit
be4c401913
BIN
assets/share/combat/prepare/FUEL.SEARCH.png
Normal file
BIN
assets/share/combat/prepare/FUEL.SEARCH.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 27 KiB |
@ -34,10 +34,10 @@ FUEL = ButtonWrapper(
|
||||
name='FUEL',
|
||||
share=Button(
|
||||
file='./assets/share/combat/prepare/FUEL.png',
|
||||
area=(592, 276, 688, 388),
|
||||
search=(572, 256, 708, 408),
|
||||
color=(113, 90, 123),
|
||||
button=(592, 276, 688, 388),
|
||||
area=(592, 276, 688, 366),
|
||||
search=(474, 271, 811, 396),
|
||||
color=(123, 96, 134),
|
||||
button=(592, 276, 688, 366),
|
||||
),
|
||||
)
|
||||
FUEL_ENTRANCE = ButtonWrapper(
|
||||
@ -74,10 +74,10 @@ FUEL_SELECTED = ButtonWrapper(
|
||||
name='FUEL_SELECTED',
|
||||
share=Button(
|
||||
file='./assets/share/combat/prepare/FUEL_SELECTED.png',
|
||||
area=(587, 271, 692, 395),
|
||||
area=(587, 271, 692, 368),
|
||||
search=(474, 271, 811, 396),
|
||||
color=(130, 111, 137),
|
||||
button=(587, 271, 692, 395),
|
||||
color=(136, 112, 144),
|
||||
button=(587, 271, 692, 368),
|
||||
),
|
||||
)
|
||||
FUEL_SLIDER = ButtonWrapper(
|
||||
|
@ -1,4 +1,5 @@
|
||||
import module.config.server as server
|
||||
from module.base.timer import Timer
|
||||
|
||||
from module.base.utils import crop, area_offset
|
||||
from module.logger import logger
|
||||
@ -122,9 +123,10 @@ class Fuel(UI):
|
||||
skip_first_screenshot=True
|
||||
)
|
||||
|
||||
def set_fuel_count(self, count, total):
|
||||
def set_fuel_count(self, count):
|
||||
slider = Slider(main=self, slider=FUEL_SLIDER)
|
||||
slider.set(count, total)
|
||||
# Can only use 5 fuel at one time
|
||||
slider.set(count, 5)
|
||||
self.ui_ensure_index(
|
||||
count, letter=Digit(OCR_FUEL_COUNT, lang=server.lang),
|
||||
next_button=FUEL_PLUS, prev_button=FUEL_MINUS,
|
||||
@ -139,20 +141,29 @@ class Fuel(UI):
|
||||
return
|
||||
|
||||
logger.info("Use Fuel")
|
||||
|
||||
timeout = Timer(1, count=3)
|
||||
has_fuel = False
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
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):
|
||||
logger.info('Fuel selected')
|
||||
break
|
||||
if self.appear(POPUP_CONFIRM):
|
||||
timeout.start()
|
||||
if self.appear(FUEL_SELECTED) or self.appear(FUEL):
|
||||
has_fuel = True
|
||||
if not has_fuel and timeout.reached():
|
||||
logger.info("No fuel found")
|
||||
return
|
||||
if self.appear_then_click(FUEL):
|
||||
has_fuel = True
|
||||
continue
|
||||
if self.appear_then_click(FUEL_ENTRANCE):
|
||||
if not self.appear(POPUP_CONFIRM) and self.appear_then_click(FUEL_ENTRANCE):
|
||||
continue
|
||||
|
||||
offset = FUEL_SELECTED.button_offset
|
||||
@ -178,6 +189,8 @@ class Fuel(UI):
|
||||
break
|
||||
if self.appear(FUEL) and self.handle_popup_confirm():
|
||||
continue
|
||||
if self.appear(FUEL_SELECTED) and self.handle_popup_confirm():
|
||||
continue
|
||||
|
||||
self.set_fuel_count(use, count)
|
||||
self.set_fuel_count(use)
|
||||
self._fuel_confirm()
|
||||
|
Loading…
Reference in New Issue
Block a user