diff --git a/config/template.json b/config/template.json index 6a52a4fd8..b2d6c3aa4 100644 --- a/config/template.json +++ b/config/template.json @@ -37,11 +37,19 @@ "Enable": false, "NextRun": "2020-01-01 00:00:00", "Command": "Dungeon", - "ServerUpdate": "00:00" + "ServerUpdate": "04:00" }, "Dungeon": { "Name": "Calyx_Golden_Memories", "Team": 1 } + }, + "DailyQuest": { + "Scheduler": { + "Enable": false, + "NextRun": "2020-01-01 00:00:00", + "Command": "DailyQuest", + "ServerUpdate": "04:00" + } } } \ No newline at end of file diff --git a/module/config/argument/args.json b/module/config/argument/args.json index d5cfb781b..6df0c12bc 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -163,7 +163,7 @@ }, "ServerUpdate": { "type": "input", - "value": "00:00", + "value": "04:00", "display": "hide" } }, @@ -212,5 +212,28 @@ ] } } + }, + "DailyQuest": { + "Scheduler": { + "Enable": { + "type": "checkbox", + "value": false + }, + "NextRun": { + "type": "datetime", + "value": "2020-01-01 00:00:00", + "validate": "datetime" + }, + "Command": { + "type": "input", + "value": "DailyQuest", + "display": "hide" + }, + "ServerUpdate": { + "type": "input", + "value": "04:00", + "display": "hide" + } + } } } \ No newline at end of file diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 77c077a35..e1a940f3b 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -9,7 +9,7 @@ Scheduler: NextRun: 2020-01-01 00:00:00 Command: Alas ServerUpdate: - value: 00:00 + value: 04:00 display: hide Emulator: Serial: @@ -67,7 +67,7 @@ Optimization: value: goto_main option: [ stay_there, goto_main, close_game ] -# ==================== Farm ==================== +# ==================== Daily ==================== Dungeon: Name: @@ -77,9 +77,3 @@ Dungeon: Team: value: 1 option: [ 1, 2, 3, 4, 5, 6 ] - -# ==================== Daily ==================== - - -# ==================== Tools ==================== - diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index 30018cf7c..e507742e6 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -11,7 +11,8 @@ "menu": "list", "page": "setting", "tasks": [ - "Dungeon" + "Dungeon", + "DailyQuest" ] } } \ No newline at end of file diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 9fd5fc3cf..3a251f974 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -25,3 +25,5 @@ Daily: Dungeon: - Scheduler - Dungeon + DailyQuest: + - Scheduler diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 52a0fd42f..6693be31f 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -13,7 +13,7 @@ class GeneratedConfig: Scheduler_Enable = False Scheduler_NextRun = datetime.datetime(2020, 1, 1, 0, 0) Scheduler_Command = 'Alas' - Scheduler_ServerUpdate = '00:00' + Scheduler_ServerUpdate = '04:00' # Group `Emulator` Emulator_Serial = 'auto' diff --git a/module/config/config_manual.py b/module/config/config_manual.py index edc61bc67..a4c273e44 100644 --- a/module/config/config_manual.py +++ b/module/config/config_manual.py @@ -10,7 +10,7 @@ class ManualConfig: SCHEDULER_PRIORITY = """ Restart - > Dungeon + > Dungeon > DailyQuest """ """ diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 78a848ff8..fc4bfe50d 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -21,6 +21,10 @@ "Dungeon": { "name": "Dungeon", "help": "" + }, + "DailyQuest": { + "name": "Daily Quest", + "help": "" } }, "Scheduler": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 5d725fc99..e87aaf217 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -21,6 +21,10 @@ "Dungeon": { "name": "Task.Dungeon.name", "help": "Task.Dungeon.help" + }, + "DailyQuest": { + "name": "Task.DailyQuest.name", + "help": "Task.DailyQuest.help" } }, "Scheduler": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 0656a5a8d..3eba4d86a 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -21,6 +21,10 @@ "Dungeon": { "name": "每日副本", "help": "" + }, + "DailyQuest": { + "name": "每日任务", + "help": "" } }, "Scheduler": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index f9c532392..c07c6222f 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -21,6 +21,10 @@ "Dungeon": { "name": "每日副本", "help": "" + }, + "DailyQuest": { + "name": "每日任務", + "help": "" } }, "Scheduler": { diff --git a/src.py b/src.py index 72e91f655..552812335 100644 --- a/src.py +++ b/src.py @@ -26,6 +26,10 @@ class StarRailCopilot(AzurLaneAutoScript): from tasks.dungeon.dungeon import Dungeon Dungeon(config=self.config, device=self.device).run() + def daily_quest(self): + from tasks.daily.daily_quest import DailyQuestUI + DailyQuestUI(config=self.config, device=self.device).run() + if __name__ == '__main__': src = StarRailCopilot('src') diff --git a/tasks/daily/camera.py b/tasks/daily/camera.py index 2e038155a..11dd3cbd1 100644 --- a/tasks/daily/camera.py +++ b/tasks/daily/camera.py @@ -17,6 +17,7 @@ class CameraUI(UI): in: Any out: page_camera, TAKE_PICTURE """ + logger.hr('Take picture', level=2) self.ui_ensure(page_camera, skip_first_screenshot) # Take picture skip_first_screenshot = True diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index fa7aac7dd..3aadd3d29 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -5,7 +5,9 @@ from module.logger import * from module.ocr.ocr import Ocr, OcrResultButton from module.ocr.utils import split_and_pair_buttons from tasks.daily.assets.assets_daily_reward import * -from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST_STATE +from tasks.daily.camera import CameraUI +from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST, KEYWORDS_DAILY_QUEST_STATE +from tasks.daily.synthesize import SynthesizeConsumablesUI from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DungeonUI @@ -20,6 +22,11 @@ class DailyQuestOcr(Ocr): result = result.replace("J", "」") result = result.replace(";", "」") result = result.replace("宇审", "宇宙") + # 进行中」hbadarin + if "进行中" in result: + result = "进行中" + if "已领取" in result: + result = "已领取" return result @@ -85,8 +92,6 @@ class DailyQuestUI(DungeonUI): results = [result.matched_keyword for result in results] logger.info("Daily quests recognition complete") logger.info(f"Daily quests: {results}") - if len(results) != 6: - logger.warning(f'Unexpected amount of daily quests: {len(results)}') return results def _get_quest_reward(self, skip_first_screenshot=True): @@ -111,6 +116,9 @@ class DailyQuestUI(DungeonUI): and (self.appear(ACTIVE_POINTS_5_LOCKED) or self.appear(ACTIVE_POINTS_5_CHECKED)) ) + def _all_reward_got(self): + return self.appear(ACTIVE_POINTS_5_CHECKED) + def _get_active_point_reward(self, skip_first_screenshot=True): while 1: if skip_first_screenshot: @@ -134,9 +142,55 @@ class DailyQuestUI(DungeonUI): continue def get_daily_rewards(self): + """ + Returns: + int: If all reward got. + + Pages: + in: Any + out: page_guide, Daily_Training + """ + logger.hr('Get daily rewards', level=2) self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training) logger.info("Getting quest rewards") self._get_quest_reward() logger.info("Getting active point rewards") self._get_active_point_reward() - logger.info("All daily reward got") + if self._all_reward_got(): + logger.info("All daily reward got") + return True + else: + logger.info('Daily reward got but not yet claimed') + return False + + def do_daily_quests(self): + """ + Returns: + int: Number of quests done + """ + logger.hr('Recognize quests', level=1) + quests = self.daily_quests_recognition() + + done = 0 + logger.hr('Do quests', level=1) + if KEYWORDS_DAILY_QUEST.Take_1_photo in quests: + CameraUI(self.config, self.device).take_picture() + done += 1 + if KEYWORDS_DAILY_QUEST.Synthesize_Consumable_1_time in quests: + SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables() + done += 1 + + return done + + def run(self): + for _ in range(5): + got = self.get_daily_rewards() + if got: + break + done = self.do_daily_quests() + if not done: + logger.info('No more quests able to do') + break + + # Scheduler + self.config.task_delay(server_update=True) diff --git a/tasks/daily/synthesize.py b/tasks/daily/synthesize.py index 945e6ea40..490ffd805 100644 --- a/tasks/daily/synthesize.py +++ b/tasks/daily/synthesize.py @@ -57,7 +57,7 @@ class SynthesizeUI(UI): class SynthesizeConsumablesUI(SynthesizeUI): - def synthesize(self) -> bool: + def synthesize_consumables(self) -> bool: """ Returns: bool: @@ -65,9 +65,9 @@ class SynthesizeConsumablesUI(SynthesizeUI): Examples: self = SynthesizeConsumablesUI('alas') self.device.screenshot() - result = self.synthesize() + result = self.synthesize_consumables() """ - + logger.hr('Synthesize consumables', level=2) # If the current page is not the menu page, # the menu scroll bar must be at the top when opening the menu page from other page, # so first step is determine whether the scroll bar is at the top