mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 17:11:42 +00:00
87554793d3
- 修复了上一场战斗的队伍位置信息会保留到下一场战斗的问题 - 修复了领取大量任务时, 不会等待的问题 - 修复了不计算BOSS队心情消耗的问题 - 增加了碰磁BOSS所有刷新点的方法 - 修复了没有检测到BOSS时停滞的问题 - 修复了处理夜间委托 - 修复了丢失地图信息补全不起作用的问题 - 修复了换装滑动失败后, 陷入死循环的问题 - 删除了微层混合AB图的一些多余逻辑 - 7-2现在会优先捡全部问号了, 不需要先捡附近的来减少行走距离.
107 lines
3.5 KiB
Python
107 lines
3.5 KiB
Python
from datetime import datetime
|
|
from time import sleep
|
|
|
|
from module.config.config import AzurLaneConfig
|
|
from module.logger import logger
|
|
|
|
config_name = 'EmotionRecord'
|
|
|
|
|
|
class Emotion:
|
|
def __init__(self, config):
|
|
"""
|
|
Args:
|
|
config (AzurLaneConfig):
|
|
"""
|
|
self.config = config
|
|
self.emotion = self.config.config
|
|
# self.load()
|
|
self.update()
|
|
self.record()
|
|
|
|
# def load(self):
|
|
# logger.hr('Emotion load')
|
|
# self.emotion.read_file(codecs.open(self.config.EMOTION_LOG, "r", "utf8"))
|
|
# self.update()
|
|
|
|
def record(self):
|
|
for index in [1, 2, 3]:
|
|
logger.attr(f'Emotion fleet_{index}', self.emotion[config_name][f'fleet_{index}_emotion'])
|
|
# self.emotion.write(codecs.open(self.config.CONFIG_FILE, "w+", "utf8"))
|
|
self.config.save()
|
|
|
|
def recover_value(self, index):
|
|
return self.config.__getattribute__('FLEET_%s_RECOVER_PER_HOUR' % index) // 10
|
|
|
|
def emotion_limit(self, index):
|
|
return self.config.__getattribute__('FLEET_%s_EMOTION_LIMIT' % index)
|
|
|
|
def recover_stop(self, index):
|
|
return 150 if self.recover_value(index) > 3 else 119
|
|
|
|
def update(self):
|
|
for index in [1, 2, 3]:
|
|
savetime = datetime.strptime(self.emotion[config_name][f'fleet_{index}_savetime'], self.config.TIME_FORMAT)
|
|
savetime = int(savetime.timestamp())
|
|
recover_count = int(datetime.now().timestamp() // 360 - savetime // 360)
|
|
|
|
value = self.emotion.getint(config_name, f'fleet_{index}_emotion')
|
|
|
|
value += self.recover_value(index=index) * recover_count
|
|
if value > self.recover_stop(index=index):
|
|
value = self.recover_stop(index)
|
|
self.emotion[config_name][f'fleet_{index}_emotion'] = str(value)
|
|
self.emotion[config_name][f'fleet_{index}_savetime'] = str(
|
|
datetime.strftime(datetime.now(), self.config.TIME_FORMAT))
|
|
|
|
def reduce(self, index):
|
|
logger.hr('Emotion reduce')
|
|
self.update()
|
|
self.emotion[config_name][f'fleet_{index}_emotion'] = str(int(
|
|
self.emotion[config_name][f'fleet_{index}_emotion']) - 2)
|
|
self.record()
|
|
|
|
def recovered_time(self, fleet=(1, 2)):
|
|
"""
|
|
Args:
|
|
fleet (int, tuple):
|
|
"""
|
|
if isinstance(fleet, int):
|
|
fleet = (fleet,)
|
|
recover_count = [
|
|
(self.emotion_limit(index) - int(self.emotion[config_name][f'fleet_{index}_emotion'])) \
|
|
// self.recover_value(index) for index in fleet]
|
|
recover_count = max(recover_count)
|
|
recover_timestamp = datetime.now().timestamp() // 360 + recover_count + 1
|
|
return datetime.fromtimestamp(recover_timestamp * 360)
|
|
|
|
def emotion_triggered(self, fleet):
|
|
"""
|
|
Args:
|
|
fleet (int, list):
|
|
|
|
Returns:
|
|
bool:
|
|
"""
|
|
if not isinstance(fleet, list):
|
|
fleet = [fleet]
|
|
return datetime.now() > self.recovered_time(fleet=fleet)
|
|
|
|
def emotion_recovered(self, fleet):
|
|
pass
|
|
|
|
def wait(self, fleet=(1, 2)):
|
|
"""
|
|
Args:
|
|
fleet (int, tuple):
|
|
"""
|
|
self.update()
|
|
recovered_time = self.recovered_time(fleet=fleet)
|
|
while 1:
|
|
if datetime.now() > recovered_time:
|
|
break
|
|
|
|
logger.attr('Emotion recovered', recovered_time)
|
|
self.config.EMOTION_LIMIT_TRIGGERED = True
|
|
sleep(60)
|