StarRailCopilot/tasks/rogue/rogue.py

75 lines
2.9 KiB
Python
Raw Permalink Normal View History

from module.exception import RequestHumanTakeover
2023-10-18 16:07:17 +00:00
from module.logger import logger
2024-02-06 21:13:54 +00:00
from tasks.battle_pass.keywords import KEYWORDS_BATTLE_PASS_QUEST
from tasks.daily.keywords import KEYWORDS_DAILY_QUEST
2023-10-18 13:01:48 +00:00
from tasks.rogue.entry.entry import RogueEntry
from tasks.rogue.exception import RogueReachedWeeklyPointLimit, RogueTeamNotPrepared
2023-10-14 16:32:40 +00:00
from tasks.rogue.route.loader import RouteLoader
class Rogue(RouteLoader, RogueEntry):
2023-10-14 16:32:40 +00:00
def rogue_once(self):
"""
Do a complete rogue run.
Pages:
2023-10-18 13:01:48 +00:00
in: Any
2023-10-14 16:32:40 +00:00
out: page_rogue, is_page_rogue_main()
"""
2023-10-18 16:07:17 +00:00
try:
self.rogue_world_enter()
except RogueTeamNotPrepared:
logger.error(f'Please prepare your team in {self.config.RogueWorld_World} '
f'and start rogue task at team preparation page')
raise RequestHumanTakeover
except RogueReachedWeeklyPointLimit:
logger.hr('Reached rogue weekly point limit')
return False
2023-10-18 16:07:17 +00:00
2023-10-14 16:32:40 +00:00
self.rogue_run()
self.rogue_reward_claim()
2023-10-18 16:07:17 +00:00
return True
2023-10-14 16:32:40 +00:00
def run(self):
self.config.update_battle_pass_quests()
2023-12-06 09:47:39 +00:00
self.config.update_daily_quests()
if self.config.stored.DungeonDouble.is_expired():
self.config.task_call('Dungeon')
self.config.task_stop()
# Run
success = self.rogue_once()
# Scheduler
with self.config.multi_set():
# Task switched
if self.config.task_switched():
self.config.task_stop()
# Archived daily quest
if success:
quests = self.config.stored.DailyQuest.load_quests()
if KEYWORDS_DAILY_QUEST.Complete_Divergent_Universe_or_Simulated_Universe_1_times in quests:
logger.info('Achieve daily quest Complete_Divergent_Universe_or_Simulated_Universe_1_times')
self.config.task_call('DailyQuest')
2023-12-06 09:47:39 +00:00
self.config.task_stop()
quests = self.config.stored.BattlePassWeeklyQuest.load_quests()
if KEYWORDS_BATTLE_PASS_QUEST.Complete_Divergent_Universe_or_Simulated_Universe_1_times in quests:
logger.info('Achieve battle pass quest Complete_Divergent_Universe_or_Simulated_Universe_1_times')
self.config.task_call('BattlePass')
self.config.task_stop()
# End
if success:
logger.info('Rogue run success')
# Call rogue itself, so multiple rogue runs are considered as separated tasks
# which won't trigger failure count >= 3 when clearing 100 elites
self.config.task_call('Rogue')
else:
logger.info('Rogue run failed')
self.config.task_delay(server_update=True)
2023-10-14 16:32:40 +00:00
if __name__ == '__main__':
self = Rogue('src', task='Rogue')
2023-10-14 16:32:40 +00:00
self.device.screenshot()
self.rogue_once()