def _dorm_receive_click(self): """ Click coins and loves in dorm. Returns: int: Receive count. Pages: in: page_dorm out: page_dorm, with info_bar """ image = MASK_DORM.apply(self.device.image) loves = TEMPLATE_DORM_LOVE.match_multi(image, name='DORM_LOVE') coins = TEMPLATE_DORM_COIN.match_multi(image, name='DORM_COIN') logger.info(f'Dorm loves: {len(loves)}, Dorm coins: {len(coins)}') count = 0 for button in loves: count += 1 # Disable click record check, because may have too many coins or loves. self.device.click(button, control_check=False) self.device.sleep((0.5, 0.8)) for button in coins: count += 1 self.device.click(button, control_check=False) self.device.sleep((0.5, 0.8)) return count
def _dorm_receive_click(self): """ Click coins and loves in dorm. Returns: int: Receive count. Pages: in: page_dorm out: page_dorm, with info_bar """ image = MASK_DORM.apply(np.array(self.device.image)) love_points = Points(TEMPLATE_DORM_LOVE.match_multi(image), config=self.config).group() coin_points = Points(TEMPLATE_DORM_COIN.match_multi(image), config=self.config).group() logger.info( f'Dorm loves: {len(love_points)}, Dorm coins: {len(coin_points)}') count = 0 for point in love_points: button = tuple(np.append(point, point + TEMPLATE_DORM_LOVE.size)) button = Button(area=button, color=(), button=button, name='DORM_LOVE') count += 1 # Disable click record check, because may have too many coins or loves. self.device.click(button, record_check=False) self.device.sleep((0.5, 0.8)) for point in coin_points: button = tuple(np.append(point, point + TEMPLATE_DORM_LOVE.size)) button = Button(area=button, color=(), button=button, name='DORM_COIN') count += 1 self.device.click(button, record_check=False) self.device.sleep((0.5, 0.8)) return count