コード例 #1
0
ファイル: sos.py プロジェクト: chenkid999/AzurLaneAutoScript
    def _find_target_chapter(self, chapter):
        """
        find the target chapter search button or goto button.

        Args:
            chapter (int): SOS target chapter

        Returns:
            Button: signal search button or goto button of the target chapter
        """
        signal_search_buttons = TEMPLATE_SIGNAL_SEARCH.match_multi(self.device.image)
        sos_goto_buttons = TEMPLATE_SIGNAL_GOTO.match_multi(self.device.image)
        all_buttons = sos_goto_buttons + signal_search_buttons
        if not len(all_buttons):
            logger.info('No SOS chapter found')
            return None

        chapter_buttons = [button.crop(self._sos_chapter_crop) for button in all_buttons]
        ocr_chapters = Digit(chapter_buttons, letter=[132, 230, 115], threshold=136, name='OCR_SOS_CHAPTER')
        chapter_list = ocr_chapters.ocr(self.device.image)
        if not isinstance(chapter_list, list):
            chapter_list = [chapter_list]
        if chapter in chapter_list:
            logger.info('Target SOS chapter found')
            return all_buttons[chapter_list.index(chapter)]
        else:
            logger.info('Target SOS chapter not found')
            return None
コード例 #2
0
    def get_common_rarity_dd(self):
        """
        Get a common rarity dd with level is 100 and highest emotion
        Returns:
            Button:
        """
        logger.hr('FINDING VANGUARD')

        level_grids = CARD_LEVEL_GRIDS
        card_grids = CARD_GRIDS
        emotion_grids = CARD_EMOTION_GRIDS

        level_ocr = LevelOcr(level_grids.buttons,
                             name='DOCK_LEVEL_OCR',
                             threshold=64)
        list_level = level_ocr.ocr(self.device.image)
        emotion_ocr = Digit(emotion_grids.buttons,
                            name='DOCK_EMOTION_OCR',
                            threshold=176)
        list_emotion = emotion_ocr.ocr(self.device.image)

        button_list = list(zip(card_grids.buttons, list_level,
                               list_emotion))[::-1]

        # for :
        #     if level == 100 and emotion == 150:
        #         return button
        button, _, _ = max(filter(lambda a: a[1] == 100, button_list),
                           key=lambda a: a[2])
        return button
コード例 #3
0
    def get_power(self, image):
        grids = ButtonGrid(origin=(222, 257),
                           delta=(244, 30),
                           button_shape=(72, 28),
                           grid_shape=(4, 2),
                           name='POWER')
        power = [grids[self.index, 0], grids[self.index, 1]]

        power = Digit(power,
                      name='POWER',
                      letter=(255, 223, 57),
                      threshold=128)
        result = power.ocr(image)
        return result
コード例 #4
0
    def get_power(self, image):
        """
        Args:
            image: Screenshot in page_exercise.

        Returns:
            list[int]: Fleet power, such as [14848, 13477].
        """
        grids = ButtonGrid(origin=(222, 257),
                           delta=(244, 30),
                           button_shape=(72, 28),
                           grid_shape=(4, 2),
                           name='POWER')
        power = [grids[self.index, 0], grids[self.index, 1]]

        power = Digit(power,
                      name='POWER',
                      letter=(255, 223, 57),
                      threshold=128)
        result = power.ocr(image)
        return result