diff --git a/dev_tools/keyword_extract.py b/dev_tools/keyword_extract.py index 203f53bd2..98321d20f 100644 --- a/dev_tools/keyword_extract.py +++ b/dev_tools/keyword_extract.py @@ -161,6 +161,8 @@ class KeywordExtract: self.write_keywords(keyword_class='DungeonTab', output_file='./tasks/dungeon/keywords/tab.py') self.load_daily_quests_keywords() self.write_keywords(keyword_class='DailyQuest', output_file='./tasks/daily/keywords/daily_quest.py') + self.load_keywords(['前往', '领取', '进行中', '已领取', '本日活跃度已满']) + self.write_keywords(keyword_class='DailyQuestState', output_file='./tasks/daily/keywords/daily_quest_state.py') self.load_keywords(list(self.iter_guide())) self.write_keywords(keyword_class='DungeonList', output_file='./tasks/dungeon/keywords/dungeon.py', text_convert=dungeon_name) diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index afa25bebc..ed77c2316 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -3,8 +3,9 @@ import numpy as np from module.base.timer import Timer 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 +from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST_STATE from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DungeonUI @@ -61,12 +62,20 @@ class DailyQuestUI(DungeonUI): def _ocr_single_page(self) -> list[OcrResultButton]: ocr = DailyQuestOcr(OCR_DAILY_QUEST) ocr.merge_thres_y = 20 - results = ocr.matched_ocr(self.device.image, DailyQuest) - if len(results) < 4: - logger.warning(f"Recognition failed at {4 - len(results)} quests on one page") - return results + results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest]) + if len(results) < 8: + logger.warning(f"Recognition failed at {8 - len(results)} quests on one page") + + def completed_state(state): + return state != KEYWORDS_DAILY_QUEST_STATE.Go and state != KEYWORDS_DAILY_QUEST_STATE.In_Progress + + return [quest for quest, _ in + split_and_pair_buttons(results, split_func=completed_state, relative_area=(0, 0, 200, 720))] def daily_quests_recognition(self): + """ + Returns incomplete quests only + """ logger.info("Recognizing daily quests") self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training) self._ensure_position('left') @@ -86,7 +95,7 @@ class DailyQuestUI(DungeonUI): if self.appear(DAILY_QUEST_FULL) or self.appear(DAILY_QUEST_GOTO): break - if self.appear_then_click(DAILY_QUEST_REWARD): + if self.appear_then_click(DAILY_QUEST_REWARD, interval=1): continue def _no_reward_to_get(self): diff --git a/tasks/daily/keywords/__init__.py b/tasks/daily/keywords/__init__.py index 937e9460e..0ee2bcfe0 100644 --- a/tasks/daily/keywords/__init__.py +++ b/tasks/daily/keywords/__init__.py @@ -1,2 +1,3 @@ import tasks.daily.keywords.daily_quest as KEYWORDS_DAILY_QUEST -from tasks.daily.keywords.classes import DailyQuest +import tasks.daily.keywords.daily_quest_state as KEYWORDS_DAILY_QUEST_STATE +from tasks.daily.keywords.classes import DailyQuest, DailyQuestState diff --git a/tasks/daily/keywords/classes.py b/tasks/daily/keywords/classes.py index 39ba677b0..3a0e6b36b 100644 --- a/tasks/daily/keywords/classes.py +++ b/tasks/daily/keywords/classes.py @@ -7,3 +7,8 @@ from module.ocr.keyword import Keyword @dataclass class DailyQuest(Keyword): instances: ClassVar = {} + + +@dataclass +class DailyQuestState(Keyword): + instances: ClassVar = {} diff --git a/tasks/daily/keywords/daily_quest_state.py b/tasks/daily/keywords/daily_quest_state.py new file mode 100644 index 000000000..05eac864b --- /dev/null +++ b/tasks/daily/keywords/daily_quest_state.py @@ -0,0 +1,45 @@ +from .classes import DailyQuestState + +# This file was auto-generated, do not modify it manually. To generate: +# ``` python -m dev_tools.keyword_extract ``` + +Go = DailyQuestState( + id=1, + name='Go', + cn='前往', + cht='前往', + en='Go', + jp='進む', +) +Claim = DailyQuestState( + id=2, + name='Claim', + cn='领取', + cht='領取', + en='Claim', + jp='受取', +) +In_Progress = DailyQuestState( + id=3, + name='In_Progress', + cn='进行中', + cht='進行中', + en='In Progress', + jp='進行中', +) +Claimed = DailyQuestState( + id=4, + name='Claimed', + cn='已领取', + cht='已領取', + en='Claimed', + jp='受取済', +) +Today_Activity_completed = DailyQuestState( + id=5, + name='Today_Activity_completed', + cn='本日活跃度已满', + cht='本日活躍度已滿', + en="Today's Activity completed", + jp='本日のアクティブ度が最大に達しました', +)