mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 18:20:42 +00:00
Merge branch 'dev' into master
This commit is contained in:
commit
56d2df66b9
13
alas.py
13
alas.py
@ -5,8 +5,12 @@ from datetime import datetime
|
||||
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.logger import logger, pyw_name, log_file
|
||||
|
||||
from module.device.device import Device
|
||||
|
||||
from module.updater import Update
|
||||
|
||||
|
||||
|
||||
class AzurLaneAutoScript:
|
||||
def __init__(self, ini_name=''):
|
||||
@ -45,26 +49,35 @@ class AzurLaneAutoScript:
|
||||
from module.reward.reward import Reward
|
||||
az = Reward(self.config, device=self.device)
|
||||
az.reward_loop()
|
||||
self.update_check()
|
||||
|
||||
def setting(self):
|
||||
for key, value in self.config.config['Setting'].items():
|
||||
print(f'{key} = {value}')
|
||||
|
||||
logger.hr('Settings saved')
|
||||
self.update_check()
|
||||
self.config.config_check()
|
||||
|
||||
def update_check(self):
|
||||
self.config.UPDATE = Update(self.config)
|
||||
if self.config.UPDATE.check_update():
|
||||
logger.warning('A new update is available, please run updater.bat or check github.')
|
||||
|
||||
def reward(self):
|
||||
for key, value in self.config.config['Reward'].items():
|
||||
print(f'{key} = {value}')
|
||||
|
||||
logger.hr('Reward Settings saved')
|
||||
self.reward_when_finished()
|
||||
self.update_check()
|
||||
|
||||
def emulator(self):
|
||||
for key, value in self.config.config['Emulator'].items():
|
||||
print(f'{key} = {value}')
|
||||
|
||||
logger.hr('Emulator saved')
|
||||
self.update_check()
|
||||
from module.handler.login import LoginHandler
|
||||
az = LoginHandler(self.config, device=self.device)
|
||||
if az.app_ensure_start():
|
||||
|
@ -21,9 +21,9 @@ class Config:
|
||||
cfg = AzurLaneConfig().merge(Config())
|
||||
|
||||
# Folder to save temp images
|
||||
folder = ''
|
||||
folder = './screenshots/temp/'
|
||||
# Put Screenshot here
|
||||
file = ''
|
||||
file = './screenshots/TEMPLATE_AMBUSH_EVADE_FAILED.png'
|
||||
|
||||
i = Image.open(file).convert('RGB')
|
||||
grids = Grids(i, cfg)
|
||||
|
@ -22,6 +22,7 @@ class AzurLaneConfig:
|
||||
config = configparser.ConfigParser(interpolation=None)
|
||||
start_time = datetime.now()
|
||||
|
||||
UPDATE = True
|
||||
SERVER = server.server
|
||||
logger.attr('Server', SERVER)
|
||||
|
||||
|
@ -16,6 +16,7 @@ from module.reward.assets import *
|
||||
from module.ui.page import page_reward, page_commission, CAMPAIGN_CHECK
|
||||
from module.ui.ui import UI
|
||||
|
||||
|
||||
dictionary_cn = {
|
||||
'major_comm': ['自主训练', '对抗演习', '科研任务', '工具整备', '战术课程', '货物运输'],
|
||||
'daily_comm': ['日常资源开发', '高阶战术研发'],
|
||||
@ -33,19 +34,19 @@ dictionary_cn = {
|
||||
'urgent_ship': ['观舰']
|
||||
}
|
||||
dictionary_en = {
|
||||
'major_comm': ['SelfTraining', 'DefenseExercise', 'ResearchMission', 'Prep', 'Class', 'CargoTransport'],
|
||||
'daily_comm': ['Daily', 'Awakening'],
|
||||
'extra_drill': ['Sailing', 'DefensePatrol', 'Buoy', 'saingTraining'],
|
||||
'extra_part': ['Protection', 'Forestprtectioncommisionl', 'veinprotectoncommisionl', 'veinprtectioncommision', 'Forestprotectncommisionll', 'veinprotectncommision'],
|
||||
'extra_cube': ['FleetExercise', 'EscortExercise', 'FleetCargo', 'CombatExercise'],
|
||||
'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll'],
|
||||
'extra_book': ['MerchantEscort'],
|
||||
'urgent_drill': ['CargoDefense', 'Destroy'],
|
||||
'major_comm': ['SelfTraining', 'DefenseExercise', 'ResearchMission', 'Prep', 'Class'],
|
||||
'daily_comm': ['Daily', 'Awakening', 'paily'],
|
||||
'extra_drill': ['Sailing', 'Buoy', 'saingTraining', 'shortrangesailingTraining', 'MidrangesailingTraining', 'FrontierDefensePatrol'],
|
||||
'extra_part': ['Protection', 'Forestprtectioncommisionl', 'veinprotectoncommisionl', 'veinprtectioncommision', 'Forestprotectncommisionll', 'veinprotectncommision', 'Forestprtectoncommisionl', 'Forestprtectioncommisonl', 'veinprotectoncommisonl', 'veinprotecioncommisionl', 'Forestprotectoncommisionll'],
|
||||
'extra_cube': ['FleetExercise', 'EscortExercise', 'FleetCargo', 'CombatExercise', 'FleetCargoTransport'],
|
||||
'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll', 'smalscaleoiExtraction'],
|
||||
'extra_book': ['MerchantEscort', 'SmalIMerchantEscor'],
|
||||
'urgent_drill': ['CargoDefense', 'Destroy', 'CoastalDefensePatrol'],
|
||||
'urgent_part': ['Lavella', 'Maui', 'Rendova', 'banna', 'Mannelsland'],
|
||||
'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'],
|
||||
'urgent_box': ['Gear', 'Handover'],
|
||||
'urgent_cube': ['MerchantRescue', 'Attack'],
|
||||
'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort'],
|
||||
'urgent_cube': ['MerchantRescue', 'Attack', 'EnemyAtack'],
|
||||
'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort'],
|
||||
'urgent_ship': ['Launch']
|
||||
}
|
||||
|
||||
|
45
module/updater.py
Normal file
45
module/updater.py
Normal file
@ -0,0 +1,45 @@
|
||||
from urllib import error, request
|
||||
from module.logger import logger
|
||||
from module.config.config import AzurLaneConfig
|
||||
|
||||
class Update(object):
|
||||
|
||||
def __init__(self, config):
|
||||
"""
|
||||
Args:
|
||||
config(AzurLaneConfig):
|
||||
"""
|
||||
self.config = config
|
||||
|
||||
def check_update(self):
|
||||
version = ''
|
||||
latest_version = ''
|
||||
_file = open('version.txt', 'r')
|
||||
|
||||
if self.config.UPDATE:
|
||||
version = _file.readline()
|
||||
|
||||
try:
|
||||
with request.urlopen("https://raw.githubusercontent.com/whoamikyo/AzurLaneAutoScript/master/version.txt") as f:
|
||||
_f = f.read().decode('utf-8')
|
||||
latest_version = _f.splitlines()[1]
|
||||
except error.HTTPError as e:
|
||||
logger.info("Couldn't check for updates, {}.".format(e))
|
||||
|
||||
else:
|
||||
version = _file.readlines()[1]
|
||||
|
||||
try:
|
||||
with request.urlopen("https://raw.githubusercontent.com/whoamikyo/AzurLaneAutoScript/master/version.txt") as f:
|
||||
_f = f.read().decode('utf-8')
|
||||
latest_version = _f.splitlines()[1]
|
||||
except error.HTTPError as e:
|
||||
logger.info("Couldn't check for updates, {}.".format(e))
|
||||
|
||||
_file.close()
|
||||
|
||||
if version != latest_version:
|
||||
logger.info("Current version: " + version)
|
||||
logger.info("Latest version: " + latest_version)
|
||||
|
||||
return True
|
Loading…
Reference in New Issue
Block a user