diff --git a/assets/cn/daily/DAILY_SKIP.png b/assets/cn/daily/DAILY_SKIP.png new file mode 100644 index 000000000..c2ef04e04 Binary files /dev/null and b/assets/cn/daily/DAILY_SKIP.png differ diff --git a/module/daily/assets.py b/module/daily/assets.py index c9e27d14e..5834d0263 100644 --- a/module/daily/assets.py +++ b/module/daily/assets.py @@ -15,5 +15,6 @@ DAILY_MISSION_2 = Button(area={'cn': (482, 300, 701, 415), 'en': (584, 363, 701, DAILY_MISSION_3 = Button(area={'cn': (482, 460, 701, 575), 'en': (583, 522, 701, 534), 'jp': (482, 460, 701, 575), 'tw': (482, 460, 701, 575)}, color={'cn': (75, 106, 146), 'en': (73, 101, 139), 'jp': (75, 106, 146), 'tw': (75, 106, 146)}, button={'cn': (482, 460, 701, 575), 'en': (583, 522, 701, 534), 'jp': (482, 460, 701, 575), 'tw': (482, 460, 701, 575)}, file={'cn': './assets/cn/daily/DAILY_MISSION_3.png', 'en': './assets/en/daily/DAILY_MISSION_3.png', 'jp': './assets/jp/daily/DAILY_MISSION_3.png', 'tw': './assets/tw/daily/DAILY_MISSION_3.png'}) DAILY_NEXT = Button(area={'cn': (821, 161, 996, 604), 'en': (811, 151, 1004, 612), 'jp': (821, 161, 996, 604), 'tw': (821, 161, 996, 604)}, color={'cn': (71, 48, 43), 'en': (66, 44, 39), 'jp': (71, 48, 43), 'tw': (71, 48, 43)}, button={'cn': (821, 161, 996, 604), 'en': (811, 151, 1004, 612), 'jp': (821, 161, 996, 604), 'tw': (821, 161, 996, 604)}, file={'cn': './assets/cn/daily/DAILY_NEXT.png', 'en': './assets/en/daily/DAILY_NEXT.png', 'jp': './assets/jp/daily/DAILY_NEXT.png', 'tw': './assets/tw/daily/DAILY_NEXT.png'}) DAILY_PREV = Button(area={'cn': (282, 163, 456, 600), 'en': (282, 163, 456, 600), 'jp': (282, 163, 456, 600), 'tw': (282, 163, 456, 600)}, color={'cn': (60, 73, 71), 'en': (57, 70, 69), 'jp': (60, 73, 71), 'tw': (60, 73, 71)}, button={'cn': (282, 163, 456, 600), 'en': (282, 163, 456, 600), 'jp': (282, 163, 456, 600), 'tw': (282, 163, 456, 600)}, file={'cn': './assets/cn/daily/DAILY_PREV.png', 'en': './assets/en/daily/DAILY_PREV.png', 'jp': './assets/jp/daily/DAILY_PREV.png', 'tw': './assets/tw/daily/DAILY_PREV.png'}) +DAILY_SKIP = Button(area={'cn': (1003, 295, 1102, 349), 'en': (1003, 295, 1102, 349), 'jp': (1003, 295, 1102, 349), 'tw': (1003, 295, 1102, 349)}, color={'cn': (123, 160, 209), 'en': (123, 160, 209), 'jp': (123, 160, 209), 'tw': (123, 160, 209)}, button={'cn': (1003, 295, 1102, 349), 'en': (1003, 295, 1102, 349), 'jp': (1003, 295, 1102, 349), 'tw': (1003, 295, 1102, 349)}, file={'cn': './assets/cn/daily/DAILY_SKIP.png', 'en': './assets/cn/daily/DAILY_SKIP.png', 'jp': './assets/cn/daily/DAILY_SKIP.png', 'tw': './assets/cn/daily/DAILY_SKIP.png'}) OCR_DAILY_FLEET_INDEX = Button(area={'cn': (525, 605, 561, 667), 'en': (525, 605, 561, 667), 'jp': (525, 605, 561, 667), 'tw': (525, 605, 561, 667)}, color={'cn': (60, 90, 139), 'en': (60, 90, 139), 'jp': (60, 90, 139), 'tw': (60, 90, 139)}, button={'cn': (525, 605, 561, 667), 'en': (525, 605, 561, 667), 'jp': (525, 605, 561, 667), 'tw': (525, 605, 561, 667)}, file={'cn': './assets/cn/daily/OCR_DAILY_FLEET_INDEX.png', 'en': './assets/en/daily/OCR_DAILY_FLEET_INDEX.png', 'jp': './assets/jp/daily/OCR_DAILY_FLEET_INDEX.png', 'tw': './assets/tw/daily/OCR_DAILY_FLEET_INDEX.png'}) OCR_REMAIN = Button(area={'cn': (526, 114, 546, 144), 'en': (526, 114, 546, 144), 'jp': (526, 114, 546, 144), 'tw': (526, 114, 546, 144)}, color={'cn': (94, 132, 164), 'en': (94, 132, 164), 'jp': (94, 132, 164), 'tw': (94, 132, 164)}, button={'cn': (526, 114, 546, 144), 'en': (526, 114, 546, 144), 'jp': (526, 114, 546, 144), 'tw': (526, 114, 546, 144)}, file={'cn': './assets/cn/daily/OCR_REMAIN.png', 'en': './assets/en/daily/OCR_REMAIN.png', 'jp': './assets/jp/daily/OCR_REMAIN.png', 'tw': './assets/tw/daily/OCR_REMAIN.png'}) diff --git a/module/daily/daily.py b/module/daily/daily.py index e88b9e683..260335a33 100644 --- a/module/daily/daily.py +++ b/module/daily/daily.py @@ -19,7 +19,6 @@ RECORD_SINCE = (0,) class Daily(Reward, DailyEquipment): daily_current: int daily_checked: list - daily_auto_checked = False def is_active(self): color = get_color(image=self.device.image, area=DAILY_ACTIVE.area) @@ -49,6 +48,12 @@ class Daily(Reward, DailyEquipment): self._wait_daily_switch() self.device.screenshot() + def handle_daily_additional(self): + if self.handle_guild_popup_cancel(): + self.config.GUILD_POPUP_TRIGGERED = True + return True + return False + def daily_execute(self, remain, fleet): """ Args: @@ -57,6 +62,10 @@ class Daily(Reward, DailyEquipment): Returns: bool: True if success, False if daily locked. + + Pages: + in: page_daily + out: page_daily """ logger.hr(f'Daily {self.daily_current}') logger.attr('Fleet', fleet) @@ -69,13 +78,8 @@ class Daily(Reward, DailyEquipment): self.device.click(BACK_ARROW) return self.appear(DAILY_ENTER_CHECK) or self.appear(BACK_ARROW) - def daily_additional(): - if self.handle_guild_popup_cancel(): - self.config.GUILD_POPUP_TRIGGERED = True - return True - return False - - self.ui_click(click_button=DAILY_ENTER, check_button=daily_enter_check, appear_button=DAILY_CHECK) + self.ui_click(click_button=DAILY_ENTER, check_button=daily_enter_check, appear_button=DAILY_CHECK, + skip_first_screenshot=True) if self.appear(DAILY_LOCKED): logger.info('Daily locked') self.ui_click(click_button=BACK_ARROW, check_button=DAILY_CHECK) @@ -85,17 +89,62 @@ class Daily(Reward, DailyEquipment): button = DAILY_MISSION_LIST[self.config.DAILY_CHOOSE[self.daily_current] - 1] for n in range(remain): logger.hr(f'Count {n + 1}') - self.ui_click(click_button=button, check_button=self.combat_appear, appear_button=daily_enter_check, - additional=self.handle_combat_automation_confirm if not self.daily_auto_checked else daily_additional) - self.daily_auto_checked = True + result = self.daily_enter(button) + if not result: + break self.ui_ensure_index(fleet, letter=OCR_DAILY_FLEET_INDEX, prev_button=DAILY_FLEET_PREV, next_button=DAILY_FLEET_NEXT, fast=False, skip_first_screenshot=True) self.combat(emotion_reduce=False, save_get_items=False, expected_end=daily_end, balance_hp=False) - self.ui_click(click_button=BACK_ARROW, check_button=DAILY_CHECK, additional=daily_additional) + self.ui_click(click_button=BACK_ARROW, check_button=DAILY_CHECK, additional=self.handle_daily_additional, + skip_first_screenshot=True) self.device.sleep((1, 1.2)) return True + def daily_enter(self, button, skip_first_screenshot=True): + """ + Args: + button (Button): Daily entrance + skip_first_screenshot (bool): + + Returns: + bool: True if combat appear. False if daily skip unlocked, skipped daily, received rewards. + + Pages: + in: DAILY_ENTER_CHECK + out: DAILY_ENTER_CHECK or combat_appear + """ + reward_received = False + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + + if self.appear(DAILY_ENTER_CHECK, interval=5): + self.device.click(button) + continue + if self.handle_get_items(save_get_items=False): + reward_received = True + continue + if self.appear_then_click(DAILY_SKIP, offset=(20, 20), interval=5): + continue + if self.handle_combat_automation_confirm(): + continue + if self.handle_daily_additional(): + continue + if self.handle_popup_confirm('DAILY_SKIP'): + continue + + # End + if self.appear(DAILY_SKIP, offset=(20, 20)): + if reward_received: + return False + if self.info_bar_count(): + return False + if self.combat_appear(): + return True + def daily_check(self, n=None): if not n: n = self.daily_current