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
2024-01-01 20:07:35 +00:00
from tasks . daily . keywords import KEYWORDS_DAILY_QUEST
2023-10-18 13:01:48 +00:00
from tasks . rogue . entry . entry import RogueEntry
2023-10-18 18:13:51 +00:00
from tasks . rogue . exception import RogueReachedWeeklyPointLimit , RogueTeamNotPrepared
2023-10-14 16:32:40 +00:00
from tasks . rogue . route . loader import RouteLoader
2023-10-18 16:21:00 +00:00
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 :
2023-11-17 19:55:41 +00:00
logger . error ( f ' Please prepare your team in { self . config . RogueWorld_World } '
f ' and start rogue task at team preparation page ' )
2023-10-18 16:07:17 +00:00
self . rogue_world_exit ( )
return False
2023-10-18 18:13:51 +00:00
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 ( )
2024-03-06 08:32:14 +00:00
# runs when one rogue run finishes (do not handle whether the last rogue run finished or failed due to one who use this feature has less chance of failure -- would be better if check boss battle result instead of rogue result, but this version also works), and decreases rogue farming count by 1
if self . config . RogueWorld_WeeklyFarming and self . config . RogueWorld_WeeklyFarmingCount > 0 :
self . config . RogueWorld_WeeklyFarmingCount - = 1
logger . attr ( " WeeklyFarmingCount " ,
self . config . RogueWorld_WeeklyFarmingCount )
2023-10-18 16:07:17 +00:00
return True
2023-10-14 16:32:40 +00:00
2023-10-18 16:21:00 +00:00
def run ( self ) :
2024-01-01 20:07:35 +00:00
self . config . update_battle_pass_quests ( )
2023-12-06 09:47:39 +00:00
self . config . update_daily_quests ( )
2024-01-12 14:37:20 +00:00
if self . config . stored . DungeonDouble . is_expired ( ) :
self . config . task_call ( ' Dungeon ' )
self . config . task_stop ( )
2023-10-18 18:13:51 +00:00
while 1 :
# Run
success = self . rogue_once ( )
2023-10-20 18:25:18 +00:00
# Scheduler
2023-12-06 09:47:39 +00:00
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 ( )
2024-01-01 20:07:35 +00:00
if KEYWORDS_DAILY_QUEST . Complete_Simulated_Universe_1_times in quests :
2023-12-27 16:43:20 +00:00
logger . info ( ' Achieve daily quest Complete_Simulated_Universe_1_times ' )
2023-12-06 09:47:39 +00:00
self . config . task_call ( ' DailyQuest ' )
self . config . task_stop ( )
2024-01-01 20:07:35 +00:00
quests = self . config . stored . BattlePassWeeklyQuest . load_quests ( )
2024-02-06 21:13:54 +00:00
if KEYWORDS_BATTLE_PASS_QUEST . Complete_Simulated_Universe_1_times in quests :
2024-01-01 20:07:35 +00:00
logger . info ( ' Achieve battle pass quest Complete_Simulated_Universe_1_times ' )
self . config . task_call ( ' BattlePass ' )
self . config . task_stop ( )
2023-12-06 09:47:39 +00:00
# End
if not success :
self . config . task_delay ( server_update = True )
break
2023-10-18 16:21:00 +00:00
2023-10-14 16:32:40 +00:00
if __name__ == ' __main__ ' :
2023-10-18 16:21:00 +00:00
self = Rogue ( ' src ' , task = ' Rogue ' )
2023-10-14 16:32:40 +00:00
self . device . screenshot ( )
self . rogue_once ( )