Exemplo n.º 1
0
    def commission_parse(self):
        # Name
        # This is different from CN, EN has longer names
        area = area_offset((176, 23, 420, 51), self.area[0:2])
        button = Button(area=area, color=(), button=area, name='COMMISSION')
        ocr = Ocr(button, lang='cnocr', back=(74, 97, 148), use_binary=False)
        self.button = button
        self.name = ocr.ocr(self.image)
        self.genre = self.commission_name_parse(self.name)

        # Duration time
        area = area_offset((290, 74, 390, 92), self.area[0:2])
        button = Button(area=area, color=(), button=area, name='DURATION')
        ocr = Ocr(button, lang='stage', back=(57, 85, 132))
        self.duration = self.parse_time(ocr.ocr(self.image))

        # Expire time
        area = area_offset((-49, 68, -45, 84), self.area[0:2])
        button = Button(area=area,
                        color=(189, 65, 66),
                        button=area,
                        name='IS_URGENT')
        if button.appear_on(self.image):
            area = area_offset((-49, 73, 45, 91), self.area[0:2])
            button = Button(area=area, color=(), button=area, name='EXPIRE')
            ocr = Ocr(button, lang='stage', back=(189, 65, 66))
            self.expire = self.parse_time(ocr.ocr(self.image))
        else:
            self.expire = None

        # Status
        area = area_offset((179, 71, 187, 93), self.area[0:2])
        dic = {0: 'finished', 1: 'running', 2: 'pending'}
        self.status = dic[int(np.argmax(get_color(self.image, area)))]
Exemplo n.º 2
0
    def commission_parse(self):
        # Name
        area = area_offset((176, 23, 420, 53), self.area[0:2])
        button = Button(area=area, color=(), button=area, name='COMMISSION')
        ocr = Ocr(button, lang='cnocr', threshold=256)
        self.button = button
        self.name = ocr.ocr(self.image)
        self.genre = self.commission_name_parse(self.name)

        # Duration time
        area = area_offset((290, 68, 390, 95), self.area[0:2])
        button = Button(area=area, color=(), button=area, name='DURATION')
        ocr = Ocr(button, alphabet='0123456789:')
        self.duration = self.parse_time(ocr.ocr(self.image))

        # Expire time
        area = area_offset((-49, 68, -45, 84), self.area[0:2])
        button = Button(area=area,
                        color=(189, 65, 66),
                        button=area,
                        name='IS_URGENT')
        if button.appear_on(self.image):
            area = area_offset((-49, 67, 45, 94), self.area[0:2])
            button = Button(area=area, color=(), button=area, name='EXPIRE')
            ocr = Ocr(button, alphabet='0123456789:')
            self.expire = self.parse_time(ocr.ocr(self.image))
        else:
            self.expire = None

        # Status
        area = area_offset((179, 71, 187, 93), self.area[0:2])
        dic = {0: 'finished', 1: 'running', 2: 'pending'}
        self.status = dic[int(np.argmax(get_color(self.image, area)))]
Exemplo n.º 3
0
 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
    def get_button(self, index):
        """
        Args:
            index(int): Fleet index, 1-6.

        Returns:
            Button: Button instance.
        """
        area = area_offset(area=(
            0,
            (self.FLEET_BAR_SHAPE_Y + self.FLEET_BAR_MARGIN_Y) * (index - 1),
            self._bar.area[2] - self._bar.area[0],
            (self.FLEET_BAR_SHAPE_Y + self.FLEET_BAR_MARGIN_Y) * (index - 1) + self.FLEET_BAR_SHAPE_Y
        ), offset=(self._bar.area[0:2]))
        return Button(area=(), color=(), button=area, name='%s_INDEX_%s' % (str(self._bar), str(index)))
Exemplo n.º 5
0
 def guild_lobby_get_report(self):
     """
     Returns:
         Button: Button to enter guild report.
     """
     # Find red color in the area of GUILD_REPORT_AVAILABLE
     image = color_similarity_2d(self.image_crop(GUILD_REPORT_AVAILABLE), color=(255, 8, 8))
     points = np.array(np.where(image > 221)).T[:, ::-1]
     if len(points):
         # The center of red dot
         points = Points(points).group(threshold=40) + GUILD_REPORT_AVAILABLE.area[:2]
         # Shift to the center of report icon
         area = area_offset((-51, -45, -13, 0), offset=points[0])
         return Button(area=area, color=(255, 255, 255), button=area, name='GUILD_REPORT')
     else:
         return None
    def _get_archives_entrance(self, name):
        """
        Create entrance button to target archive campaign
        using a template acquired by event folder name

        Args:
            name(str): event folder name
        """
        template = dic_archives_template[name]

        sim, point = template.match_result(self.device.image)
        if sim < 0.85:
            return None

        button = area_offset(area=(-12, -12, 44, 32), offset=point)
        color = get_color(self.device.image, button)
        entrance = Button(area=button, color=color, button=button, name=name)
        return entrance
Exemplo n.º 7
0
    def _tactical_animation_running(self):
        """
        Returns:
            bool: If showing skill points increasing animation.
        """
        color_height = np.mean(self.device.image.crop((922, 0, 1036, 720)).convert('L'), axis=1)
        parameters = {'height': 200}
        peaks, _ = signal.find_peaks(color_height, **parameters)
        peaks = [y for y in peaks if y > 67 + 243]

        if not len(peaks):
            logger.warning('No student card found.')
        for y in peaks:
            student_area = (447, y - 243, 1244, y)
            area = area_offset((677, 172, 761, 183), student_area[0:2])
            # Normal: 160, In skill-increasing animation: 109
            if np.mean(get_color(self.device.image, area)) < 135:
                return True

        return False
Exemplo n.º 8
0
    def campaign_match_multi(self,
                             template,
                             image,
                             name_offset=(75, 9),
                             name_size=(60, 16),
                             name_letter=(255, 255, 255),
                             name_thresh=128):
        """
        Args:
            template (Template):
            image: Screenshot
            name_offset (tuple[int]):
            name_size (tuple[int]):
            name_letter (tuple[int]):
            name_thresh (int):

        Returns:
            list[Button]: Stage clear buttons.
        """
        digits = []
        color = tuple(np.mean(np.mean(template.image, axis=0), axis=0))
        result = template.match_multi(image, similarity=0.95)

        for point in result:
            point = point[::-1]
            button = tuple(
                np.append(point, point + template.image.shape[:2][::-1]))
            point = point + name_offset
            name = image.crop(np.append(point, point + name_size))
            name = extract_letters(name,
                                   letter=name_letter,
                                   threshold=name_thresh)
            stage = self._extract_stage_name(name)
            digits.append(
                Button(area=area_offset(stage, point),
                       color=color,
                       button=button,
                       name='stage'))

        return digits
Exemplo n.º 9
0
    def _get_archives_entrance(self, name):
        """
        Create entrance button to target archive campaign
        using a template acquired by event folder name

        TODO: Each server have different selectable campaign
              Need something similar to commission to scroll
              or turn page. CN/JP have more than 4 atm.

        Args:
            name(str): event folder name
        """
        template = dic_archives_template[name]

        sim, point = template.match_result(self.device.image)
        if sim < 0.85:
            raise CampaignNameError

        button = area_offset(area=(-12, -12, 44, 32), offset=point)
        color = get_color(self.device.image, button)
        entrance = Button(area=button, color=color, button=button, name=name)
        return entrance