initial commit

This commit is contained in:
whoamikyo 2020-06-16 00:30:50 -03:00
parent 1e55c25f49
commit 26a321a916
6 changed files with 69 additions and 12 deletions

10
alas.py
View File

@ -5,6 +5,7 @@ from datetime import datetime
from module.config.config import AzurLaneConfig from module.config.config import AzurLaneConfig
from module.logger import logger, pyw_name, log_file from module.logger import logger, pyw_name, log_file
from module.updater import Update
class AzurLaneAutoScript: class AzurLaneAutoScript:
@ -42,26 +43,35 @@ class AzurLaneAutoScript:
from module.reward.reward import Reward from module.reward.reward import Reward
az = Reward(self.config) az = Reward(self.config)
az.reward_loop() az.reward_loop()
self.update_check()
def setting(self): def setting(self):
for key, value in self.config.config['Setting'].items(): for key, value in self.config.config['Setting'].items():
print(f'{key} = {value}') print(f'{key} = {value}')
logger.hr('Settings saved') logger.hr('Settings saved')
self.update_check()
self.config.config_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): def reward(self):
for key, value in self.config.config['Reward'].items(): for key, value in self.config.config['Reward'].items():
print(f'{key} = {value}') print(f'{key} = {value}')
logger.hr('Reward Settings saved') logger.hr('Reward Settings saved')
self.reward_when_finished() self.reward_when_finished()
self.update_check()
def emulator(self): def emulator(self):
for key, value in self.config.config['Emulator'].items(): for key, value in self.config.config['Emulator'].items():
print(f'{key} = {value}') print(f'{key} = {value}')
logger.hr('Emulator saved') logger.hr('Emulator saved')
self.update_check()
from module.handler.login import LoginHandler from module.handler.login import LoginHandler
az = LoginHandler(self.config) az = LoginHandler(self.config)
if az.app_ensure_start(): if az.app_ensure_start():

View File

@ -21,9 +21,9 @@ class Config:
cfg = AzurLaneConfig().merge(Config()) cfg = AzurLaneConfig().merge(Config())
# Folder to save temp images # Folder to save temp images
folder = '' folder = './screenshots/temp/'
# Put Screenshot here # Put Screenshot here
file = '' file = './screenshots/TEMPLATE_AMBUSH_EVADE_FAILED.png'
i = Image.open(file).convert('RGB') i = Image.open(file).convert('RGB')
grids = Grids(i, cfg) grids = Grids(i, cfg)

View File

@ -22,6 +22,7 @@ class AzurLaneConfig:
config = configparser.ConfigParser(interpolation=None) config = configparser.ConfigParser(interpolation=None)
start_time = datetime.now() start_time = datetime.now()
UPDATE = True
SERVER = server.server SERVER = server.server
logger.attr('Server', SERVER) logger.attr('Server', SERVER)

View File

@ -16,6 +16,7 @@ from module.reward.assets import *
from module.ui.page import page_reward, page_commission, CAMPAIGN_CHECK from module.ui.page import page_reward, page_commission, CAMPAIGN_CHECK
from module.ui.ui import UI from module.ui.ui import UI
dictionary_cn = { dictionary_cn = {
'major_comm': ['自主训练', '对抗演习', '科研任务', '工具整备', '战术课程', '货物运输'], 'major_comm': ['自主训练', '对抗演习', '科研任务', '工具整备', '战术课程', '货物运输'],
'daily_comm': ['日常资源开发', '高阶战术研发'], 'daily_comm': ['日常资源开发', '高阶战术研发'],
@ -33,19 +34,19 @@ dictionary_cn = {
'urgent_ship': ['观舰'] 'urgent_ship': ['观舰']
} }
dictionary_en = { dictionary_en = {
'major_comm': ['SelfTraining', 'DefenseExercise', 'ResearchMission', 'Prep', 'Class', 'CargoTransport'], 'major_comm': ['SelfTraining', 'DefenseExercise', 'ResearchMission', 'Prep', 'Class'],
'daily_comm': ['Daily', 'Awakening'], 'daily_comm': ['Daily', 'Awakening', 'paily'],
'extra_drill': ['Sailing', 'DefensePatrol', 'Buoy', 'saingTraining'], 'extra_drill': ['Sailing', 'Buoy', 'saingTraining', 'shortrangesailingTraining', 'MidrangesailingTraining', 'FrontierDefensePatrol'],
'extra_part': ['Protection', 'Forestprtectioncommisionl', 'veinprotectoncommisionl', 'veinprtectioncommision', 'Forestprotectncommisionll', 'veinprotectncommision'], 'extra_part': ['Protection', 'Forestprtectioncommisionl', 'veinprotectoncommisionl', 'veinprtectioncommision', 'Forestprotectncommisionll', 'veinprotectncommision', 'Forestprtectoncommisionl', 'Forestprtectioncommisonl', 'veinprotectoncommisonl', 'veinprotecioncommisionl', 'Forestprotectoncommisionll'],
'extra_cube': ['FleetExercise', 'EscortExercise', 'FleetCargo', 'CombatExercise'], 'extra_cube': ['FleetExercise', 'EscortExercise', 'FleetCargo', 'CombatExercise', 'FleetCargoTransport'],
'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll'], 'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll', 'smalscaleoiExtraction'],
'extra_book': ['MerchantEscort'], 'extra_book': ['MerchantEscort', 'SmalIMerchantEscor'],
'urgent_drill': ['CargoDefense', 'Destroy'], 'urgent_drill': ['CargoDefense', 'Destroy', 'CoastalDefensePatrol'],
'urgent_part': ['Lavella', 'Maui', 'Rendova', 'banna', 'Mannelsland'], 'urgent_part': ['Lavella', 'Maui', 'Rendova', 'banna', 'Mannelsland'],
'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'], 'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'],
'urgent_box': ['Gear', 'Handover'], 'urgent_box': ['Gear', 'Handover'],
'urgent_cube': ['MerchantRescue', 'Attack'], 'urgent_cube': ['MerchantRescue', 'Attack', 'EnemyAtack'],
'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort'], 'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort'],
'urgent_ship': ['Launch'] 'urgent_ship': ['Launch']
} }

45
module/updater.py Normal file
View 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

0
version.txt Normal file
View File