diff --git a/config/template.json b/config/template.json index d06f58ed9..3e30dbe85 100644 --- a/config/template.json +++ b/config/template.json @@ -99,6 +99,7 @@ "SaveFolder": "./screenshots", "AzurStatsID": null, "API": "default", + "DailyRecord": "do_not", "ResearchRecord": "do_not", "CommissionRecord": "do_not", "CombatRecord": "do_not", diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 3652d8d7d..c3e1ee446 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -454,6 +454,14 @@ "cn_gz_reverse_proxy" ] }, + "DailyRecord": { + "type": "select", + "value": "do_not", + "option": [ + "do_not", + "save" + ] + }, "ResearchRecord": { "type": "select", "value": "do_not", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 548cbee67..f407d8603 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -103,6 +103,9 @@ DropRecord: API: value: default option: [ default, cn_gz_reverse_proxy] + DailyRecord: + value: do_not + option: [ do_not, save ] ResearchRecord: value: do_not option: [ do_not, save, upload, save_and_upload ] diff --git a/module/config/config_generated.py b/module/config/config_generated.py index a4057058c..9ecddf146 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -48,6 +48,7 @@ class GeneratedConfig: DropRecord_SaveFolder = './screenshots' DropRecord_AzurStatsID = None DropRecord_API = 'default' # default, cn_gz_reverse_proxy + DropRecord_DailyRecord = 'do_not' # do_not, save DropRecord_ResearchRecord = 'do_not' # do_not, save, upload, save_and_upload DropRecord_CommissionRecord = 'do_not' # do_not, save, upload, save_and_upload DropRecord_CombatRecord = 'do_not' # do_not, save diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 4782f770a..63233880e 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -567,6 +567,12 @@ "default": "Default (Cloudflare)", "cn_gz_reverse_proxy": "Reverse proxy (Guangzhou, South China)" }, + "DailyRecord": { + "name": "Daily Record", + "help": "", + "do_not": "Do nothing", + "save": "Save" + }, "ResearchRecord": { "name": "Research Record", "help": "", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 76004a220..841bd611f 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -567,6 +567,12 @@ "default": "default", "cn_gz_reverse_proxy": "cn_gz_reverse_proxy" }, + "DailyRecord": { + "name": "DropRecord.DailyRecord.name", + "help": "DropRecord.DailyRecord.help", + "do_not": "do_not", + "save": "save" + }, "ResearchRecord": { "name": "DropRecord.ResearchRecord.name", "help": "DropRecord.ResearchRecord.help", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index e6b36e0a0..dd79a1a79 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -583,6 +583,12 @@ "upload": "上传", "save_and_upload": "保存并上传" }, + "DailyRecord": { + "name": "每日挑战截图", + "help": "", + "do_not": "无操作", + "save": "保存" + }, "CombatRecord": { "name": "战斗掉落截图", "help": "启用后会放缓结算时的点击速度\n在自律寻敌下不生效", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 3539f6377..6ac3aacdf 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -567,6 +567,12 @@ "default": "默認 (Cloudflare)", "cn_gz_reverse_proxy": "國內反向代理 (廣州)" }, + "DailyRecord": { + "name": "每日任務截圖", + "help": "", + "do_not": "無操作", + "save": "保存" + }, "ResearchRecord": { "name": "科研截圖", "help": "", diff --git a/module/daily/daily.py b/module/daily/daily.py index 6d8f3c03d..4c6fa68c9 100644 --- a/module/daily/daily.py +++ b/module/daily/daily.py @@ -153,12 +153,13 @@ class Daily(Combat, DailyEquipment): else: return 4 - def daily_execute(self, remain=3, stage=1, fleet=1): + def daily_execute(self, remain=3, stage=1, fleet=1, drop=None): """ Args: remain (int): Remain daily challenge count. stage (int): Index of stage counted from top, 1 to 3. fleet (int): Index of fleet to use. + drop (DropImage): Returns: bool: True if success, False if daily locked. @@ -189,7 +190,7 @@ class Daily(Combat, DailyEquipment): button = DAILY_MISSION_LIST[stage - 1] for n in range(remain): logger.hr(f'Count {n + 1}') - result = self.daily_enter(button) + result = self.daily_enter(button, drop=drop) if not result: break if self.daily_current == self.supply_line_disruption_index: @@ -199,18 +200,19 @@ class Daily(Combat, DailyEquipment): # Execute classic daily run 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.combat(emotion_reduce=False, save_get_items=drop, expected_end=daily_end, balance_hp=False) 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): + def daily_enter(self, button, skip_first_screenshot=True, drop=None): """ Args: button (Button): Daily entrance skip_first_screenshot (bool): + drop (DropImage): Returns: bool: True if combat appear. False if daily skip unlocked, skipped daily, received rewards. @@ -229,7 +231,7 @@ class Daily(Combat, DailyEquipment): if self.appear(DAILY_ENTER_CHECK, threshold=30, interval=5): self.device.click(button) continue - if self.handle_get_items(): + if self.handle_get_items(drop=drop): reward_received = True continue if self.config.Daily_UseDailySkip: @@ -280,43 +282,49 @@ class Daily(Combat, DailyEquipment): while 1: if self.daily_current > 7: break - if self.daily_current == self.empty_index: - logger.info('This daily is not open now') - self.daily_check() - self.next() - continue - stage, fleet = self.get_daily_stage_and_fleet() - if self.daily_current == self.supply_line_disruption_index and not self.config.Daily_UseDailySkip: - logger.info('Skip supply line disruption if UseDailySkip disabled') - self.daily_check() - self.next() - continue - if not stage: - logger.info(f'No stage set on daily_current: {self.daily_current}, skip') - self.daily_check() - self.next() - continue - if self.daily_current != self.supply_line_disruption_index and not fleet: - logger.info(f'No fleet set on daily_current: {self.daily_current}, skip') - self.daily_check() - self.next() - continue - if not self.is_active(): - self.daily_check() - self.next() - continue - remain = OCR_REMAIN.ocr(self.device.image) - if remain == 0: - self.daily_check() - self.next() - continue - else: - self.daily_execute(remain=remain, stage=stage, fleet=fleet) - self.daily_check() - # The order of daily tasks will be disordered after execute a daily, exit and re-enter to reset. - # 打完一次之后每日任务的顺序会乱掉, 退出再进入来重置顺序. - self.ui_goto(page_campaign_menu) - break + with self.stat.new( + genre='daily', + method=self.config.DropRecord_DailyRecord, + info=f'daily_{self.daily_current}' + ) as drop: + drop.add(self.device.image) + if self.daily_current == self.empty_index: + logger.info('This daily is not open now') + self.daily_check() + self.next() + continue + stage, fleet = self.get_daily_stage_and_fleet() + if self.daily_current == self.supply_line_disruption_index and not self.config.Daily_UseDailySkip: + logger.info('Skip supply line disruption if UseDailySkip disabled') + self.daily_check() + self.next() + continue + if not stage: + logger.info(f'No stage set on daily_current: {self.daily_current}, skip') + self.daily_check() + self.next() + continue + if self.daily_current != self.supply_line_disruption_index and not fleet: + logger.info(f'No fleet set on daily_current: {self.daily_current}, skip') + self.daily_check() + self.next() + continue + if not self.is_active(): + self.daily_check() + self.next() + continue + remain = OCR_REMAIN.ocr(self.device.image) + if remain == 0: + self.daily_check() + self.next() + continue + else: + self.daily_execute(remain=remain, stage=stage, fleet=fleet, drop=drop) + self.daily_check() + # The order of daily tasks will be disordered after execute a daily, exit and re-enter to reset. + # 打完一次之后每日任务的顺序会乱掉, 退出再进入来重置顺序. + self.ui_goto(page_campaign_menu) + break def daily_run(self): self.daily_checked = [0]