mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Add: Check if team prepared
This commit is contained in:
parent
ce09d1ff22
commit
0951ba6e9e
BIN
assets/share/rogue/path/CHARACTER_EMPTY.SEARCH.png
Normal file
BIN
assets/share/rogue/path/CHARACTER_EMPTY.SEARCH.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
assets/share/rogue/path/CHARACTER_EMPTY.png
Normal file
BIN
assets/share/rogue/path/CHARACTER_EMPTY.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
@ -3,6 +3,16 @@ from module.base.button import Button, ButtonWrapper
|
|||||||
# This file was auto-generated, do not modify it manually. To generate:
|
# This file was auto-generated, do not modify it manually. To generate:
|
||||||
# ``` python -m dev_tools.button_extract ```
|
# ``` python -m dev_tools.button_extract ```
|
||||||
|
|
||||||
|
CHARACTER_EMPTY = ButtonWrapper(
|
||||||
|
name='CHARACTER_EMPTY',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/rogue/path/CHARACTER_EMPTY.png',
|
||||||
|
area=(546, 517, 558, 545),
|
||||||
|
search=(520, 500, 848, 564),
|
||||||
|
color=(106, 106, 108),
|
||||||
|
button=(546, 517, 558, 545),
|
||||||
|
),
|
||||||
|
)
|
||||||
CHECK_ABUNDANCE = ButtonWrapper(
|
CHECK_ABUNDANCE = ButtonWrapper(
|
||||||
name='CHECK_ABUNDANCE',
|
name='CHECK_ABUNDANCE',
|
||||||
share=Button(
|
share=Button(
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
from typing import Dict, Optional
|
|
||||||
|
|
||||||
from module.base.decorator import cached_property
|
from module.base.decorator import cached_property
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.exception import ScriptError
|
from module.exception import ScriptError
|
||||||
@ -8,6 +6,7 @@ from tasks.base.assets.assets_base_page import BACK
|
|||||||
from tasks.rogue.assets.assets_rogue_path import *
|
from tasks.rogue.assets.assets_rogue_path import *
|
||||||
from tasks.rogue.assets.assets_rogue_ui import ROGUE_LAUNCH
|
from tasks.rogue.assets.assets_rogue_ui import ROGUE_LAUNCH
|
||||||
from tasks.rogue.bleesing.ui import RogueUI
|
from tasks.rogue.bleesing.ui import RogueUI
|
||||||
|
from tasks.rogue.exception import RogueTeamNotPrepared
|
||||||
from tasks.rogue.keywords import KEYWORDS_ROGUE_PATH, RoguePath
|
from tasks.rogue.keywords import KEYWORDS_ROGUE_PATH, RoguePath
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ def area_pad_around(area, pad):
|
|||||||
|
|
||||||
class RoguePathHandler(RogueUI):
|
class RoguePathHandler(RogueUI):
|
||||||
@cached_property
|
@cached_property
|
||||||
def _rogue_path_checks(self) -> Dict[RoguePath, ButtonWrapper]:
|
def _rogue_path_checks(self) -> dict[RoguePath, ButtonWrapper]:
|
||||||
buttons = {
|
buttons = {
|
||||||
KEYWORDS_ROGUE_PATH.Preservation: CHECK_PRESERVATION,
|
KEYWORDS_ROGUE_PATH.Preservation: CHECK_PRESERVATION,
|
||||||
KEYWORDS_ROGUE_PATH.Remembrance: CHECK_REMEMBRANCE,
|
KEYWORDS_ROGUE_PATH.Remembrance: CHECK_REMEMBRANCE,
|
||||||
@ -45,7 +44,7 @@ class RoguePathHandler(RogueUI):
|
|||||||
return buttons
|
return buttons
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def _rogue_path_clicks(self) -> Dict[RoguePath, ButtonWrapper]:
|
def _rogue_path_clicks(self) -> dict[RoguePath, ButtonWrapper]:
|
||||||
buttons = {
|
buttons = {
|
||||||
KEYWORDS_ROGUE_PATH.Preservation: CLICK_PRESERVATION,
|
KEYWORDS_ROGUE_PATH.Preservation: CLICK_PRESERVATION,
|
||||||
KEYWORDS_ROGUE_PATH.Remembrance: CLICK_REMEMBRANCE,
|
KEYWORDS_ROGUE_PATH.Remembrance: CLICK_REMEMBRANCE,
|
||||||
@ -67,7 +66,7 @@ class RoguePathHandler(RogueUI):
|
|||||||
logger.critical(f'Invalid rogue path: {path}')
|
logger.critical(f'Invalid rogue path: {path}')
|
||||||
raise ScriptError
|
raise ScriptError
|
||||||
|
|
||||||
def _get_selected_path(self, skip_first_screenshot=True) -> Optional[RoguePath]:
|
def _get_selected_path(self, skip_first_screenshot=True) -> RoguePath | None:
|
||||||
timeout = Timer(1, count=5).start()
|
timeout = Timer(1, count=5).start()
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
@ -90,8 +89,21 @@ class RoguePathHandler(RogueUI):
|
|||||||
appear = [self.appear(button) for button in self._rogue_path_clicks.values()]
|
appear = [self.appear(button) for button in self._rogue_path_clicks.values()]
|
||||||
return all(appear)
|
return all(appear)
|
||||||
|
|
||||||
|
def _is_team_prepared(self) -> bool:
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: is_page_rogue_launch()
|
||||||
|
"""
|
||||||
|
slots = CHARACTER_EMPTY.match_multi_template(self.device.image)
|
||||||
|
slots = 4 - len(slots)
|
||||||
|
logger.attr('TeamSlotsPrepared', slots)
|
||||||
|
return slots > 0
|
||||||
|
|
||||||
def rogue_path_select(self, path: str | RoguePath, skip_first_screenshot=True):
|
def rogue_path_select(self, path: str | RoguePath, skip_first_screenshot=True):
|
||||||
"""
|
"""
|
||||||
|
Raises:
|
||||||
|
RogueTeamNotPrepared:
|
||||||
|
|
||||||
Pages:
|
Pages:
|
||||||
in: LAUNCH_ROGUE
|
in: LAUNCH_ROGUE
|
||||||
out: is_page_choose_bonus()
|
out: is_page_choose_bonus()
|
||||||
@ -115,7 +127,10 @@ class RoguePathHandler(RogueUI):
|
|||||||
logger.info('rogue_path_select ended at page_main')
|
logger.info('rogue_path_select ended at page_main')
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.appear_then_click(ROGUE_LAUNCH, interval=2):
|
if self.appear(ROGUE_LAUNCH, interval=2):
|
||||||
|
if not self._is_team_prepared():
|
||||||
|
raise RogueTeamNotPrepared
|
||||||
|
self.device.click(ROGUE_LAUNCH)
|
||||||
continue
|
continue
|
||||||
# The average level of your team is lower than the recommended level.
|
# The average level of your team is lower than the recommended level.
|
||||||
# Continue anyway?
|
# Continue anyway?
|
||||||
|
10
tasks/rogue/exception.py
Normal file
10
tasks/rogue/exception.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class RogueTeamNotPrepared(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RogueDomainExitNotFound(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RogueRouteError(Exception):
|
||||||
|
pass
|
@ -1,4 +1,6 @@
|
|||||||
|
from module.logger import logger
|
||||||
from tasks.rogue.entry.entry import RogueEntry
|
from tasks.rogue.entry.entry import RogueEntry
|
||||||
|
from tasks.rogue.exception import RogueTeamNotPrepared
|
||||||
from tasks.rogue.route.loader import RouteLoader
|
from tasks.rogue.route.loader import RouteLoader
|
||||||
|
|
||||||
|
|
||||||
@ -11,9 +13,16 @@ class RogueHandler(RouteLoader, RogueEntry):
|
|||||||
in: Any
|
in: Any
|
||||||
out: page_rogue, is_page_rogue_main()
|
out: page_rogue, is_page_rogue_main()
|
||||||
"""
|
"""
|
||||||
self.rogue_world_enter()
|
try:
|
||||||
|
self.rogue_world_enter()
|
||||||
|
except RogueTeamNotPrepared:
|
||||||
|
logger.error(f'Please prepare your team in {self.config.RogueWorld_World}')
|
||||||
|
self.rogue_world_exit()
|
||||||
|
return False
|
||||||
|
|
||||||
self.rogue_run()
|
self.rogue_run()
|
||||||
self.rogue_reward_claim()
|
self.rogue_reward_claim()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user