mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 09:01:45 +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.
|
string (str): Such as 14:59.
|
||||||
|
|
||||||
Returns:
|
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(':')]
|
hour, minute = [int(x) for x in string.split(':')]
|
||||||
future = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
|
future = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
|
||||||
@ -31,6 +31,20 @@ def future_time(string):
|
|||||||
return future
|
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):
|
def future_time_range(string):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
|
@ -107,8 +107,7 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
|
|||||||
Returns:
|
Returns:
|
||||||
bool: If triggered a restart condition.
|
bool: If triggered a restart condition.
|
||||||
"""
|
"""
|
||||||
now = datetime.now()
|
if self.config.get_server_last_update(since=(0,)) > self.start_time:
|
||||||
if now.date() != self.start_time.date():
|
|
||||||
logger.hr('Triggered restart new day')
|
logger.hr('Triggered restart new day')
|
||||||
return True
|
return True
|
||||||
if not self.campaign.config.IGNORE_LOW_EMOTION_WARN:
|
if not self.campaign.config.IGNORE_LOW_EMOTION_WARN:
|
||||||
|
@ -2,15 +2,16 @@ import codecs
|
|||||||
import configparser
|
import configparser
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
|
from datetime import timezone
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
import module.config.server as server
|
||||||
from module.base.timer import *
|
from module.base.timer import *
|
||||||
from module.config.dictionary import *
|
from module.config.dictionary import *
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
import module.config.server as server
|
|
||||||
|
|
||||||
|
|
||||||
class AzurLaneConfig:
|
class AzurLaneConfig:
|
||||||
@ -520,6 +521,30 @@ class AzurLaneConfig:
|
|||||||
self.C124_NON_S3_WITHDRAW_TOLERANCE = int(option['non_s3_enemy_withdraw_tolerance'])
|
self.C124_NON_S3_WITHDRAW_TOLERANCE = int(option['non_s3_enemy_withdraw_tolerance'])
|
||||||
self.C124_AMMO_PICK_UP = int(option['ammo_pick_up_124'])
|
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):
|
def record_executed_since(self, option, since):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
@ -530,10 +555,7 @@ class AzurLaneConfig:
|
|||||||
bool: If got a record after last game update.
|
bool: If got a record after last game update.
|
||||||
"""
|
"""
|
||||||
record = datetime.strptime(self.config.get(*option), self.TIME_FORMAT)
|
record = datetime.strptime(self.config.get(*option), self.TIME_FORMAT)
|
||||||
since = np.array(since)
|
update = self.get_server_last_update(since)
|
||||||
|
|
||||||
hour = since[since <= datetime.now().hour][-1]
|
|
||||||
update = datetime.now().replace(hour=hour, minute=0, second=0, microsecond=0)
|
|
||||||
|
|
||||||
logger.attr(f'{option[0]}_{option[1]}', f'Record time: {record}')
|
logger.attr(f'{option[0]}_{option[1]}', f'Record time: {record}')
|
||||||
logger.attr(f'{option[0]}_{option[1]}', f'Last update: {update}')
|
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():
|
if self.handle_popup_confirm():
|
||||||
continue
|
continue
|
||||||
if self.appear_then_click(WITHDRAW, interval=2):
|
if self.appear_then_click(WITHDRAW, interval=5):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# End
|
# End
|
||||||
|
Loading…
Reference in New Issue
Block a user