mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:27:33 +08:00
Add: 适配了第四章
- 稍微移动了章节OCR的位置, 因为4-4会识别为14-4 - 针对第四章这种偏红的地图做了一些优化 - 稍微延长了敌人刷新时的等待时间 - 更改出错截图文件名为格式化的时间
This commit is contained in:
parent
007d14c1d7
commit
a674198365
5
alas.py
5
alas.py
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.logger import logger, pyw_name, log_file
|
||||
@ -24,8 +25,8 @@ class AzurLaneAutoScript:
|
||||
logger.info(f'Saving error: {folder}')
|
||||
os.mkdir(folder)
|
||||
for data in logger.screenshot_deque:
|
||||
image_time, image = data['time'], data['image']
|
||||
image.save(f'{folder}/{image_time}.png')
|
||||
image_time = datetime.strftime(data['time'], '%Y-%m-%d_%H-%M-%S-%f')
|
||||
data['image'].save(f'{folder}/{image_time}.png')
|
||||
with open(log_file, 'r') as f:
|
||||
start = 0
|
||||
for index, line in enumerate(f.readlines()):
|
||||
|
78
campaign/campaign_main/campaign_4_1.py
Normal file
78
campaign/campaign_main/campaign_4_1.py
Normal file
@ -0,0 +1,78 @@
|
||||
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()
|
||||
MAP.shape = 'F6'
|
||||
MAP.map_data = '''
|
||||
ME -- SP -- -- SP
|
||||
-- -- -- -- -- ME
|
||||
ME ME ++ ++ ME SP
|
||||
-- -- MB ++ -- ME
|
||||
ME -- ME MM ME --
|
||||
-- MB ++ ++ ++ ++
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 50 50 50 50 50
|
||||
50 10 10 10 10 20
|
||||
20 10 10 10 10 20
|
||||
20 10 10 10 10 20
|
||||
50 10 10 10 10 20
|
||||
50 10 50 50 50 50
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 2, 'mystery': 1},
|
||||
{'battle': 1, 'enemy': 2},
|
||||
{'battle': 2, 'enemy': 1},
|
||||
{'battle': 3, 'enemy': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, \
|
||||
A2, B2, C2, D2, E2, F2, \
|
||||
A3, B3, C3, D3, E3, F3, \
|
||||
A4, B4, C4, D4, E4, F4, \
|
||||
A5, B5, C5, D5, E5, F5, \
|
||||
A6, B6, C6, D6, E6, F6, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
class Config:
|
||||
FLEET_2 = 0
|
||||
SUBMARINE = 0
|
||||
MAP_MYSTERY_HAS_CARRIER = True
|
||||
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
|
||||
'height': (120, 255 - 40),
|
||||
'width': (1.5, 10),
|
||||
'prominence': 10,
|
||||
'distance': 35,
|
||||
}
|
||||
EDGE_LINES_FIND_PEAKS_PARAMETERS = {
|
||||
'height': (255 - 40, 255),
|
||||
'prominence': 10,
|
||||
'distance': 50,
|
||||
'wlen': 1000
|
||||
}
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
MAP_AMBUSH_OVERLAY_TRANSPARENCY_THRESHOLD = 0.3
|
||||
MAP_AIR_RAID_OVERLAY_TRANSPARENCY_THRESHOLD = 0.25
|
||||
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.65
|
||||
|
||||
def battle_0(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_3(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.battle_default()
|
||||
|
||||
return self.clear_boss()
|
64
campaign/campaign_main/campaign_4_2.py
Normal file
64
campaign/campaign_main/campaign_4_2.py
Normal file
@ -0,0 +1,64 @@
|
||||
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
|
||||
from campaign.campaign_main.campaign_4_1 import Config
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'F6'
|
||||
MAP.camera_data = ['D2', 'D4']
|
||||
# WIKI的图有错: https://wiki.biligame.com/blhx/4-2
|
||||
# D5是敌人刷新点, 假图害人
|
||||
MAP.map_data = '''
|
||||
++ ++ ++ ME SP --
|
||||
SP -- -- -- ME --
|
||||
-- -- ME ME -- ME
|
||||
SP -- -- -- -- MB
|
||||
++ ++ ME ME -- ME
|
||||
++ ++ -- MB ME MM
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 50 50 50 50 50
|
||||
50 50 50 50 50 50
|
||||
50 50 50 50 50 50
|
||||
50 50 50 10 10 10
|
||||
50 50 20 10 10 20
|
||||
50 50 20 10 10 20
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 3, 'mystery': 1},
|
||||
{'battle': 1, 'enemy': 2},
|
||||
{'battle': 2, 'enemy': 1},
|
||||
{'battle': 3, 'enemy': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, \
|
||||
A2, B2, C2, D2, E2, F2, \
|
||||
A3, B3, C3, D3, E3, F3, \
|
||||
A4, B4, C4, D4, E4, F4, \
|
||||
A5, B5, C5, D5, E5, F5, \
|
||||
A6, B6, C6, D6, E6, F6, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
MAP_AMBUSH_OVERLAY_TRANSPARENCY_THRESHOLD = 0.3
|
||||
MAP_AIR_RAID_OVERLAY_TRANSPARENCY_THRESHOLD = 0.25
|
||||
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.65
|
||||
|
||||
def battle_0(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_3(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.battle_default()
|
||||
|
||||
return self.clear_boss()
|
60
campaign/campaign_main/campaign_4_3.py
Normal file
60
campaign/campaign_main/campaign_4_3.py
Normal file
@ -0,0 +1,60 @@
|
||||
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
|
||||
from campaign.campaign_main.campaign_4_1 import Config as Config41
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'G4'
|
||||
MAP.map_data = '''
|
||||
SP ME -- ME -- SP MB
|
||||
-- -- ME -- ME -- ME
|
||||
++ ++ ME -- -- MB MM
|
||||
++ ++ MB -- ME -- ME
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 50 50 50 50 10 10
|
||||
50 50 50 50 50 10 20
|
||||
50 50 20 10 10 10 10
|
||||
50 50 10 10 50 50 50
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 3, 'mystery': 1},
|
||||
{'battle': 1, 'enemy': 1},
|
||||
{'battle': 2, 'enemy': 2},
|
||||
{'battle': 3, 'enemy': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
class Config(Config41):
|
||||
INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40
|
||||
EDGE_LINES_HOUGHLINES_THRESHOLD = 40
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
MAP_AMBUSH_OVERLAY_TRANSPARENCY_THRESHOLD = 0.3
|
||||
MAP_AIR_RAID_OVERLAY_TRANSPARENCY_THRESHOLD = 0.25
|
||||
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.65
|
||||
|
||||
def battle_0(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_3(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.battle_default()
|
||||
|
||||
return self.clear_boss()
|
74
campaign/campaign_main/campaign_4_4.py
Normal file
74
campaign/campaign_main/campaign_4_4.py
Normal file
@ -0,0 +1,74 @@
|
||||
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
|
||||
from campaign.campaign_main.campaign_4_1 import Config as Config41
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'H6'
|
||||
MAP.camera_data = ['D2', 'D4']
|
||||
MAP.map_data = '''
|
||||
++ ++ MB ME SP -- ++ ++
|
||||
++ ++ ME __ ME ME ++ ++
|
||||
++ ++ -- ME -- -- -- SP
|
||||
++ ++ -- ME ++ ME -- --
|
||||
++ ++ ME -- ++ -- ME --
|
||||
MB ME -- ME -- ME -- SP
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 50 10 20 50 50 50 50
|
||||
50 50 10 20 50 50 50 50
|
||||
50 50 10 20 50 50 50 50
|
||||
50 50 10 20 50 50 50 50
|
||||
50 50 10 20 50 50 50 50
|
||||
10 10 10 20 50 50 50 50
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 3},
|
||||
{'battle': 1, 'enemy': 1},
|
||||
{'battle': 2, 'enemy': 2},
|
||||
{'battle': 3, 'enemy': 1},
|
||||
{'battle': 4, 'enemy': 2, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, H1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, H2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, H3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, H4, \
|
||||
A5, B5, C5, D5, E5, F5, G5, H5, \
|
||||
A6, B6, C6, D6, E6, F6, G6, H6, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
road_main = RoadGrids([B6, [C4, D6], [C5, D4], [D3, C2], [C2, D1]])
|
||||
|
||||
|
||||
class Config(Config41):
|
||||
MAP_MYSTERY_HAS_CARRIER = False
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
MAP_AMBUSH_OVERLAY_TRANSPARENCY_THRESHOLD = 0.3
|
||||
MAP_AIR_RAID_OVERLAY_TRANSPARENCY_THRESHOLD = 0.25
|
||||
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.65
|
||||
|
||||
def battle_0(self):
|
||||
if self.clear_roadblocks([road_main]):
|
||||
return True
|
||||
if self.clear_potential_roadblocks([road_main]):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_4(self):
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
if self.clear_roadblocks([road_main]):
|
||||
return True
|
||||
if self.clear_potential_roadblocks([road_main]):
|
||||
return True
|
||||
|
||||
return self.clear_boss()
|
@ -59,7 +59,7 @@ class CampaignOcr:
|
||||
if result is None or len(result) == 0:
|
||||
logger.warning('No stage clear image found.')
|
||||
|
||||
name_offset = (75, 9)
|
||||
name_offset = (77, 9)
|
||||
name_size = (60, 16)
|
||||
name_letter = (255, 255, 255)
|
||||
name_back = (102, 102, 102)
|
||||
|
@ -281,6 +281,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
|
||||
expected_end (str): with_searching, no_searching, in_stage.
|
||||
"""
|
||||
logger.info('Combat status')
|
||||
logger.attr('expected_end', expected_end)
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import Image
|
||||
@ -63,7 +64,7 @@ class Screenshot(Connection):
|
||||
|
||||
self.image.load()
|
||||
if self.config.ENABLE_ERROR_LOG_AND_SCREENSHOT_SAVE:
|
||||
logger.screenshot_deque.append({'time': int(time.time() * 1000), 'image': self.image})
|
||||
logger.screenshot_deque.append({'time': datetime.now(), 'image': self.image})
|
||||
return self.image
|
||||
|
||||
def save_screenshot(self, genre='items'):
|
||||
|
@ -94,4 +94,7 @@ class AmbushHandler(Combat):
|
||||
self._handle_ambush()
|
||||
return True
|
||||
|
||||
if self.appear(MAP_AMBUSH_EVADE):
|
||||
self._handle_ambush()
|
||||
|
||||
return False
|
||||
|
@ -7,9 +7,9 @@ from module.logger import logger
|
||||
|
||||
class EnemySearchingHandler(InfoBarHandler):
|
||||
MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD = 0.5 # Usually (0.70, 0.80).
|
||||
MAP_ENEMY_SEARCHING_TIMEOUT_SECOND = 4
|
||||
MAP_ENEMY_SEARCHING_TIMEOUT_SECOND = 4.5
|
||||
|
||||
def _color_initial(self):
|
||||
def enemy_searching_color_initial(self):
|
||||
MAP_ENEMY_SEARCHING.load_color(self.device.image)
|
||||
|
||||
def enemy_searching_appear(self):
|
||||
@ -18,7 +18,7 @@ class EnemySearchingHandler(InfoBarHandler):
|
||||
) > self.MAP_ENEMY_SEARCHING_OVERLAY_TRANSPARENCY_THRESHOLD
|
||||
|
||||
def handle_enemy_flashing(self):
|
||||
self.device.sleep(1)
|
||||
self.device.sleep(1.2)
|
||||
|
||||
def handle_in_stage(self):
|
||||
if self.appear(IN_STAGE_RED) or self.appear(IN_STAGE_BLUE):
|
||||
@ -48,7 +48,7 @@ class EnemySearchingHandler(InfoBarHandler):
|
||||
self.device.sleep(0.3)
|
||||
logger.info('In map.')
|
||||
break
|
||||
self._color_initial()
|
||||
self.enemy_searching_color_initial()
|
||||
|
||||
if timeout.reached():
|
||||
# logger.warning('Enemy searching timeout.')
|
||||
|
@ -69,6 +69,7 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
|
||||
while 1:
|
||||
self.ambush_color_initial()
|
||||
self.enemy_searching_color_initial()
|
||||
grid.__str__ = location
|
||||
result = 'nothing'
|
||||
self.device.click(grid)
|
||||
@ -118,6 +119,7 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
|
||||
self.handle_boss_appear_refocus()
|
||||
grid = self.convert_map_to_grid(location)
|
||||
walk_timeout.reset()
|
||||
# break
|
||||
|
||||
if self.handle_map_cat_attack():
|
||||
@ -140,7 +142,7 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
# End
|
||||
if ambushed_retry.started() and ambushed_retry.reached():
|
||||
break
|
||||
if not arrived and walk_timeout.reached():
|
||||
if walk_timeout.reached():
|
||||
logger.warning('Walk timeout. Retrying.')
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user