Fix: Failed to receive weekly reward if immersifier is full

This commit is contained in:
LmeSzinc 2023-10-23 22:36:40 +08:00
parent 15c78c5b3a
commit e1903f0ed4
3 changed files with 22 additions and 9 deletions

View File

@ -66,6 +66,7 @@ class RogueRewardHandler(RogueUI):
logger.info('Rogue reward claim')
claimed = False
appear = False
click_count = 0
timeout = Timer(2, count=10).start()
while 1:
if skip_first_screenshot:
@ -76,12 +77,15 @@ class RogueRewardHandler(RogueUI):
# End
if claimed:
if self.appear(REWARD_CHECK):
break
return True
if self.is_page_rogue_main():
break
return True
if not appear and timeout.reached():
logger.warning('Rogue reward claim timeout, CLAIM_ALL not found')
break
return False
if click_count > 3:
logger.warning('Failed to claim weekly rewards, probably because immersifier is full')
return False
if self.handle_reward():
claimed = True
@ -91,6 +95,7 @@ class RogueRewardHandler(RogueUI):
self.device.click(CLAIM_ALL)
self.interval_reset(CLAIM_ALL, interval=1)
appear = True
click_count += 1
continue
def rogue_reward_claim(self):
@ -107,9 +112,9 @@ class RogueRewardHandler(RogueUI):
logger.hr('Rogue reward claim', level=2)
if self._rogue_reward_appear():
self._rogue_reward_enter()
self._rogue_reward_claim()
success = self._rogue_reward_claim()
self._rogue_reward_exit()
return True
return success
else:
logger.info('No rogue reward')
return False

View File

@ -1,3 +1,5 @@
from datetime import datetime, timedelta
from module.base.timer import Timer
from module.logger import logger
from module.ocr.ocr import DigitCounter
@ -109,9 +111,17 @@ class RogueReward(RogueUI, CombatInteract):
use_immersifier=True
):
if not use_trailblaze_power and not use_immersifier:
logger.info('Cannot claim domain reward, as all disabled')
return False
if use_immersifier and self.config.stored.Immersifier.value > 0:
return True
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
if use_trailblaze_power and self.config.stored.TrailblazePower.predict_current() >= 40:
logger.info(f'Can claim domain reward, got enough trailblaze power')
return True
logger.info('Cannot claim domain reward, requirements not satisfied')
return False

View File

@ -184,11 +184,9 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent, RogueReward):
use_immersifier = 'immersifier' in self.config.RogueWorld_ImmersionReward
if self.can_claim_domain_reward(use_trailblaze_power=use_trailblaze_power, use_immersifier=use_immersifier):
logger.info('Can claim domain reward')
result = self.goto(*waypoints)
self.claim_domain_reward(use_trailblaze_power=use_trailblaze_power, use_immersifier=use_immersifier)
else:
logger.info('Cannot claim more rewards')
result = []
return result