2024-06-14 16:06:17 +00:00
|
|
|
from module.config.utils import get_server_next_monday_update
|
2023-09-26 19:14:12 +00:00
|
|
|
from module.logger import logger
|
|
|
|
from module.ocr.ocr import DigitCounter
|
|
|
|
from tasks.daily.keywords import KEYWORDS_DAILY_QUEST
|
|
|
|
from tasks.dungeon.assets.assets_dungeon_ui import OCR_DUNGEON_LIST, OCR_WEEKLY_LIMIT
|
|
|
|
from tasks.dungeon.dungeon import Dungeon
|
2024-02-12 15:29:21 +00:00
|
|
|
from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_NAV, KEYWORDS_DUNGEON_TAB
|
2023-09-26 19:14:12 +00:00
|
|
|
from tasks.dungeon.ui import DUNGEON_LIST
|
|
|
|
|
|
|
|
|
|
|
|
class WeeklyDungeon(Dungeon):
|
|
|
|
def require_compulsory_support(self) -> bool:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _dungeon_run(self, dungeon: DungeonList, team: int = None, wave_limit: int = 0, support_character: str = None,
|
|
|
|
skip_ui_switch: bool = False):
|
|
|
|
if team is None:
|
|
|
|
team = self.config.Weekly_Team
|
2024-02-23 16:41:01 +00:00
|
|
|
|
2023-09-26 19:14:12 +00:00
|
|
|
skip_ui_switch = True
|
|
|
|
return super()._dungeon_run(
|
|
|
|
dungeon=dungeon, team=team, wave_limit=wave_limit,
|
|
|
|
support_character=support_character, skip_ui_switch=skip_ui_switch)
|
|
|
|
|
2024-05-13 07:07:44 +00:00
|
|
|
def handle_ascension_dungeon_prepare(self):
|
|
|
|
# combat_wave_cost==30 in weekly, but no handle_ascension_dungeon_prepare required
|
|
|
|
return False
|
|
|
|
|
2023-09-26 19:14:12 +00:00
|
|
|
def get_weekly_remain(self) -> int:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_guide, Survival_Index, KEYWORDS_DUNGEON_NAV.Echo_of_War
|
|
|
|
"""
|
|
|
|
ocr = DigitCounter(OCR_WEEKLY_LIMIT)
|
|
|
|
current, _, _ = ocr.ocr_single_line(self.device.image)
|
|
|
|
total = self.config.stored.EchoOfWar.FIXED_TOTAL
|
|
|
|
if current <= total:
|
|
|
|
logger.attr('EchoOfWar', f'{current}/{total}')
|
|
|
|
self.config.stored.EchoOfWar.value = current
|
|
|
|
return current
|
|
|
|
else:
|
|
|
|
logger.warning(f'Invalid EchoOfWar limit: {current}/{total}')
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# self.config.update_battle_pass_quests()
|
|
|
|
self.config.update_daily_quests()
|
|
|
|
self.called_daily_support = False
|
|
|
|
self.achieved_daily_quest = False
|
2024-01-01 20:07:35 +00:00
|
|
|
self.achieved_weekly_quest = False
|
2023-09-26 19:14:12 +00:00
|
|
|
self.daily_quests = self.config.stored.DailyQuest.load_quests()
|
2024-01-01 20:07:35 +00:00
|
|
|
self.weekly_quests = self.config.stored.BattlePassWeeklyQuest.load_quests()
|
2023-09-26 19:14:12 +00:00
|
|
|
|
|
|
|
dungeon = DungeonList.find(self.config.Weekly_Name)
|
2024-05-26 19:03:11 +00:00
|
|
|
planner = self.planner.get_weekly()
|
|
|
|
if planner is not None:
|
|
|
|
dungeon = planner
|
2024-05-26 19:15:42 +00:00
|
|
|
logger.attr('DungeonWeekly', dungeon)
|
2023-09-26 19:14:12 +00:00
|
|
|
|
|
|
|
# UI switches
|
|
|
|
self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Survival_Index)
|
|
|
|
# Equivalent to self.dungeon_goto(dungeon), but check limit remains
|
|
|
|
DUNGEON_LIST.search_button = OCR_DUNGEON_LIST
|
2024-02-12 15:29:21 +00:00
|
|
|
self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Echo_of_War)
|
2024-02-17 13:28:54 +00:00
|
|
|
self._dungeon_wait_until_dungeon_list_loaded()
|
2024-06-14 16:06:17 +00:00
|
|
|
monday = get_server_next_monday_update(self.config.Scheduler_ServerUpdate)
|
2023-09-26 19:14:12 +00:00
|
|
|
|
|
|
|
# Check limit
|
|
|
|
remain = self.get_weekly_remain()
|
|
|
|
if remain <= 0:
|
|
|
|
if KEYWORDS_DAILY_QUEST.Complete_Echo_of_War_1_times in self.daily_quests:
|
|
|
|
logger.info('Reached the limit to get Echo_of_War rewards, continue cause daily quests require it')
|
|
|
|
remain = 1
|
|
|
|
else:
|
|
|
|
logger.info('Reached the limit to get Echo_of_War rewards, stop')
|
2024-06-14 16:06:17 +00:00
|
|
|
self.config.task_delay(target=monday)
|
2023-09-26 19:14:12 +00:00
|
|
|
self.config.task_stop()
|
|
|
|
|
|
|
|
self._dungeon_insight(dungeon)
|
|
|
|
self._dungeon_enter(dungeon)
|
|
|
|
|
|
|
|
# Combat
|
|
|
|
count = self.dungeon_run(dungeon, wave_limit=min(remain, 3))
|
|
|
|
|
2024-01-01 20:07:35 +00:00
|
|
|
logger.attr('achieved_daily_quest', self.achieved_daily_quest)
|
|
|
|
logger.attr('achieved_weekly_quest', self.achieved_weekly_quest)
|
2023-09-26 19:14:12 +00:00
|
|
|
with self.config.multi_set():
|
|
|
|
if count:
|
2024-01-01 20:07:35 +00:00
|
|
|
# Check battle pass
|
|
|
|
if self.achieved_weekly_quest:
|
|
|
|
self.config.task_call('BattlePass')
|
|
|
|
# Check daily
|
|
|
|
if self.achieved_daily_quest:
|
2023-09-26 19:14:12 +00:00
|
|
|
self.config.task_call('DailyQuest')
|
2024-01-12 09:10:11 +00:00
|
|
|
# Update dashboard
|
|
|
|
self.config.stored.EchoOfWar.add(-count)
|
|
|
|
if self.config.stored.EchoOfWar.value < 0:
|
|
|
|
logger.warning(f'Invalid EchoOfWar value, revise to 0')
|
|
|
|
self.config.stored.EchoOfWar.value = 0
|
2023-09-26 19:14:12 +00:00
|
|
|
# Finished all remains
|
|
|
|
if count >= remain:
|
|
|
|
logger.info('All Echo_of_War rewards got')
|
2024-06-14 16:06:17 +00:00
|
|
|
self.config.task_delay(target=monday)
|
2023-09-26 19:14:12 +00:00
|
|
|
self.config.task_stop()
|
|
|
|
|
|
|
|
logger.warning(f'Unexpected Echo_of_War case, count={count}, remain={remain}')
|
|
|
|
self.config.task_delay(server_update=True)
|
|
|
|
self.config.task_stop()
|