コード例 #1
0
    def _tactical_get_finish(self):
        """
        Get the future finish time.
        """
        logger.hr('Tactical get finish')
        grids = ButtonGrid(origin=(421, 596),
                           delta=(223, 0),
                           button_shape=(139, 27),
                           grid_shape=(4, 1),
                           name='TACTICAL_REMAIN')
        is_running = [
            self.image_color_count(button, color=(148, 255, 99), count=50)
            for button in grids.buttons
        ]
        logger.info(
            f'Tactical status: {["running" if s else "empty" for s in is_running]}'
        )

        buttons = [b for b, s in zip(grids.buttons, is_running) if s]
        ocr = Duration(buttons, letter=(148, 255, 99), name='TACTICAL_REMAIN')
        remains = ocr.ocr(self.device.image)
        remains = [remains] if not isinstance(remains, list) else remains

        now = datetime.now()
        self.tactical_finish = [(now + remain).replace(microsecond=0)
                                for remain in remains
                                if remain.total_seconds()]
        logger.info(
            f'Tactical finish: {[str(f) for f in self.tactical_finish]}')
コード例 #2
0
    def _tactical_get_finish(self):
        """
        Get the future finish time.
        """
        logger.hr('Tactical get finish')
        grids = ButtonGrid(origin=(421, 596),
                           delta=(223, 0),
                           button_shape=(139, 27),
                           grid_shape=(4, 1),
                           name='TACTICAL_REMAIN')

        # tactical cards can't be loaded that fast, confirm if it's empty.
        confirm_timer = Timer(0.6, count=2).start()
        while 1:
            is_running = [
                self.image_color_count(button, color=(148, 255, 99), count=50)
                for button in grids.buttons
            ]
            logger.info(
                f'Tactical status: {["running" if s else "empty" for s in is_running]}'
            )
            if any(is_running):
                break
            if confirm_timer.reached():
                break
            self.device.screenshot()

        buttons = [b for b, s in zip(grids.buttons, is_running) if s]
        ocr = Duration(buttons, letter=(148, 255, 99), name='TACTICAL_REMAIN')
        remains = ocr.ocr(self.device.image)
        remains = [remains] if not isinstance(remains, list) else remains

        now = datetime.now()
        self.tactical_finish = [(now + remain).replace(microsecond=0)
                                for remain in remains
                                if remain.total_seconds()]
        logger.info(
            f'Tactical finish: {[str(f) for f in self.tactical_finish]}')