mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 01:49:41 +00:00
Upd: return incomplete quests only (#11)
* Upd: return incomplete quests only * Fix: Typo * Fix: Use split_and_pair_button
This commit is contained in:
parent
173485b2f7
commit
035ab0a778
@ -161,6 +161,8 @@ class KeywordExtract:
|
|||||||
self.write_keywords(keyword_class='DungeonTab', output_file='./tasks/dungeon/keywords/tab.py')
|
self.write_keywords(keyword_class='DungeonTab', output_file='./tasks/dungeon/keywords/tab.py')
|
||||||
self.load_daily_quests_keywords()
|
self.load_daily_quests_keywords()
|
||||||
self.write_keywords(keyword_class='DailyQuest', output_file='./tasks/daily/keywords/daily_quest.py')
|
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.load_keywords(list(self.iter_guide()))
|
||||||
self.write_keywords(keyword_class='DungeonList', output_file='./tasks/dungeon/keywords/dungeon.py',
|
self.write_keywords(keyword_class='DungeonList', output_file='./tasks/dungeon/keywords/dungeon.py',
|
||||||
text_convert=dungeon_name)
|
text_convert=dungeon_name)
|
||||||
|
@ -3,8 +3,9 @@ import numpy as np
|
|||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.logger import *
|
from module.logger import *
|
||||||
from module.ocr.ocr import Ocr, OcrResultButton
|
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.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.keywords import KEYWORDS_DUNGEON_TAB
|
||||||
from tasks.dungeon.ui import DungeonUI
|
from tasks.dungeon.ui import DungeonUI
|
||||||
|
|
||||||
@ -61,12 +62,20 @@ class DailyQuestUI(DungeonUI):
|
|||||||
def _ocr_single_page(self) -> list[OcrResultButton]:
|
def _ocr_single_page(self) -> list[OcrResultButton]:
|
||||||
ocr = DailyQuestOcr(OCR_DAILY_QUEST)
|
ocr = DailyQuestOcr(OCR_DAILY_QUEST)
|
||||||
ocr.merge_thres_y = 20
|
ocr.merge_thres_y = 20
|
||||||
results = ocr.matched_ocr(self.device.image, DailyQuest)
|
results = ocr.matched_ocr(self.device.image, [DailyQuestState, DailyQuest])
|
||||||
if len(results) < 4:
|
if len(results) < 8:
|
||||||
logger.warning(f"Recognition failed at {4 - len(results)} quests on one page")
|
logger.warning(f"Recognition failed at {8 - len(results)} quests on one page")
|
||||||
return results
|
|
||||||
|
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):
|
def daily_quests_recognition(self):
|
||||||
|
"""
|
||||||
|
Returns incomplete quests only
|
||||||
|
"""
|
||||||
logger.info("Recognizing daily quests")
|
logger.info("Recognizing daily quests")
|
||||||
self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training)
|
self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training)
|
||||||
self._ensure_position('left')
|
self._ensure_position('left')
|
||||||
@ -86,7 +95,7 @@ class DailyQuestUI(DungeonUI):
|
|||||||
|
|
||||||
if self.appear(DAILY_QUEST_FULL) or self.appear(DAILY_QUEST_GOTO):
|
if self.appear(DAILY_QUEST_FULL) or self.appear(DAILY_QUEST_GOTO):
|
||||||
break
|
break
|
||||||
if self.appear_then_click(DAILY_QUEST_REWARD):
|
if self.appear_then_click(DAILY_QUEST_REWARD, interval=1):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def _no_reward_to_get(self):
|
def _no_reward_to_get(self):
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
import tasks.daily.keywords.daily_quest as KEYWORDS_DAILY_QUEST
|
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
|
||||||
|
@ -7,3 +7,8 @@ from module.ocr.keyword import Keyword
|
|||||||
@dataclass
|
@dataclass
|
||||||
class DailyQuest(Keyword):
|
class DailyQuest(Keyword):
|
||||||
instances: ClassVar = {}
|
instances: ClassVar = {}
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class DailyQuestState(Keyword):
|
||||||
|
instances: ClassVar = {}
|
||||||
|
45
tasks/daily/keywords/daily_quest_state.py
Normal file
45
tasks/daily/keywords/daily_quest_state.py
Normal file
@ -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='本日のアクティブ度が最大に達しました',
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user