mirror of
https://github.com/ok-oldking/ok-wuthering-waves.git
synced 2025-06-07 01:15:18 +00:00
优化月卡检查
This commit is contained in:
parent
9ce28fe4b3
commit
8857fbde17
@ -29,6 +29,8 @@ class CombatCheck:
|
|||||||
self.last_liberation = 0
|
self.last_liberation = 0
|
||||||
|
|
||||||
def reset_to_false(self, recheck=False, reason=""):
|
def reset_to_false(self, recheck=False, reason=""):
|
||||||
|
if self.handle_monthly_card():
|
||||||
|
return True
|
||||||
if is_pure_black(self.frame):
|
if is_pure_black(self.frame):
|
||||||
logger.error('getting a pure black frame for unknown reason, reset_to_false return true')
|
logger.error('getting a pure black frame for unknown reason, reset_to_false return true')
|
||||||
return True
|
return True
|
||||||
|
@ -57,13 +57,13 @@ class BaseWWTask(BaseTask, FindFeature, OCR):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_check_monthly_card(self):
|
def set_check_monthly_card(self, next_day=False):
|
||||||
if self.monthly_card_config.get('Check Monthly Card'):
|
if self.monthly_card_config.get('Check Monthly Card'):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
hour = self.monthly_card_config.get('Monthly Card Time')
|
hour = self.monthly_card_config.get('Monthly Card Time')
|
||||||
# Calculate the next 4 o'clock in the morning
|
# Calculate the next 4 o'clock in the morning
|
||||||
next_four_am = now.replace(hour=hour, minute=0, second=0, microsecond=0)
|
next_four_am = now.replace(hour=hour, minute=0, second=0, microsecond=0)
|
||||||
if now >= next_four_am:
|
if now >= next_four_am or next_day:
|
||||||
next_four_am += timedelta(days=1)
|
next_four_am += timedelta(days=1)
|
||||||
next_monthly_card_start_date_time = next_four_am - timedelta(seconds=30)
|
next_monthly_card_start_date_time = next_four_am - timedelta(seconds=30)
|
||||||
# Subtract 1 minute from the next 4 o'clock in the morning
|
# Subtract 1 minute from the next 4 o'clock in the morning
|
||||||
@ -94,26 +94,26 @@ class BaseWWTask(BaseTask, FindFeature, OCR):
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
def check_for_monthly_card(self):
|
def check_for_monthly_card(self):
|
||||||
if self.next_monthly_card_start > 0:
|
if self.should_check_monthly_card():
|
||||||
if time.time() > self.next_monthly_card_start:
|
start = time.time()
|
||||||
start = time.time()
|
logger.info(f'check_for_monthly_card start check')
|
||||||
logger.info(f'start waiting for monthly card')
|
if self.check_combat():
|
||||||
f4_open = False
|
logger.info(f'check_for_monthly_card in combat return')
|
||||||
if self.in_team_and_world():
|
return time.time() - start
|
||||||
logger.info(f'in team send f4 to wait')
|
if self.in_team_and_world():
|
||||||
self.send_key('f4')
|
logger.info(f'check_for_monthly_card in team send sleep until monthly card popup')
|
||||||
f4_open = True
|
|
||||||
monthly_card = self.wait_until(self.handle_monthly_card, time_out=120, raise_if_not_found=False)
|
monthly_card = self.wait_until(self.handle_monthly_card, time_out=120, raise_if_not_found=False)
|
||||||
logger.info(f'wait monthly card end {monthly_card}')
|
logger.info(f'wait monthly card end {monthly_card}')
|
||||||
if f4_open:
|
cost = time.time() - start
|
||||||
self.send_key('esc')
|
return cost
|
||||||
self.sleep(2)
|
|
||||||
logger.info(f'wait monthly card close f4')
|
|
||||||
cost = time.time() - start
|
|
||||||
self.set_check_monthly_card()
|
|
||||||
return cost
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def should_check_monthly_card(self):
|
||||||
|
if self.next_monthly_card_start > 0:
|
||||||
|
if 0 < time.time() - self.next_monthly_card_start < 120:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def sleep(self, timeout):
|
def sleep(self, timeout):
|
||||||
return super().sleep(timeout - self.check_for_monthly_card())
|
return super().sleep(timeout - self.check_for_monthly_card())
|
||||||
|
|
||||||
@ -131,6 +131,7 @@ class BaseWWTask(BaseTask, FindFeature, OCR):
|
|||||||
self.sleep(2)
|
self.sleep(2)
|
||||||
self.click(monthly_card)
|
self.click(monthly_card)
|
||||||
self.sleep(1)
|
self.sleep(1)
|
||||||
|
self.set_check_monthly_card(next_day=True)
|
||||||
logger.debug(f'check_monthly_card {monthly_card}')
|
logger.debug(f'check_monthly_card {monthly_card}')
|
||||||
return monthly_card is not None
|
return monthly_card is not None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user