mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 00:52:22 +00:00
Add: Timezone aware
- Fix mat withdraw on slow device
This commit is contained in:
parent
aa12392a28
commit
2609b4a70d
@ -23,7 +23,7 @@ def future_time(string):
|
||||
string (str): Such as 14:59.
|
||||
|
||||
Returns:
|
||||
datetime.datetime: Time with given hour, minute, second in the future.
|
||||
datetime.datetime: Time with given hour, minute in the future.
|
||||
"""
|
||||
hour, minute = [int(x) for x in string.split(':')]
|
||||
future = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
|
||||
@ -31,6 +31,20 @@ def future_time(string):
|
||||
return future
|
||||
|
||||
|
||||
def past_time(string):
|
||||
"""
|
||||
Args:
|
||||
string (str): Such as 14:59.
|
||||
|
||||
Returns:
|
||||
datetime.datetime: Time with given hour, minute in the past.
|
||||
"""
|
||||
hour, minute = [int(x) for x in string.split(':')]
|
||||
past = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
|
||||
past = past - timedelta(days=1) if past > datetime.now() else past
|
||||
return past
|
||||
|
||||
|
||||
def future_time_range(string):
|
||||
"""
|
||||
Args:
|
||||
|
@ -107,8 +107,7 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
|
||||
Returns:
|
||||
bool: If triggered a restart condition.
|
||||
"""
|
||||
now = datetime.now()
|
||||
if now.date() != self.start_time.date():
|
||||
if self.config.get_server_last_update(since=(0,)) > self.start_time:
|
||||
logger.hr('Triggered restart new day')
|
||||
return True
|
||||
if not self.campaign.config.IGNORE_LOW_EMOTION_WARN:
|
||||
|
@ -2,15 +2,16 @@ import codecs
|
||||
import configparser
|
||||
import copy
|
||||
import os
|
||||
from datetime import timezone
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
import module.config.server as server
|
||||
from module.base.timer import *
|
||||
from module.config.dictionary import *
|
||||
from module.logger import logger
|
||||
import module.config.server as server
|
||||
|
||||
|
||||
class AzurLaneConfig:
|
||||
@ -520,6 +521,30 @@ class AzurLaneConfig:
|
||||
self.C124_NON_S3_WITHDRAW_TOLERANCE = int(option['non_s3_enemy_withdraw_tolerance'])
|
||||
self.C124_AMMO_PICK_UP = int(option['ammo_pick_up_124'])
|
||||
|
||||
def get_server_timezone(self):
|
||||
if self.SERVER == 'en':
|
||||
return -7
|
||||
elif self.SERVER == 'cn':
|
||||
return 8
|
||||
elif self.SERVER == 'jp':
|
||||
return 9
|
||||
else:
|
||||
return 8
|
||||
|
||||
def get_server_last_update(self, since):
|
||||
"""
|
||||
Args:
|
||||
since (tuple(int)): Update hour in Azurlane, such as (0, 12, 18,).
|
||||
|
||||
Returns:
|
||||
datetime.datetime
|
||||
"""
|
||||
d = datetime.now(timezone.utc).astimezone()
|
||||
diff = d.utcoffset() // timedelta(seconds=1) // 3600 - self.get_server_timezone()
|
||||
since = np.sort((np.array(since) + diff) % 24)
|
||||
update = sorted([past_time(f'{t}:00') for t in since])[-1]
|
||||
return update
|
||||
|
||||
def record_executed_since(self, option, since):
|
||||
"""
|
||||
Args:
|
||||
@ -530,10 +555,7 @@ class AzurLaneConfig:
|
||||
bool: If got a record after last game update.
|
||||
"""
|
||||
record = datetime.strptime(self.config.get(*option), self.TIME_FORMAT)
|
||||
since = np.array(since)
|
||||
|
||||
hour = since[since <= datetime.now().hour][-1]
|
||||
update = datetime.now().replace(hour=hour, minute=0, second=0, microsecond=0)
|
||||
update = self.get_server_last_update(since)
|
||||
|
||||
logger.attr(f'{option[0]}_{option[1]}', f'Record time: {record}')
|
||||
logger.attr(f'{option[0]}_{option[1]}', f'Last update: {update}')
|
||||
|
@ -128,7 +128,7 @@ class MapOperation(MysteryHandler, FleetPreparation, Retirement, FastForwardHand
|
||||
|
||||
if self.handle_popup_confirm():
|
||||
continue
|
||||
if self.appear_then_click(WITHDRAW, interval=2):
|
||||
if self.appear_then_click(WITHDRAW, interval=5):
|
||||
continue
|
||||
|
||||
# End
|
||||
|
Loading…
Reference in New Issue
Block a user