def local_to_area(local_grid, pad=0):
     result = []
     for local in local_grid:
         # Predict the position of grid after swipe.
         # Swipe should ends there, to prevent treating swipe as click.
         area = area_offset((0, 0, 1, 1), offset=-map_vector)
         corner = local.grid2screen(area2corner(area))
         area = trapezoid2area(corner, pad=pad)
         result.append(area)
     return result
Example #2
0
    def get_boss_leave_button(self):
        for grid in self.view:
            if grid.predict_current_fleet():
                return None

        grids = [grid for grid in self.view if grid.predict_caught_by_siren()]
        if len(grids) == 1:
            center = grids[0]
        elif len(grids) > 1:
            logger.warning(
                f'Found multiple fleets in boss ({grids}), use the center one')
            center = SelectedGrids(grids).sort_by_camera_distance(
                self.view.center_loca)[0]
        else:
            logger.warning('No fleet in boss, use camera center instead')
            center = self.view[self.view.center_loca]

        logger.info(f'Fleet in boss: {center}')
        # The left half grid next to the center grid.
        area = corner2inner(
            center.grid2screen(area2corner((1, 0.25, 1.5, 0.75))))
        button = Button(area=area, color=(), button=area, name='BOSS_LEAVE')
        return button