1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-25 02:30:09 +08:00

Revert "Revert "Merge branch 'dev' of https://github.com/LmeSzinc/AzurLaneAutoScript into dev""

This reverts commit ac9303012c.
This commit is contained in:
whoamikyo
2020-08-18 20:48:14 -03:00
parent ac9303012c
commit 09d3f695de
741 changed files with 18944 additions and 8381 deletions

View File

@@ -1,7 +1,6 @@
from module.base.button import Button
from module.logger import logger
from module.exception import CampaignEnd
from module.exception import ScriptError
from module.exception import CampaignEnd, ScriptError, MapEnemyMoved
from module.map.map import Map
from module.map.map_base import CampaignMap
from module.base.decorator import Config
@@ -27,9 +26,8 @@ class CampaignBase(Map):
return False
@Config.when(POOR_MAP_DATA=True, MAP_CLEAR_ALL_THIS_TIME=False)
def execute_a_battle(self):
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
logger.info('Running with poor map data.')
def battle_function(self):
logger.info('Using function: battle_with_poor_map_data')
if self.fleet_2_break_siren_caught():
return True
self.clear_all_mystery()
@@ -45,12 +43,10 @@ class CampaignBase(Map):
return True
return self.clear_enemy()
logger.warning('No battle executed.')
return False
@Config.when(MAP_CLEAR_ALL_THIS_TIME=True)
def execute_a_battle(self):
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
def battle_function(self):
logger.info('Using function: clear_all')
if self.fleet_2_break_siren_caught():
return True
@@ -60,7 +56,7 @@ class CampaignBase(Map):
self.pick_up_ammo()
remain = self.map.select(is_enemy=True, is_boss=False)
logger.info('Enemy remain: {}')
logger.info(f'Enemy remain: {remain}')
if remain.count > 0:
if self.clear_siren():
return True
@@ -74,21 +70,42 @@ class CampaignBase(Map):
return result
@Config.when(MAP_CLEAR_ALL_THIS_TIME=False, POOR_MAP_DATA=False)
def execute_a_battle(self):
def battle_function(self):
func = self.FUNCTION_NAME_BASE + 'default'
for extra_battle in range(10):
if hasattr(self, self.FUNCTION_NAME_BASE + str(self.battle_count - extra_battle)):
func = self.FUNCTION_NAME_BASE + str(self.battle_count - extra_battle)
break
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
logger.info(f'Using function: {func}')
func = self.__getattribute__(func)
result = func()
return result
def execute_a_battle(self):
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
prev = self.battle_count
result = False
for _ in range(10):
try:
result = self.battle_function()
break
except MapEnemyMoved:
if self.battle_count > prev:
result = True
break
else:
continue
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
@@ -109,4 +126,8 @@ class CampaignBase(Map):
return True
logger.warning('Battle function exhausted.')
raise ScriptError('Battle function exhausted.')
if self.config.ENABLE_EXCEPTION:
raise ScriptError('Battle function exhausted.')
else:
logger.warning('ScriptError, Battle function exhausted, Withdrawing because enable_exception = no')
self.withdraw()