From aadfb2e00b45a551bad318d3e9e753a483014a39 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 00:45:48 -0300 Subject: [PATCH 01/18] Fix: [EN] Some tweaks on commission dictionary --- module/reward/commission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/reward/commission.py b/module/reward/commission.py index b6c9b638a..86b2e5a02 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -37,7 +37,7 @@ dictionary_en = { '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_part': ['Protection', 'Forestpr', 'veinprot', 'veinprtectioncommision'], 'extra_cube': ['FleetExercise', 'EscortExercise', 'FleetCargo', 'CombatExercise', 'FleetCargoTransport'], 'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll', 'smalscaleoiExtraction'], 'extra_book': ['MerchantEscort', 'SmalIMerchantEscor'], From 60ee098be3426cba383de814b62d78b702f870c6 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 02:08:23 -0300 Subject: [PATCH 02/18] Tweak: updater.bar merged into Easy_install-V2.bat --- Easy_Install-V2.bat | 36 ++++++++++++++++++++----- campaign/event_20200611_en/d3.py | 46 ++++++++++++++++++++++++++------ updater.bat | 23 ---------------- 3 files changed, 67 insertions(+), 38 deletions(-) delete mode 100644 updater.bat diff --git a/Easy_Install-V2.bat b/Easy_Install-V2.bat index f8f913cea..96b897ed7 100644 --- a/Easy_Install-V2.bat +++ b/Easy_Install-V2.bat @@ -33,6 +33,7 @@ goto menu echo 1. Essentials programs echo 2. Clone repository echo 3. Python 3.7.6 + requirements.txt + echo 4. Updater Only echo. echo Install in order echo. @@ -44,6 +45,7 @@ goto menu if %menu%==1 GOTO programs if %menu%==2 GOTO clone if %menu%==3 GOTO python + if %menu%==4 GOTO updater if %menu%==exit GOTO EOF else ( @@ -88,6 +90,16 @@ cls @powershell -NoProfile -ExecutionPolicy Bypass -Command "choco install -y --force --allow-empty-checksums adb git" +:: timout +PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 +:: killing adb server +call adb kill-server > nul 2>&1 + +goto menu + +:clone +echo Cloning repository +git clone https://github.com/LmeSzinc/AzurLaneAutoScript.git goto menu @@ -114,12 +126,22 @@ if not exist %ROOT% ( goto menu -:clone -echo Cloning repository -git clone https://github.com/LmeSzinc/AzurLaneAutoScript.git -:: timout -PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 -:: killing adb server -call adb kill-server > nul 2>&1 +:updater +ECHO. +ECHO 1. https://github.com/LmeSzinc/AzurLaneAutoScript (Main Repo, When in doubt, use it) +ECHO 2. https://github.com/whoamikyo/AzurLaneAutoScript (Fork) +set choice= +set /p choice=Choose the repository you want to use. +if not '%choice%'=='' set choice=%choice:~0,1% +if '%choice%'=='1' goto LmeSzinc +if '%choice%'=='2' goto whoamikyo +ECHO "%choice%" is not valid, try again +ECHO. +goto start +:LmeSzinc +git pull https://github.com/LmeSzinc/AzurLaneAutoScript.git +goto end +:whoamikyo +git pull https://github.com/whoamikyo/AzurLaneAutoScript.git goto menu \ No newline at end of file diff --git a/campaign/event_20200611_en/d3.py b/campaign/event_20200611_en/d3.py index 26968be89..6471388e0 100644 --- a/campaign/event_20200611_en/d3.py +++ b/campaign/event_20200611_en/d3.py @@ -5,7 +5,8 @@ from module.logger import logger from campaign.event_20200611_en.d1 import Config as ConfigBase -MAP = CampaignMap() +MAP = CampaignMap('d3') +MAP.shape = 'N10' MAP.map_data = """ -- -- -- -- -- ME -- -- ME -- -- -- -- ++ -- -- -- ME -- -- MB MB -- -- ME -- -- -- @@ -62,13 +63,30 @@ MAP.spawn_data = [ {'battle': 6, 'boss': 1}, ] +A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1, M1, N1, \ +A2, B2, C2, D2, E2, F2, G2, H2, I2, J2, K2, L2, M2, N2, \ +A3, B3, C3, D3, E3, F3, G3, H3, I3, J3, K3, L3, M3, N3, \ +A4, B4, C4, D4, E4, F4, G4, H4, I4, J4, K4, L4, M4, N4, \ +A5, B5, C5, D5, E5, F5, G5, H5, I5, J5, K5, L5, M5, N5, \ +A6, B6, C6, D6, E6, F6, G6, H6, I6, J6, K6, L6, M6, N6, \ +A7, B7, C7, D7, E7, F7, G7, H7, I7, J7, K7, L7, M7, N7, \ +A8, B8, C8, D8, E8, F8, G8, H8, I8, J8, K8, L8, M8, N8, \ +A9, B9, C9, D9, E9, F9, G9, H9, I9, J9, K9, L9, M9, N9, \ +A10, B10, C10, D10, E10, F10, G10, H10, I10, J10, K10, L10, M10, N910, \ + = MAP.flatten() + +ROAD_MAIN = RoadGrids([[D4, E3], [J5 ,K4, J3]]) class Config(ConfigBase): MAP_HAS_WALL = True MAP_SIREN_COUNT = 3 MAP_SIREN_TEMPLATE = ['LaGalissonniere', 'Vauquelin'] - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 50 + EDGE_LINES_HOUGHLINES_THRESHOLD = 50 + + TRUST_EDGE_LINES = False # True to use edge to crop inner, false to use inner to crop edge + class Campaign(CampaignBase): @@ -77,22 +95,34 @@ class Campaign(CampaignBase): def battle_0(self): if self.clear_siren(): return True - if self.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): + if self.fleet_2.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): return True - if self.clear_enemy(scale=(3,), genre=['light', 'main', 'enemy', 'carrier']): + if self.fleet_2.clear_enemy(scale=(3,), genre=['light', 'main', 'enemy', 'carrier']): return True return self.battle_default() + def battle_4(self): + if self.clear_roadblocks([ROAD_MAIN]): + return True + if self.clear_potential_roadblocks([ROAD_MAIN]): + return True + if self.fleet_1.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): + return True + if self.fleet_1.clear_enemy(scale=(3,), genre=['light', 'main', 'enemy', 'carrier']): + return True + def battle_5(self): - if self.clear_enemy(scale=(1,)): + if self.clear_siren(): return True - if self.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): + if self.clear_potential_roadblocks([ROAD_MAIN]): return True - if self.clear_enemy(genre=['light', 'main']): + if self.fleet_1.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): + return True + if self.fleet_1.clear_enemy(scale=(3,), genre=['light', 'main', 'enemy', 'carrier']): return True return self.battle_default() def battle_6(self): - return self.fleet_2.brute_clear_boss() + return self.fleet_1.brute_clear_boss() diff --git a/updater.bat b/updater.bat deleted file mode 100644 index 166b460d3..000000000 --- a/updater.bat +++ /dev/null @@ -1,23 +0,0 @@ -@ECHO off -set PATH=%PATH%;%PROGRAMFILES%\Git\cmd -cls -:start -ECHO. -ECHO 1. https://github.com/LmeSzinc/AzurLaneAutoScript -ECHO 2. https://github.com/whoamikyo/AzurLaneAutoScript -set choice= -set /p choice=Choose the repository you want to use. -if not '%choice%'=='' set choice=%choice:~0,1% -if '%choice%'=='1' goto LmeSzinc -if '%choice%'=='2' goto whoamikyo -ECHO "%choice%" is not valid, try again -ECHO. -goto start -:LmeSzinc -git pull https://github.com/LmeSzinc/AzurLaneAutoScript.git -goto end -:whoamikyo -git pull https://github.com/whoamikyo/AzurLaneAutoScript.git -goto end -:end -pause \ No newline at end of file From 7cba96dffb2face431bc62bb4d437ea11de2799a Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 02:09:03 -0300 Subject: [PATCH 03/18] Create version.txt --- version.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 version.txt diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..e69de29bb From 63c16596b9e031d773205cb881181934b582e585 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 03:07:32 -0300 Subject: [PATCH 04/18] Update: made some improvements on Easy_Install-V2 --- Easy_Install-V2.bat | 56 +++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/Easy_Install-V2.bat b/Easy_Install-V2.bat index 96b897ed7..d709e4600 100644 --- a/Easy_Install-V2.bat +++ b/Easy_Install-V2.bat @@ -54,7 +54,7 @@ goto menu echo :: Incorrect Input Entered echo. echo Please type a 'number' or 'exit' - echo Press any key to retrn to the menu... + echo Press any key to return to the menu... echo. pause > NUL goto menu @@ -127,21 +127,43 @@ if not exist %ROOT% ( goto menu :updater -ECHO. -ECHO 1. https://github.com/LmeSzinc/AzurLaneAutoScript (Main Repo, When in doubt, use it) -ECHO 2. https://github.com/whoamikyo/AzurLaneAutoScript (Fork) -set choice= -set /p choice=Choose the repository you want to use. -if not '%choice%'=='' set choice=%choice:~0,1% -if '%choice%'=='1' goto LmeSzinc -if '%choice%'=='2' goto whoamikyo -ECHO "%choice%" is not valid, try again -ECHO. -goto start -:LmeSzinc -git pull https://github.com/LmeSzinc/AzurLaneAutoScript.git -goto end -:whoamikyo -git pull https://github.com/whoamikyo/AzurLaneAutoScript.git + cls + echo. + echo :: Only update + echo. + echo 1. https://github.com/LmeSzinc/AzurLaneAutoScript (Main Repo, When in doubt, use it) + echo 2. https://github.com/whoamikyo/AzurLaneAutoScript (Fork) + echo. + echo. + echo :: Type a 'number' and press ENTER + echo :: Type 'exit' to quit + echo. + + set /P choice=Choose the repository you want to use. + if %choice%==1 GOTO LmeSzinc + if %choice%==2 GOTO whoamikyo + if %menu%==exit GOTO EOF + + else ( + cls + echo. + echo :: Incorrect Input Entered + echo. + echo Please type a 'number' or 'exit' + echo Press any key to return to the menu... + echo. + pause > NUL + goto updater + ) + +:LmeSzinc +git pull --ff-only https://github.com/LmeSzinc/AzurLaneAutoScript.git +:: timout +PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 +goto menu +:whoamikyo +git pull --ff-only https://github.com/whoamikyo/AzurLaneAutoScript.git +:: timout +PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 goto menu \ No newline at end of file From edc3a936d405004e0e6426ccf08fa54fd529b6d8 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 03:31:03 -0300 Subject: [PATCH 05/18] Fix: [EN] fix commission filter --- module/reward/commission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/reward/commission.py b/module/reward/commission.py index 86b2e5a02..eb93cdd85 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -46,7 +46,7 @@ dictionary_en = { 'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'], 'urgent_box': ['Gear', 'Handover'], 'urgent_cube': ['MerchantRescue', 'Attack', 'EnemyAtack'], - 'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort'], + 'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort', 'BIWPatro'], 'urgent_ship': ['Launch'] } From 7a431f90a8d2168ab34bdc5c8b836525bca63d5a Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 05:29:39 -0300 Subject: [PATCH 06/18] Enhancement: Made major enhancements on Easy_Install-V2.bat --- Easy_Install-V2.bat | 33 +++++++++++++++++++++++---------- module/reward/commission.py | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Easy_Install-V2.bat b/Easy_Install-V2.bat index d709e4600..ad52ddd20 100644 --- a/Easy_Install-V2.bat +++ b/Easy_Install-V2.bat @@ -99,7 +99,7 @@ goto menu :clone echo Cloning repository -git clone https://github.com/LmeSzinc/AzurLaneAutoScript.git +git clone https://github.com/LmeSzinc/AzurLaneAutoScript.git && cd AzurLaneAutoScript && git remote add whoamikyo https://github.com/whoamikyo/AzurLaneAutoScript.git goto menu @@ -129,20 +129,28 @@ goto menu :updater cls echo. - echo :: Only update + echo :: This update only will work if you downloaded ALAS with this file using option 2. clone + echo. + echo ::DISCLAIMER + echo IF YOU GET THE FOLLOWING ERROR: + echo "error: Your local changes to the following files would be overwritten by merge:Easy_Install-V2.bat" + echo YOU NEED RE-DOWNLOAD ONLY Easy_Install-V2.bat FILE FROM REPOSITORY AND OVERWRITTEN THE OLD FOR NEW FILE echo. echo 1. https://github.com/LmeSzinc/AzurLaneAutoScript (Main Repo, When in doubt, use it) - echo 2. https://github.com/whoamikyo/AzurLaneAutoScript (Fork) - echo. + echo 2. https://github.com/whoamikyo/AzurLaneAutoScript (Mirrored Fork) + echo 3. https://github.com/whoamikyo/AzurLaneAutoScript (nightly build, dont use) + echo 4. Back to main menu echo. echo :: Type a 'number' and press ENTER echo :: Type 'exit' to quit echo. - set /P choice=Choose the repository you want to use. + set /P choice= if %choice%==1 GOTO LmeSzinc if %choice%==2 GOTO whoamikyo - if %menu%==exit GOTO EOF + if %choice%==3 GOTO nightly + if %choice%==4 GOTO menu + if %choice%==exit GOTO EOF else ( cls @@ -158,12 +166,17 @@ goto menu :LmeSzinc -git pull --ff-only https://github.com/LmeSzinc/AzurLaneAutoScript.git +git fetch origin master && git reset --hard origin/master && git pull --ff-only origin master :: timout PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 -goto menu +goto updater :whoamikyo -git pull --ff-only https://github.com/whoamikyo/AzurLaneAutoScript.git +git fetch whoamikyo master && git reset --hard whoamikyo/master && git pull --ff-only whoamikyo master :: timout PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 -goto menu \ No newline at end of file +goto updater +:nightly +git fetch whoamikyo nightly && git reset --hard whoamikyo/nightly && git pull --ff-only whoamikyo nightly +:: timout +PowerShell -Command "Start-Sleep -s 10" > nul 2>&1 +goto updater \ No newline at end of file diff --git a/module/reward/commission.py b/module/reward/commission.py index eb93cdd85..7d3e7e92f 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -42,7 +42,7 @@ dictionary_en = { 'extra_oil': ['oil', 'smallscaleoiExtractionll', 'smal.scaleoiExtractionll', 'smalscaleoiExtraction'], 'extra_book': ['MerchantEscort', 'SmalIMerchantEscor'], 'urgent_drill': ['CargoDefense', 'Destroy', 'CoastalDefensePatrol'], - 'urgent_part': ['Lavella', 'Maui', 'Rendova', 'banna', 'Mannelsland'], + 'urgent_part': ['Lavella', 'Maui', 'Rendova', 'banna', 'Mannelsland', 'AidingMamne'], 'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'], 'urgent_box': ['Gear', 'Handover'], 'urgent_cube': ['MerchantRescue', 'Attack', 'EnemyAtack'], From 5efc957abb42e92f60443cc2ac1689ff55e4e2a3 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 05:34:40 -0300 Subject: [PATCH 07/18] Add: Added option to enable or disable some exceptions -ALAS will withdraw from the map when it occurs instead of stopping --- config/template.ini | 1 + module/campaign/campaign_base.py | 8 ++++++-- module/config/argparser.py | 1 + module/config/argparser_en.py | 1 + module/config/argparser_jp.py | 1 + module/config/config.py | 2 ++ module/config/dictionary.py | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/template.ini b/config/template.ini index 96f7aa012..7c8f6d958 100644 --- a/config/template.ini +++ b/config/template.ini @@ -3,6 +3,7 @@ command = Daily [Setting] enable_stop_condition = yes +enable_exception = yes enable_fast_forward = yes if_count_greater_than = 0 if_time_reach = 0 diff --git a/module/campaign/campaign_base.py b/module/campaign/campaign_base.py index 2cff764fa..8fcf0ae5c 100644 --- a/module/campaign/campaign_base.py +++ b/module/campaign/campaign_base.py @@ -87,8 +87,12 @@ class CampaignBase(Map): result = func() if not result: - logger.warning('No combat executed.') - raise ScriptError('No combat executed.') + logger.warning('ScriptError, No combat executed.') + if self.config.ENABLE_EXCEPTION: + raise ScriptError('No combat executed.') + else: + logger.warning('ScriptError, Withdrawing because enable_exception = no') + self.withdraw() return result diff --git a/module/config/argparser.py b/module/config/argparser.py index d31dc9e43..4c0ea777d 100644 --- a/module/config/argparser.py +++ b/module/config/argparser.py @@ -125,6 +125,7 @@ def main(ini_name=''): # 选择关卡 stage = setting_parser.add_argument_group('关卡设置', '需要运行一次来保存选项') stage.add_argument('--启用停止条件', default=default('--启用停止条件'), choices=['是', '否']) + stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'],help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping') stage.add_argument('--使用周回模式', default=default('--使用周回模式'), choices=['是', '否']) stop = stage.add_argument_group('停止条件', '触发后不会马上停止会先完成当前出击, 不需要就填0') diff --git a/module/config/argparser_en.py b/module/config/argparser_en.py index bf4970262..68b3fdb3b 100644 --- a/module/config/argparser_en.py +++ b/module/config/argparser_en.py @@ -123,6 +123,7 @@ def main(ini_name=''): # 选择关卡 stage = setting_parser.add_argument_group('Level settings', 'Need to Press start to save your settings.') stage.add_argument('--enable_stop_condition', default=default('--enable_stop_condition'), choices=['yes', 'no']) + stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'], help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping') stage.add_argument('--enable_fast_forward', default=default('--enable_fast_forward'), choices=['yes', 'no'], help='Enable or disable clearing mode') stop = stage.add_argument_group('Stop condition', 'After triggering, it will not stop immediately. It will complete the current attack first, and fill in 0 if it is not needed.') diff --git a/module/config/argparser_jp.py b/module/config/argparser_jp.py index 6483a62e8..8de9dafd3 100644 --- a/module/config/argparser_jp.py +++ b/module/config/argparser_jp.py @@ -119,6 +119,7 @@ def main(ini_name=''): # 选择关卡 stage = setting_parser.add_argument_group('Level settings', 'Need to run once to save options') stage.add_argument('--enable_stop_condition', default=default('--enable_stop_condition'), choices=['yes', 'no']) + stage.add_argument('--enable_exception', default=default('--enable_exception'), choices=['yes', 'no'],help='Enable or disable some exceptions, ALAS will withdraw from the map when it occurs instead of stopping') stage.add_argument('--enable_fast_forward', default=default('--enable_fast_forward'), choices=['yes', 'no']) stop = stage.add_argument_group('Stop condition', 'After triggering, it will not stop immediately. It will complete the current attack first, and fill in 0 if it is not needed.') diff --git a/module/config/config.py b/module/config/config.py index 7f4e0cb42..923d81076 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -113,6 +113,7 @@ class AzurLaneConfig: CAMPAIGN_MODE = 'normal' ENABLE_STOP_CONDITION = True + ENABLE_EXCEPTION = True ENABLE_FAST_FORWARD = True STOP_IF_OIL_LOWER_THAN = 5000 STOP_IF_COUNT_GREATER_THAN = 0 @@ -418,6 +419,7 @@ class AzurLaneConfig: option = config['Setting'] # Stop condition self.ENABLE_STOP_CONDITION = to_bool(option['enable_stop_condition']) + self.ENABLE_EXCEPTION = to_bool(option['enable_exception']) self.ENABLE_FAST_FORWARD = to_bool(option['enable_fast_forward']) self.STOP_IF_COUNT_GREATER_THAN = int(option['if_count_greater_than']) if not option['if_time_reach'].isdigit(): diff --git a/module/config/dictionary.py b/module/config/dictionary.py index fda75f0bc..15a8a09f5 100644 --- a/module/config/dictionary.py +++ b/module/config/dictionary.py @@ -38,6 +38,7 @@ dic_true_eng_to_eng = { # Argument 'enable_stop_condition': 'enable_stop_condition', + 'enable_exception': 'enable_exception', 'enable_fast_forward': 'enable_fast_forward', 'if_count_greater_than': 'if_count_greater_than', 'if_time_reach': 'if_time_reach', From 3f06c55f6c2783eaa43adc7f4704c080d8d24a5e Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 05:35:26 -0300 Subject: [PATCH 08/18] Added: 13-4 map with basic optimization --- campaign/campaign_main/campaign_13_4.py | 88 +++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 campaign/campaign_main/campaign_13_4.py diff --git a/campaign/campaign_main/campaign_13_4.py b/campaign/campaign_main/campaign_13_4.py new file mode 100644 index 000000000..052715ebf --- /dev/null +++ b/campaign/campaign_main/campaign_13_4.py @@ -0,0 +1,88 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger + +MAP = CampaignMap('13-4') +MAP.shape = 'K8' +MAP.map_data = ''' + MB ME ME -- ME ++ ++ ++ MB MB ++ + MB -- ME ME ME -- -- MA -- ME ++ + ME -- -- ME ME -- ME ME -- ME ME + ++ SP -- ME ++ ME -- -- -- -- ME + ++ SP ME -- ME -- -- ME ++ ++ -- + ++ -- -- -- ME -- ME ME ++ ++ ME + ME ME ME -- -- -- ME -- -- ME -- + -- ME ME ME -- -- ++ ++ -- ME -- +''' +# MAP.weight_data = ''' +# 10 30 30 10 10 10 10 10 10 +# 5 30 10 30 10 10 5 10 10 +# 10 10 5 4 30 10 5 30 10 +# 10 10 10 10 10 10 5 10 30 +# 10 10 10 10 10 10 10 30 10 +# 10 10 10 10 30 10 5 10 10 +# ''' + +MAP.spawn_data = [ + {'battle': 0, 'enemy': 3}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 2}, + {'battle': 3, 'enemy': 1}, + {'battle': 4, 'enemy': 1}, + {'battle': 5, 'enemy': 1}, + {'battle': 6,}, + {'battle': 7, 'boss': 1}, + ] + +A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, \ +A2, B2, C2, D2, E2, F2, G2, H2, I2, J2, K2, \ +A3, B3, C3, D3, E3, F3, G3, H3, I3, J3, K3, \ +A4, B4, C4, D4, E4, F4, G4, H4, I4, J4, K4, \ +A5, B5, C5, D5, E5, F5, G5, H5, I5, J5, K5, \ +A6, B6, C6, D6, E6, F6, G6, H6, I6, J6, K6, \ +A7, B7, C7, D7, E7, F7, G7, H7, I7, J7, K7, \ +A8, B8, C8, D8, E8, F8, G8, H8, I8, J8, K8, \ + = MAP.flatten() + + +class Config: + + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (150, 255 - 24), + 'width': (0.9, 10), + 'prominence': 10, + 'distance': 35, + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (255 - 24, 255), + 'prominence': 10, + 'distance': 50, + 'width': (0, 10), + 'wlen': 1000, + } + + +class Campaign(CampaignBase): + MAP = MAP + + def battle_0(self): + if self.clear_enemy(): + return True + return self.battle_default() + + def battle_4(self): + if self.fleet_2.clear_enemy(): + return True + return self.battle_default() + + def battle_6(self): + self.pick_up_ammo() + if self.fleet_1.clear_enemy(): + return True + + def battle_7(self): + return self.fleet_boss.clear_boss() \ No newline at end of file From 959f75baa0d0af3ba39dd70a8ed51f63402703c8 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 06:55:37 -0300 Subject: [PATCH 09/18] Map: added roadblocks on D3 map (event_20200611) --- campaign/event_20200611_en/d3.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/campaign/event_20200611_en/d3.py b/campaign/event_20200611_en/d3.py index 6471388e0..368b5ebf4 100644 --- a/campaign/event_20200611_en/d3.py +++ b/campaign/event_20200611_en/d3.py @@ -115,6 +115,8 @@ class Campaign(CampaignBase): def battle_5(self): if self.clear_siren(): return True + if self.clear_roadblocks([ROAD_MAIN]): + return True if self.clear_potential_roadblocks([ROAD_MAIN]): return True if self.fleet_1.clear_enemy(scale=(2,), genre=['light', 'main', 'enemy', 'carrier']): From 9fa44fc9772fb4fe2e1865c2a4f14af75a432bde Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 15:32:58 -0300 Subject: [PATCH 10/18] Fix: Instance attribute grids defined outside __init__ --- module/map/camera.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/map/camera.py b/module/map/camera.py index e3aa810db..288d57155 100644 --- a/module/map/camera.py +++ b/module/map/camera.py @@ -33,6 +33,10 @@ class Camera(InfoHandler): map: CampaignMap camera = (0, 0) + def __init__(self, config, device=None): + super().__init__(config, device=None) + self.grids = Grids(self.device.image, config=self.config) + def _map_swipe(self, vector, drop_threshold=0.1): """ Args: @@ -112,7 +116,7 @@ class Camera(InfoHandler): return True try: - self.grids = Grids(self.device.image, config=self.config) + pass except Exception as e: if self.info_bar_count(): logger.info('Perspective error cause by info bar. Waiting.') From cd214dc1c17165a9dc6d7939cf5e9e1b7da56651 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 15:35:48 -0300 Subject: [PATCH 11/18] Add: added option to bypass exception on device/control Alas will withdraw from map instead stopped. --- module/device/control.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/device/control.py b/module/device/control.py index d556bc574..8cc41b210 100644 --- a/module/device/control.py +++ b/module/device/control.py @@ -8,9 +8,10 @@ from module.base.utils import * from module.device.connection import Connection from module.exception import ScriptError from module.logger import logger +from module.map.map import Map -class Control(Connection): +class Control(Connection, Map): click_record = deque(maxlen=15) @staticmethod @@ -40,9 +41,12 @@ class Control(Connection): if sum([1 if str(prev) == str(button) else 0 for prev in self.click_record]) >= 12: logger.warning(f'Too many click for a button: {button}') logger.info(f'History click: {[str(prev) for prev in self.click_record]}') - raise ScriptError(f'Too many click for a button: {button}') + if self.config.ENABLE_EXCEPTION: + raise ScriptError(f'Too many click for a button: {button}') else: + logger.warning('ScriptError, Withdrawing because enable_exception = no') self.click_record.append(str(button)) + self.withdraw() return False From 266ef8782054f7aa15fccd0b6ec38edc5a482cb6 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 16:14:48 -0300 Subject: [PATCH 12/18] Revert "Fix: Instance attribute grids defined outside __init__" This reverts commit 9fa44fc9772fb4fe2e1865c2a4f14af75a432bde. --- module/map/camera.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/module/map/camera.py b/module/map/camera.py index 288d57155..e3aa810db 100644 --- a/module/map/camera.py +++ b/module/map/camera.py @@ -33,10 +33,6 @@ class Camera(InfoHandler): map: CampaignMap camera = (0, 0) - def __init__(self, config, device=None): - super().__init__(config, device=None) - self.grids = Grids(self.device.image, config=self.config) - def _map_swipe(self, vector, drop_threshold=0.1): """ Args: @@ -116,7 +112,7 @@ class Camera(InfoHandler): return True try: - pass + self.grids = Grids(self.device.image, config=self.config) except Exception as e: if self.info_bar_count(): logger.info('Perspective error cause by info bar. Waiting.') From 6badfe65663d8c8f408f01e72902ac5d218193fe Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 16:21:40 -0300 Subject: [PATCH 13/18] Revert "Add: added option to bypass exception on device/control" This reverts commit cd214dc1c17165a9dc6d7939cf5e9e1b7da56651. --- module/device/control.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/module/device/control.py b/module/device/control.py index 8cc41b210..d556bc574 100644 --- a/module/device/control.py +++ b/module/device/control.py @@ -8,10 +8,9 @@ from module.base.utils import * from module.device.connection import Connection from module.exception import ScriptError from module.logger import logger -from module.map.map import Map -class Control(Connection, Map): +class Control(Connection): click_record = deque(maxlen=15) @staticmethod @@ -41,12 +40,9 @@ class Control(Connection, Map): if sum([1 if str(prev) == str(button) else 0 for prev in self.click_record]) >= 12: logger.warning(f'Too many click for a button: {button}') logger.info(f'History click: {[str(prev) for prev in self.click_record]}') - if self.config.ENABLE_EXCEPTION: - raise ScriptError(f'Too many click for a button: {button}') + raise ScriptError(f'Too many click for a button: {button}') else: - logger.warning('ScriptError, Withdrawing because enable_exception = no') self.click_record.append(str(button)) - self.withdraw() return False From 32971f7efd9c2555a227cda138e5faf7e97f6abd Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 23:34:53 -0300 Subject: [PATCH 14/18] Update version.txt --- version.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/version.txt b/version.txt index e69de29bb..e3c6b032a 100644 --- a/version.txt +++ b/version.txt @@ -0,0 +1,2 @@ +0.1.0 +20200619.01 \ No newline at end of file From 2961d5a8274ddbdb9d219bd5bab12b136762745e Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Fri, 19 Jun 2020 23:43:38 -0300 Subject: [PATCH 15/18] Fix: [EN] Added new commission filter --- module/reward/commission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/reward/commission.py b/module/reward/commission.py index 7d3e7e92f..6d55d76c0 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -46,7 +46,7 @@ dictionary_en = { 'urgent_book': ['Tyrant', 'Poro', 'Makira', 'Kapolo', 'Mary', 'Isle', 'Kotlin', 'AidingWapolo'], 'urgent_box': ['Gear', 'Handover'], 'urgent_cube': ['MerchantRescue', 'Attack', 'EnemyAtack'], - 'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort', 'BIWPatro'], + 'urgent_gem': ['VIP ', 'Holiday', 'PatrolEscort', 'BIWWIPEscort', 'BIWVIPEscort', 'NYBWIPEscort', 'BIWPatro', 'BIWWPEscor'], 'urgent_ship': ['Launch'] } From f5aad53e1532d454e8419bed6c43f9806d84cd9a Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Sat, 20 Jun 2020 02:01:40 -0300 Subject: [PATCH 16/18] Update version.txt --- version.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/version.txt b/version.txt index e3c6b032a..ab1fd882c 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1 @@ -0.1.0 -20200619.01 \ No newline at end of file +20200619.01 From c1a773e82a4b4535711083aa346d7aafdb647aa1 Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Sat, 20 Jun 2020 03:09:01 -0300 Subject: [PATCH 17/18] Update version.txt --- version.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/version.txt b/version.txt index ab1fd882c..e857858e6 100644 --- a/version.txt +++ b/version.txt @@ -1 +1,3 @@ -20200619.01 +0.1.0 +20200620.01 +20200620.01 \ No newline at end of file From c67f9543508718ed0a8b10faaf3db7c014e07c3d Mon Sep 17 00:00:00 2001 From: whoamikyo Date: Sat, 20 Jun 2020 06:07:43 -0300 Subject: [PATCH 18/18] Add: Update check --- alas.py | 10 +++--- config/template.ini | 1 + module/config/argparser.py | 3 ++ module/config/argparser_en.py | 3 ++ module/config/argparser_jp.py | 3 ++ module/config/config.py | 4 ++- module/config/dictionary.py | 2 ++ module/updater.py | 65 ++++++++++++++++++++++++----------- version.txt | 2 +- 9 files changed, 64 insertions(+), 29 deletions(-) diff --git a/alas.py b/alas.py index ac35d7f76..7e1941472 100644 --- a/alas.py +++ b/alas.py @@ -8,9 +8,6 @@ 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=''): @@ -60,9 +57,10 @@ class AzurLaneAutoScript: 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.') + from module.updater import Update + ad = Update(self.config) + if self.config.UPDATE_CHECK: + ad.check_update() def reward(self): for key, value in self.config.config['Reward'].items(): diff --git a/config/template.ini b/config/template.ini index 7c8f6d958..6db77496d 100644 --- a/config/template.ini +++ b/config/template.ini @@ -56,6 +56,7 @@ enable_map_clear_mode = yes clear_mode_stop_condition = map_green map_star_clear_all = index_3 command = setting +enable_update_check = yes [Reward] command = reward diff --git a/module/config/argparser.py b/module/config/argparser.py index 4c0ea777d..f8c39513a 100644 --- a/module/config/argparser.py +++ b/module/config/argparser.py @@ -214,6 +214,9 @@ def main(ini_name=''): drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['是', '否']) drop.add_argument('--掉落保存目录', default=default('--掉落保存目录')) + update = setting_parser.add_argument_group('ALAS Update Check', '') + update.add_argument('--enable_update_check', default=default('--enable_update_check'), choices=['yes', 'no']) + clear = setting_parser.add_argument_group('开荒模式', '未开荒地图会在完成后停止, 已开荒的地图会忽略选项, 无脑开就完事了') clear.add_argument('--启用开荒', default=default('--启用开荒'), choices=['是', '否']) clear.add_argument('--开荒停止条件', default=default('--开荒停止条件'), choices=['地图通关', '地图三星', '地图绿海']) diff --git a/module/config/argparser_en.py b/module/config/argparser_en.py index 68b3fdb3b..50b170e94 100644 --- a/module/config/argparser_en.py +++ b/module/config/argparser_en.py @@ -217,6 +217,9 @@ def main(ini_name=''): clear.add_argument('--clear_mode_stop_condition', default=default('--clear_mode_stop_condition'), choices=['map_100', 'map_3_star', 'map_green']) clear.add_argument('--map_star_clear_all', default=default('--map_star_clear_all'), choices=['index_1', 'index_2', 'index_3', 'do_not_use'], help='The first few stars are to destroy all enemy ships') + update = setting_parser.add_argument_group('ALAS Update Check', '') + update.add_argument('--enable_update_check', default=default('--enable_update_check'), choices=['yes', 'no']) + # ==========reward========== reward_parser = subs.add_parser('reward') reward_condition = reward_parser.add_argument_group('Triggering conditions', 'Need to Press start to save your settings, after running it will enter the on-hook vegetable collection mode') diff --git a/module/config/argparser_jp.py b/module/config/argparser_jp.py index 8de9dafd3..fbe3fc170 100644 --- a/module/config/argparser_jp.py +++ b/module/config/argparser_jp.py @@ -212,6 +212,9 @@ def main(ini_name=''): clear.add_argument('--clear_mode_stop_condition', default=default('--clear_mode_stop_condition'), choices=['map_100', 'map_3_star', 'map_green']) clear.add_argument('--map_star_clear_all', default=default('--map_star_clear_all'), choices=['index_1', 'index_2', 'index_3', 'do_not_use'], help='The first few stars are to destroy all enemy ships') + update = setting_parser.add_argument_group('ALAS Update Check', '') + update.add_argument('--enable_update_check', default=default('--enable_update_check'), choices=['yes', 'no']) + # ==========reward========== reward_parser = subs.add_parser('reward') reward_condition = reward_parser.add_argument_group('Triggering conditions', 'Need to run once to save the options, after running it will enter the on-hook vegetable collection mode') diff --git a/module/config/config.py b/module/config/config.py index 923d81076..856cb610a 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -22,7 +22,7 @@ class AzurLaneConfig: config = configparser.ConfigParser(interpolation=None) start_time = datetime.now() - UPDATE = True + UPDATE_CHECK = True SERVER = server.server logger.attr('Server', SERVER) @@ -417,6 +417,8 @@ class AzurLaneConfig: self.COMBAT_SCREENSHOT_INTERVAL = float(option['combat_screenshot_interval']) option = config['Setting'] + #UpdateCheck + self.UPDATE_CHECK = to_bool(option['enable_update_check']) # Stop condition self.ENABLE_STOP_CONDITION = to_bool(option['enable_stop_condition']) self.ENABLE_EXCEPTION = to_bool(option['enable_exception']) diff --git a/module/config/dictionary.py b/module/config/dictionary.py index 15a8a09f5..647b52df0 100644 --- a/module/config/dictionary.py +++ b/module/config/dictionary.py @@ -37,6 +37,7 @@ dic_true_eng_to_eng = { 'c12-4_leveling': 'c124_leveling', # Argument + 'enable_update_check': 'enable_update_check', 'enable_stop_condition': 'enable_stop_condition', 'enable_exception': 'enable_exception', 'enable_fast_forward': 'enable_fast_forward', @@ -228,6 +229,7 @@ dic_chi_to_eng = { '12-4打大型练级': 'c124_leveling', # Argument + 'enable_update_check': 'enable_update_check', '启用停止条件': 'enable_stop_condition', '使用周回模式': 'enable_fast_forward', '如果出击次数大于': 'if_count_greater_than', diff --git a/module/updater.py b/module/updater.py index 8c24b2665..c0c7aa8d0 100644 --- a/module/updater.py +++ b/module/updater.py @@ -1,4 +1,6 @@ +import json from urllib import error, request +import requests from module.logger import logger from module.config.config import AzurLaneConfig @@ -12,34 +14,55 @@ class Update(object): self.config = config def check_update(self): - version = '' - latest_version = '' + main_commits = 'https://api.github.com/repos/LmeSzinc/AzurLaneAutoScript/commits/master' + fork_commits = 'https://api.github.com/repos/whoamikyo/AzurLaneAutoScript/commits/master' + + # LmeSzinc commits + l = requests.get(main_commits) + main_commit_info = json.loads(l.content) + + # Whoamikyo fork commits + w = requests.get(fork_commits) + fork_commit_info = json.loads(w.content) + _file = open('version.txt', 'r') + local_version = _file.readline() - if self.config.UPDATE: - version = _file.readline() + if self.config.UPDATE_CHECK: 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] + with request.urlopen("https://raw.githubusercontent.com/LmeSzinc/AzurLaneAutoScript/master/version.txt") as m: + _m = m.read().decode('utf-8') + main_version = _m.splitlines()[1] except error.HTTPError as e: - logger.info("Couldn't check for updates, {}.".format(e)) + logger.error("Couldn't check for updates, {}.".format(e)) + + else: + + try: + with request.urlopen("https://raw.githubusercontent.com/whoamikyo/AzurLaneAutoScript/master/version.txt") as f: + _f = f.read().decode('utf-8') + fork_version = _f.splitlines()[1] + except error.HTTPError as e: + logger.error("Couldn't check for updates, {}.".format(e)) + + if main_version != fork_version: + logger.warning("Current Version: " + local_version) + logger.warning("Current LmeSzinc version: " + main_version) + logger.warning("Current whoamikyo version: " + fork_version) + logger.warning('A new update is available, please run Easy_Install-V2.bat or check github') + + else: + logger.info('ALAS is up to date') + logger.info('Latest commit from\n%s - %s' % (main_commit_info['commit']['author']['name'], main_commit_info['commit']['message'])) + logger.info('Latest commit from\n%s - %s' % (fork_commit_info['commit']['author']['name'], fork_commit_info['commit']['message'])) + + return True + + + - 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 index e857858e6..337980ae4 100644 --- a/version.txt +++ b/version.txt @@ -1,3 +1,3 @@ -0.1.0 +1.0.0 20200620.01 20200620.01 \ No newline at end of file