mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Add: Loop rogue domains
This commit is contained in:
parent
d04ca2c3c6
commit
7a22c2394f
@ -277,7 +277,7 @@ class UI( MainPage):
|
||||
|
||||
def is_in_main(self):
|
||||
if self.appear(page_main.check_button):
|
||||
if self.image_color_count(page_main.check_button, color=(235, 235, 235), threshold=221, count=400):
|
||||
if self.image_color_count(page_main.check_button, color=(235, 235, 235), threshold=234, count=400):
|
||||
return True
|
||||
if self.appear(MAP_EXIT):
|
||||
if self.image_color_count(MAP_EXIT, color=(235, 235, 235), threshold=221, count=50):
|
||||
|
@ -1,3 +1,6 @@
|
||||
from module.base.button import ClickButton
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import area_offset
|
||||
from module.logger import logger
|
||||
from tasks.base.page import page_rogue
|
||||
from tasks.map.control.waypoint import ensure_waypoints
|
||||
@ -62,6 +65,7 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
|
||||
out: is_in_main()
|
||||
"""
|
||||
logger.info('Clear blessing')
|
||||
switched = False
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
@ -71,9 +75,12 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
|
||||
# End
|
||||
if self.is_in_main():
|
||||
logger.info(f'clear_blessing() ended at page_main')
|
||||
if switched:
|
||||
self.wait_until_minimap_stabled()
|
||||
break
|
||||
|
||||
if self.handle_blessing():
|
||||
switched = True
|
||||
continue
|
||||
|
||||
def clear_occurrence(self, skip_first_screenshot=True):
|
||||
@ -114,6 +121,13 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
|
||||
self.clear_blessing()
|
||||
return result
|
||||
|
||||
def wait_until_minimap_stabled(self):
|
||||
logger.info('Wait until minimap stabled')
|
||||
radius = self.minimap.MINIMAP_RADIUS
|
||||
area = area_offset((-radius, -radius, radius, radius), offset=self.minimap.MINIMAP_CENTER)
|
||||
minimap = ClickButton(area, name='MINIMAP')
|
||||
self.wait_until_stable(minimap, timeout=Timer(1.5, count=5))
|
||||
|
||||
"""
|
||||
Additional rogue methods
|
||||
"""
|
||||
@ -215,6 +229,7 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
|
||||
# End
|
||||
if self.is_in_main():
|
||||
logger.info('Entered another domain')
|
||||
self.wait_until_minimap_stabled()
|
||||
break
|
||||
if self.ui_page_appear(page_rogue):
|
||||
logger.info('Rogue cleared')
|
||||
@ -271,6 +286,7 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
|
||||
end_point.expected_end.append(self._domain_exit_expected_end)
|
||||
end_point.lock_direction = direction
|
||||
self.goto(end_point)
|
||||
self._domain_exit_wait_next()
|
||||
|
||||
return result
|
||||
|
||||
|
@ -5,6 +5,7 @@ import numpy as np
|
||||
from module.base.decorator import cached_property
|
||||
from module.logger import logger
|
||||
from tasks.base.main_page import MainPage
|
||||
from tasks.base.page import page_rogue
|
||||
from tasks.map.keywords import MapPlane
|
||||
from tasks.map.keywords.plane import (
|
||||
Herta_MasterControlZone,
|
||||
@ -29,7 +30,7 @@ def model_from_json(model, file: str):
|
||||
|
||||
class MinimapWrapper:
|
||||
@cached_property
|
||||
def all_minimap(self) -> dict[(str, str), Minimap]:
|
||||
def all_minimap(self) -> dict[str, Minimap]:
|
||||
"""
|
||||
Returns:
|
||||
dict: Key: {world}_{plane}_{floor}, e.g. Jarilo_SilvermaneGuardRestrictedZone_F1
|
||||
@ -161,16 +162,51 @@ class RouteLoader(MinimapWrapper, RouteLoader_, MainPage):
|
||||
"""
|
||||
Run a rogue domain
|
||||
|
||||
Returns:
|
||||
bool: True if success, False if route unknown
|
||||
|
||||
Pages:
|
||||
in: page_main
|
||||
out: page_main, at another domain
|
||||
or page_rogue if rogue cleared
|
||||
"""
|
||||
route = self.position_find_known(self.device.image)
|
||||
if route is not None:
|
||||
super().route_run(route)
|
||||
return True
|
||||
else:
|
||||
self.position_find_bruteforce(self.device.image)
|
||||
logger.error('New route detected, please record it')
|
||||
return False
|
||||
|
||||
def rogue_run(self, skip_first_screenshot=True):
|
||||
"""
|
||||
Do a complete rogue run, no error handle yet.
|
||||
|
||||
Pages:
|
||||
in: page_rogue, LAUNCH_SIMULATED_UNIVERSE
|
||||
out: page_rogue, world selecting page
|
||||
"""
|
||||
base = RouteBase(config=self.config, device=self.device, task=self.config.task.command)
|
||||
count = 1
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
logger.hr(f'Route run: {count}', level=1)
|
||||
base.clear_blessing()
|
||||
success = self.route_run()
|
||||
if not success:
|
||||
# self.device.image_save()
|
||||
continue
|
||||
|
||||
# End
|
||||
if self.ui_page_appear(page_rogue):
|
||||
break
|
||||
|
||||
count += 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -180,6 +216,4 @@ if __name__ == '__main__':
|
||||
# self.position_find_bruteforce(self.device.image)
|
||||
|
||||
self.device.screenshot()
|
||||
base = RouteBase(config=self.config, device=self.device, task='Rogue')
|
||||
base.clear_blessing()
|
||||
self.route_run()
|
||||
self.rogue_run()
|
||||
|
Loading…
Reference in New Issue
Block a user