def boss_goto(self, location=(0, 0), has_fleet_step=False, drop=None): logger.hr('BOSS goto') while 1: # Update local view # Not screenshots taking, reuse the old one self.update_os() self.predict() self.predict_radar() # Calculate destination grids = self.radar.select(is_enemy=True) if grids: # Click way point grid = np.add(location_ensure(grids[0]), location) grid = point_limit(grid, area=(-4, -2, 3, 2)) if has_fleet_step: grid = limit_walk(grid) if grid == (0, 0): logger.info(f'Arrive destination: boss {location}') break grid = self.convert_radar_to_local(grid) self.device.click(grid) else: logger.info('No boss to goto, stop') break # Wait until arrived # Having new screenshots self.wait_until_walk_stable(confirm_timer=Timer(1.5, count=4), walk_out_of_step=False, drop=drop)
def question_goto(self, has_fleet_step=False): logger.hr('Question goto') while 1: # Update local view # Not screenshots taking, reuse the old one self.update_os() self.predict() self.predict_radar() # Calculate destination grids = self.radar.select(is_question=True) if grids: # Click way point grid = location_ensure(grids[0]) grid = point_limit(grid, area=(-4, -2, 3, 2)) if has_fleet_step: grid = limit_walk(grid) grid = self.convert_radar_to_local(grid) self.device.click(grid) else: logger.info('No question mark to goto, stop') break # Wait until arrived # Having new screenshots self.wait_until_walk_stable(confirm_timer=Timer(1.5, count=4), walk_out_of_step=False)
def port_goto(self): """ A simple and poor implement to goto port. Searching port on radar. In OpSi, camera always focus to fleet when fleet is moving which mess up `self.goto()`. In most situation, we use auto search to clear a map in OpSi, and classic methods are deprecated. But we still need to move fleet toward port, this method is for this situation. Raises: MapWalkError: If unable to goto such grid. Probably clicking at land, center of port, or fleet itself. """ while 1: # Calculate destination grid = self.radar.port_predict(self.device.image) logger.info(f'Port route at {grid}') if np.linalg.norm(grid) == 0: logger.info('Arrive port') break # Update local view self.update_os() self.predict() # Click way point grid = point_limit(grid, area=(-4, -2, 3, 2)) grid = self.convert_radar_to_local(grid) self.device.click(grid) # Wait until arrived self.wait_until_walk_stable()
def port_goto(self): """ A simple and poor implement to goto port. Searching port on radar. In OpSi, camera always focus to fleet when fleet is moving which mess up `self.goto()`. In most situation, we use auto search to clear a map in OpSi, and classic methods are deprecated. But we still need to move fleet toward port, this method is for this situation. Raises: MapWalkError: If unable to goto such grid. Probably clicking at land, center of port, or fleet itself. """ confirm_timer = Timer(3, count=6).start() while 1: # Calculate destination grid = self.radar.port_predict(self.device.image) logger.info(f'Port route at {grid}') radar_arrive = np.linalg.norm(grid) == 0 port_arrive = self.appear(PORT_ENTER, offset=(20, 20)) if port_arrive: logger.info('Arrive port') break elif not port_arrive and radar_arrive: if confirm_timer.reached(): logger.warning( 'Arrive port on radar but port entrance not appear') raise MapWalkError else: logger.info( 'Arrive port on radar but port entrance not appear, confirming' ) self.device.screenshot() continue else: confirm_timer.reset() # Update local view self.update_os() self.predict() # Click way point grid = point_limit(grid, area=(-4, -2, 3, 2)) grid = self.convert_radar_to_local(grid) self.device.click(grid) # Wait until arrived self.wait_until_walk_stable()