Exemplo n.º 1
0
 def click_record_check(self):
     """
     Raises:
         GameTooManyClickError:
     """
     count = {}
     for key in self.click_record:
         count[key] = count.get(key, 0) + 1
     count = sorted(count.items(), key=lambda item: item[1])
     if count[0][1] >= 12:
         logger.warning(f'Too many click for a button: {count[0][0]}')
         logger.warning(
             f'History click: {[str(prev) for prev in self.click_record]}')
         self.click_record_clear()
         raise GameTooManyClickError(
             f'Too many click for a button: {count[0][0]}')
     if len(count) >= 2 and count[0][1] >= 6 and count[1][1] >= 6:
         logger.warning(
             f'Too many click between 2 buttons: {count[0][0]}, {count[1][0]}'
         )
         logger.warning(
             f'History click: {[str(prev) for prev in self.click_record]}')
         self.click_record_clear()
         raise GameTooManyClickError(
             f'Too many click between 2 buttons: {count[0][0]}, {count[1][0]}'
         )
Exemplo n.º 2
0
    def click_record_check(self, button):
        """
        Args:
            button (button.Button): AzurLane Button instance.

        Returns:
            bool:

        Raises:
            GameTooManyClickError:
        """
        self.click_record.append(str(button))

        count = {}
        for key in self.click_record:
            count[key] = count.get(key, 0) + 1
        count = sorted(count.items(), key=lambda item: item[1])
        if count[0][1] >= 12:
            logger.warning(f'Too many click for a button: {count[0][0]}')
            logger.warning(f'History click: {[str(prev) for prev in self.click_record]}')
            self.click_record_clear()
            raise GameTooManyClickError(f'Too many click for a button: {count[0][0]}')
        if len(count) >= 2 and count[0][1] >= 6 and count[1][1] >= 6:
            logger.warning(f'Too many click between 2 buttons: {count[0][0]}, {count[1][0]}')
            logger.warning(f'History click: {[str(prev) for prev in self.click_record]}')
            self.click_record_clear()
            raise GameTooManyClickError(f'Too many click between 2 buttons: {count[0][0]}, {count[1][0]}')

        return False
Exemplo n.º 3
0
    def os_map_goto_globe(self, unpin=True, skip_first_screenshot=True):
        """
        Args:
            unpin (bool):
            skip_first_screenshot (bool):

        Pages:
            in: is_in_map
            out: is_in_globe
        """
        click_count = 0
        while 1:
            if skip_first_screenshot:
                skip_first_screenshot = False
            else:
                self.device.screenshot()

            if self.appear_then_click(MAP_GOTO_GLOBE,
                                      offset=(200, 5),
                                      interval=5):
                click_count += 1
                if click_count >= 5:
                    # When there's zone exploration reward, AL just don't let you go.
                    logger.warning(
                        'Unable to goto globe, '
                        'there might be uncollected zone exploration rewards preventing exit'
                    )
                    raise GameTooManyClickError(
                        f'Too many click for a button: {MAP_GOTO_GLOBE}')
                continue
            if self.handle_map_event():
                continue
            # Popup: Leaving current zone will terminate meowfficer searching.
            # Searching reward will be shown after entering another zone.
            if self.handle_popup_confirm('GOTO_GLOBE'):
                continue

            # End
            if self.is_in_globe():
                break

        skip_first_screenshot = True
        confirm_timer = Timer(1, count=2).start()
        unpinned = 0
        while 1:
            if skip_first_screenshot:
                skip_first_screenshot = False
            else:
                self.device.screenshot()

            if unpin:
                if self.handle_zone_pinned():
                    unpinned += 1
                    confirm_timer.reset()
                else:
                    if unpinned and confirm_timer.reached():
                        break
            else:
                if self.is_zone_pinned():
                    break
Exemplo n.º 4
0
    def click_record_check(self, button):
        """
        Args:
            button (button.Button): AzurLane Button instance.

        Returns:
            bool:
        """
        if sum([
                1 if str(prev) == str(button) else 0
                for prev in self.click_record
        ]) >= 12:
            logger.warning(f'Too many click for a button: {button}')
            logger.info(
                f'History click: {[str(prev) for prev in self.click_record]}')
            raise GameTooManyClickError(
                f'Too many click for a button: {button}')
        else:
            self.click_record.append(str(button))

        return False