mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 10:01:10 +00:00
Refactor: Chain calling waypoint methods
This commit is contained in:
parent
3cef01729a
commit
ee7cd3958d
@ -357,13 +357,13 @@ if __name__ == '__main__':
|
||||
self.minimap.init_position((519, 359))
|
||||
# Visit 3 items
|
||||
self.clear_item(
|
||||
Waypoint.run_2x((587.6, 366.9)),
|
||||
Waypoint((587.6, 366.9)).run_2x(),
|
||||
)
|
||||
self.clear_item((575.5, 377.4))
|
||||
self.clear_item(
|
||||
# Go through arched door
|
||||
Waypoint.run((581.5, 383.3), threshold=3),
|
||||
Waypoint.run((575.7, 417.2)),
|
||||
Waypoint((581.5, 383.3)).run().set_threshold(3),
|
||||
Waypoint((575.7, 417.2)).run(),
|
||||
)
|
||||
# Goto boss
|
||||
self.clear_enemy((613.5, 427.3))
|
||||
|
@ -47,29 +47,29 @@ class Waypoint:
|
||||
|
||||
__repr__ = __str__
|
||||
|
||||
@classmethod
|
||||
def run_2x(cls, *args, **kwargs) -> "Waypoint":
|
||||
def run_2x(self) -> "Waypoint":
|
||||
"""
|
||||
Product a Waypoint object with overridden "speed",
|
||||
see Waypoint class for args.
|
||||
"""
|
||||
kwargs['speed'] = 'run_2x'
|
||||
return cls(*args, **kwargs)
|
||||
self.speed = 'run_2x'
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def straight_run(cls, *args, **kwargs) -> "Waypoint":
|
||||
kwargs['speed'] = 'straight_run'
|
||||
return cls(*args, **kwargs)
|
||||
def straight_run(self) -> "Waypoint":
|
||||
self.speed = 'straight_run'
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def run(cls, *args, **kwargs) -> "Waypoint":
|
||||
kwargs['speed'] = 'run'
|
||||
return cls(*args, **kwargs)
|
||||
def run(self) -> "Waypoint":
|
||||
self.speed = 'run'
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def walk(cls, *args, **kwargs) -> "Waypoint":
|
||||
kwargs['speed'] = 'walk'
|
||||
return cls(*args, **kwargs)
|
||||
def walk(self) -> "Waypoint":
|
||||
self.speed = 'walk'
|
||||
return self
|
||||
|
||||
def set_threshold(self, threshold) -> "Waypoint":
|
||||
self.threshold = threshold
|
||||
return self
|
||||
|
||||
def get_threshold(self, end):
|
||||
"""
|
||||
|
@ -46,7 +46,7 @@ class PositionPredictState:
|
||||
|
||||
|
||||
class Minimap(MapResource):
|
||||
def init_position(self, position: tuple[int, int]):
|
||||
def init_position(self, position: tuple[int | float, int | float]):
|
||||
logger.info(f"init_position:{position}")
|
||||
self.position = position
|
||||
|
||||
@ -388,7 +388,7 @@ if __name__ == '__main__':
|
||||
# MapResource.SRCMAP = '../srcmap/srcmap'
|
||||
self = Minimap()
|
||||
# Set plane, assume starting from Jarilo_AdministrativeDistrict
|
||||
self.set_plane('Jarilo_AdministrativeDistrict', floor='F1')
|
||||
self.set_plane('Jarilo_BackwaterPass', floor='F1')
|
||||
|
||||
ui = UI('src')
|
||||
ui.device.disable_stuck_detection()
|
||||
|
Loading…
Reference in New Issue
Block a user