2023-10-23 14:36:40 +00:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
2023-10-20 09:48:22 +00:00
|
|
|
from module.base.timer import Timer
|
|
|
|
from module.logger import logger
|
|
|
|
from tasks.base.assets.assets_base_popup import GET_REWARD
|
|
|
|
from tasks.combat.interact import CombatInteract
|
2023-11-01 19:56:01 +00:00
|
|
|
from tasks.dungeon.state import DungeonState
|
|
|
|
from tasks.rogue.assets.assets_rogue_reward import REWARD_CLOSE, USE_IMMERSIFIER, USE_STAMINA
|
2023-10-20 09:48:22 +00:00
|
|
|
from tasks.rogue.bleesing.ui import RogueUI
|
|
|
|
|
|
|
|
|
2023-11-01 19:56:01 +00:00
|
|
|
class RogueReward(RogueUI, CombatInteract, DungeonState):
|
2023-10-20 09:48:22 +00:00
|
|
|
def claim_domain_reward(
|
|
|
|
self,
|
|
|
|
use_trailblaze_power=False,
|
|
|
|
use_immersifier=True,
|
|
|
|
skip_first_screenshot=True
|
|
|
|
):
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_main, DUNGEON_COMBAT_INTERACT, near immersifier
|
|
|
|
"""
|
|
|
|
logger.hr('Claim domain reward', level=2)
|
|
|
|
logger.info(f'use_trailblaze_power={use_trailblaze_power}, use_immersifier={use_immersifier}')
|
|
|
|
if not use_trailblaze_power and not use_immersifier:
|
|
|
|
return
|
|
|
|
|
|
|
|
confirm = Timer(0.6, count=2).start()
|
2023-10-23 16:27:06 +00:00
|
|
|
exhausted = False
|
2023-10-20 09:48:22 +00:00
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
if self.is_in_main():
|
|
|
|
if confirm.reached():
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
confirm.reset()
|
|
|
|
|
2023-10-23 16:27:06 +00:00
|
|
|
if not exhausted and self.handle_combat_interact():
|
2023-10-20 09:48:22 +00:00
|
|
|
self.interval_clear(USE_STAMINA)
|
|
|
|
confirm.reset()
|
|
|
|
continue
|
|
|
|
if self.handle_reward():
|
|
|
|
self.interval_clear(USE_STAMINA)
|
|
|
|
confirm.reset()
|
|
|
|
continue
|
|
|
|
if self.appear(REWARD_CLOSE, interval=2):
|
2023-11-01 19:56:01 +00:00
|
|
|
self.dungeon_update_stamina()
|
2023-10-20 09:48:22 +00:00
|
|
|
if use_immersifier and self.config.stored.Immersifier.value > 0:
|
|
|
|
self.device.click(USE_IMMERSIFIER)
|
|
|
|
self.interval_reset(USE_STAMINA)
|
|
|
|
self.interval_clear(GET_REWARD)
|
|
|
|
confirm.reset()
|
|
|
|
continue
|
|
|
|
elif use_trailblaze_power and self.config.stored.TrailblazePower.value >= 40:
|
|
|
|
self.device.click(USE_STAMINA)
|
|
|
|
self.interval_reset(USE_STAMINA)
|
|
|
|
self.interval_clear(GET_REWARD)
|
|
|
|
confirm.reset()
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
logger.info('Cannot claim more rewards')
|
|
|
|
self.device.click(REWARD_CLOSE)
|
|
|
|
self.interval_reset(USE_STAMINA)
|
|
|
|
confirm.reset()
|
2023-10-23 16:27:06 +00:00
|
|
|
exhausted = True
|
|
|
|
continue
|
2023-10-20 09:48:22 +00:00
|
|
|
|
|
|
|
def can_claim_domain_reward(
|
|
|
|
self,
|
|
|
|
use_trailblaze_power=False,
|
|
|
|
use_immersifier=True
|
|
|
|
):
|
|
|
|
if not use_trailblaze_power and not use_immersifier:
|
2023-10-23 14:36:40 +00:00
|
|
|
logger.info('Cannot claim domain reward, as all disabled')
|
2023-10-20 09:48:22 +00:00
|
|
|
return False
|
2023-10-23 14:36:40 +00:00
|
|
|
if use_immersifier:
|
|
|
|
if self.config.stored.Immersifier.value > 0:
|
|
|
|
logger.info(f'Can claim domain reward, got immersifiers')
|
|
|
|
return True
|
|
|
|
if datetime.now() - self.config.stored.Immersifier.time > timedelta(minutes=15):
|
|
|
|
logger.info(f'Can claim domain reward, immersifier record outdated')
|
|
|
|
return True
|
2023-10-20 09:48:22 +00:00
|
|
|
if use_trailblaze_power and self.config.stored.TrailblazePower.predict_current() >= 40:
|
2023-10-23 14:36:40 +00:00
|
|
|
logger.info(f'Can claim domain reward, got enough trailblaze power')
|
2023-10-20 09:48:22 +00:00
|
|
|
return True
|
2023-10-23 14:36:40 +00:00
|
|
|
logger.info('Cannot claim domain reward, requirements not satisfied')
|
2023-10-20 09:48:22 +00:00
|
|
|
return False
|