diff --git a/assets/cn/reward/COMMISSION_SCROLL.png b/assets/cn/reward/COMMISSION_SCROLL.png new file mode 100644 index 000000000..27d5d9294 Binary files /dev/null and b/assets/cn/reward/COMMISSION_SCROLL.png differ diff --git a/assets/cn/reward/COMMISSION_SCROLL_TOP.png b/assets/cn/reward/COMMISSION_SCROLL_TOP.png new file mode 100644 index 000000000..f31cb4b8a Binary files /dev/null and b/assets/cn/reward/COMMISSION_SCROLL_TOP.png differ diff --git a/assets/en/reward/COMMISSION_SCROLL.png b/assets/en/reward/COMMISSION_SCROLL.png new file mode 100644 index 000000000..27d5d9294 Binary files /dev/null and b/assets/en/reward/COMMISSION_SCROLL.png differ diff --git a/assets/en/reward/COMMISSION_SCROLL_TOP.png b/assets/en/reward/COMMISSION_SCROLL_TOP.png new file mode 100644 index 000000000..f31cb4b8a Binary files /dev/null and b/assets/en/reward/COMMISSION_SCROLL_TOP.png differ diff --git a/module/reward/assets.py b/module/reward/assets.py index 1e6b9b4ad..da8da9b14 100644 --- a/module/reward/assets.py +++ b/module/reward/assets.py @@ -9,6 +9,8 @@ COMMISSION_ADVICE = Button(area={'cn': (871, 322, 999, 383), 'en': (871, 328, 10 COMMISSION_DAILY = Button(area={'cn': (35, 132, 67, 186), 'en': (30, 126, 75, 188)}, color={'cn': (208, 172, 118), 'en': (170, 132, 92)}, button={'cn': (35, 132, 67, 186), 'en': (30, 126, 75, 188)}, file={'cn': './assets/cn/reward/COMMISSION_DAILY.png', 'en': './assets/en/reward/COMMISSION_DAILY.png'}) COMMISSION_HAS_PENDING = Button(area={'cn': (357, 300, 359, 330), 'en': (357, 300, 359, 330)}, color={'cn': (86, 201, 173), 'en': (81, 205, 174)}, button={'cn': (357, 300, 359, 330), 'en': (357, 300, 359, 330)}, file={'cn': './assets/cn/reward/COMMISSION_HAS_PENDING.png', 'en': './assets/en/reward/COMMISSION_HAS_PENDING.png'}) COMMISSION_NOTICE_AT_CAMPAIGN = Button(area={'cn': (1054, 647, 1061, 654), 'en': (1054, 647, 1061, 654)}, color={'cn': (197, 89, 64), 'en': (197, 89, 64)}, button={'cn': (1054, 647, 1061, 654), 'en': (1054, 647, 1061, 654)}, file={'cn': './assets/cn/reward/COMMISSION_NOTICE_AT_CAMPAIGN.png', 'en': './assets/en/reward/COMMISSION_NOTICE_AT_CAMPAIGN.png'}) +COMMISSION_SCROLL = Button(area={'cn': (1255, 0, 1260, 720), 'en': (1255, 0, 1260, 720)}, color={'cn': (111, 104, 69), 'en': (111, 104, 69)}, button={'cn': (1255, 0, 1260, 720), 'en': (1255, 0, 1260, 720)}, file={'cn': './assets/cn/reward/COMMISSION_SCROLL.png', 'en': './assets/en/reward/COMMISSION_SCROLL.png'}) +COMMISSION_SCROLL_TOP = Button(area={'cn': (1254, 81, 1261, 88), 'en': (1254, 81, 1261, 88)}, color={'cn': (247, 209, 66), 'en': (247, 209, 66)}, button={'cn': (1254, 81, 1261, 88), 'en': (1254, 81, 1261, 88)}, file={'cn': './assets/cn/reward/COMMISSION_SCROLL_TOP.png', 'en': './assets/en/reward/COMMISSION_SCROLL_TOP.png'}) COMMISSION_START = Button(area={'cn': (1028, 322, 1156, 383), 'en': (1031, 333, 1147, 383)}, color={'cn': (229, 175, 113), 'en': (227, 169, 108)}, button={'cn': (1028, 322, 1156, 383), 'en': (1031, 333, 1147, 383)}, file={'cn': './assets/cn/reward/COMMISSION_START.png', 'en': './assets/en/reward/COMMISSION_START.png'}) COMMISSION_STOP_SCROLLING = Button(area={'cn': (115, 236, 179, 487), 'en': (115, 236, 179, 487)}, color={'cn': (50, 55, 74), 'en': (50, 55, 74)}, button={'cn': (115, 236, 179, 487), 'en': (115, 236, 179, 487)}, file={'cn': './assets/cn/reward/COMMISSION_STOP_SCROLLING.png', 'en': './assets/en/reward/COMMISSION_STOP_SCROLLING.png'}) COMMISSION_URGENT = Button(area={'cn': (35, 231, 68, 281), 'en': (28, 221, 76, 283)}, color={'cn': (215, 188, 124), 'en': (169, 138, 95)}, button={'cn': (35, 231, 68, 281), 'en': (28, 221, 76, 283)}, file={'cn': './assets/cn/reward/COMMISSION_URGENT.png', 'en': './assets/en/reward/COMMISSION_URGENT.png'}) diff --git a/module/reward/commission.py b/module/reward/commission.py index 50a494918..456d2760a 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -9,6 +9,7 @@ from module.base.decorator import Config from module.base.ocr import Ocr from module.base.timer import Timer from module.base.utils import area_offset, get_color, random_rectangle_vector +from module.base.utils import color_similar_1d, random_rectangle_point from module.handler.info_handler import InfoHandler from module.logger import logger from module.reward.assets import * @@ -413,6 +414,26 @@ class RewardCommission(UI, InfoHandler): self.device.sleep(0.3) self.device.screenshot() + def _commission_swipe_to_top(self, bar_padding_y=10): + if self.appear(COMMISSION_SCROLL_TOP): + # Already at top + return False + + mean = np.mean(self.device.image.crop(COMMISSION_SCROLL.area), axis=1) + bar = np.where(color_similar_1d(mean, color=(247, 211, 66)))[0] + if len(bar) < bar_padding_y * 2: + # No scroll found. + return False + + bar = (COMMISSION_SCROLL.area[0], np.min(bar) + bar_padding_y, + COMMISSION_SCROLL.area[2], np.max(bar) - bar_padding_y) + p1 = random_rectangle_point(bar) + p2 = random_rectangle_point(COMMISSION_SCROLL_TOP.area) + self.device.drag(p1, p2, shake=(15, 0), point_random=(0, 0, 0, 0)) + self.device.sleep(0.3) + self.device.screenshot() + return True + def _commission_scan_list(self): commission = CommissionGroup(self.config) commission.merge(self.device.image) @@ -432,10 +453,12 @@ class RewardCommission(UI, InfoHandler): def _commission_scan_all(self): logger.hr('Scan daily') self._commission_ensure_mode('daily') + self._commission_swipe_to_top() daily = self._commission_scan_list() logger.hr('Scan urgent') self._commission_ensure_mode('urgent') + self._commission_swipe_to_top() urgent = self._commission_scan_list() logger.hr('Showing commission') @@ -529,11 +552,13 @@ class RewardCommission(UI, InfoHandler): for comm in self.daily_choose: if not self._commission_ensure_mode('daily'): self._commission_mode_reset() + self._commission_swipe_to_top() self._commission_find_and_start(comm) if self.urgent_choose: for comm in self.urgent_choose: if not self._commission_ensure_mode('urgent'): self._commission_mode_reset() + self._commission_swipe_to_top() self._commission_find_and_start(comm) if not self.daily_choose and not self.urgent_choose: logger.info('No commission chose')