From 26a321a916ba5fcc6b0a2a80c0f2c2aeeea25248 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Tue, 16 Jun 2020 00:30:50 -0300 Subject: [PATCH] initial commit --- alas.py | 10 +++++++++ dev_tools/relative_crop.py | 4 ++-- module/config/config.py | 1 + module/reward/commission.py | 21 ++++++++--------- module/updater.py | 45 +++++++++++++++++++++++++++++++++++++ version.txt | 0 6 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 module/updater.py create mode 100644 version.txt diff --git a/alas.py b/alas.py index a414019b1..1007ccd27 100644 --- a/alas.py +++ b/alas.py @@ -5,6 +5,7 @@ from datetime import datetime from module.config.config import AzurLaneConfig from module.logger import logger, pyw_name, log_file +from module.updater import Update class AzurLaneAutoScript: @@ -42,26 +43,35 @@ class AzurLaneAutoScript: from module.reward.reward import Reward az = Reward(self.config) 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) if az.app_ensure_start(): diff --git a/dev_tools/relative_crop.py b/dev_tools/relative_crop.py index 02fee4e92..c253eb4f9 100644 --- a/dev_tools/relative_crop.py +++ b/dev_tools/relative_crop.py @@ -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) diff --git a/module/config/config.py b/module/config/config.py index 01636555c..2711dc3e8 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -22,6 +22,7 @@ class AzurLaneConfig: config = configparser.ConfigParser(interpolation=None) start_time = datetime.now() + UPDATE = True SERVER = server.server logger.attr('Server', SERVER) diff --git a/module/reward/commission.py b/module/reward/commission.py index d02218816..b6c9b638a 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -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'] } diff --git a/module/updater.py b/module/updater.py new file mode 100644 index 000000000..8c24b2665 --- /dev/null +++ b/module/updater.py @@ -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 \ No newline at end of file diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..e69de29bb