Add: 适配第二章

- 修复了不开启周回模式时, 会在出击界面开启自动的问题
- 修复了多打一战后, 打完BOSS不判定当前出击结束的问题
- 增加掉落新船时锁定的功能
- 增加了地图不支持周回模式时, 跳过周回检查的功能
  周回模式的选项可以无脑开了
- 修改透视识别报warning为info
  因为低级图地图小降低了检测的阈值, 导致需要纠正错误有点多
- 减少了战斗准备页面的多余点击
- 减少了挂委托时的多余点击
This commit is contained in:
LmeSzinc 2020-04-14 17:32:26 +08:00
parent 91e83271a4
commit 70936f4f39
17 changed files with 250 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,65 @@
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 = 'F4'
MAP.map_data = '''
-- SP ME -- ME --
SP -- ++ ++ ME MM
++ -- ME -- ME ME
++ ++ ++ MB -- ++
'''
MAP.weight_data = '''
40 40 40 40 40 40
30 30 30 30 30 30
20 20 20 20 20 30
10 10 10 10 10 10
'''
MAP.spawn_data = [
{'battle': 0, 'enemy': 2, 'mystery': 1},
{'battle': 1, 'enemy': 2},
{'battle': 2, 'enemy': 2, '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, \
= MAP.flatten()
class Config:
FLEET_2 = 0
SUBMARINE = 0
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
def battle_0(self):
self.clear_all_mystery()
return self.battle_default()
def battle_2(self):
self.clear_all_mystery()
if not self.check_accessibility(D4):
return self.battle_default()
return self.clear_boss()

View File

@ -0,0 +1,54 @@
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_2_1 import Config
MAP = CampaignMap()
MAP.shape = 'G5'
MAP.camera_data = ['D3']
MAP.map_data = '''
++ ++ ++ MB ++ ++ ++
++ ++ ++ ME MA ++ ++
-- ME -- ME -- -- ME
SP -- ME -- -- ME ME
-- ME -- -- SP ME MM
'''
MAP.weight_data = '''
10 10 10 10 10 10 10
10 10 10 10 10 10 10
50 50 50 50 50 50 50
30 30 30 30 30 30 30
30 30 30 30 30 30 30
'''
MAP.spawn_data = [
{'battle': 0, 'enemy': 2, 'mystery': 1},
{'battle': 1, 'enemy': 2},
{'battle': 2, 'enemy': 1},
{'battle': 3, 'enemy': 2, '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, \
A5, B5, C5, D5, E5, F5, G5, \
= MAP.flatten()
class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
self.clear_all_mystery()
return self.battle_default()
def battle_3(self):
self.clear_all_mystery()
if not self.check_accessibility(D1):
return self.battle_default()
return self.clear_boss()

View File

@ -0,0 +1,54 @@
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_2_1 import Config
MAP = CampaignMap()
MAP.shape = 'F5'
MAP.camera_data = ['D3']
MAP.map_data = '''
SP -- ME -- MB ++
-- ME -- ME ++ ++
-- -- ME -- -- ++
SP -- -- ME ME --
++ ++ ++ -- ME MM
'''
MAP.weight_data = '''
10 10 10 10 10 10
50 50 10 10 10 10
20 20 20 20 20 20
20 20 20 20 30 30
30 30 30 30 30 30
'''
MAP.spawn_data = [
{'battle': 0, 'enemy': 2, 'mystery': 1},
{'battle': 1, 'enemy': 2},
{'battle': 2, 'enemy': 1},
{'battle': 3, 'enemy': 2, '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, \
= MAP.flatten()
class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
self.clear_all_mystery()
return self.battle_default()
def battle_3(self):
self.clear_all_mystery()
if not self.check_accessibility(E1):
return self.battle_default()
return self.clear_boss()

View File

@ -0,0 +1,47 @@
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_2_1 import Config
MAP = CampaignMap()
MAP.shape = 'G4'
MAP.camera_data = ['D2']
MAP.map_data = '''
-- ++ ++ ++ ME ME MB
SP -- ME -- -- ME --
-- -- ME -- ME ++ ++
-- ME -- SP -- MA ++
'''
MAP.weight_data = '''
20 20 20 20 10 10 10
20 20 20 20 10 10 10
20 20 20 20 30 20 20
20 20 20 20 20 20 20
'''
MAP.spawn_data = [
{'battle': 0, 'enemy': 2},
{'battle': 1, 'enemy': 2},
{'battle': 2, 'enemy': 1},
{'battle': 3, 'enemy': 2, '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 Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
return self.battle_default()
def battle_3(self):
if not self.check_accessibility(G1):
return self.battle_default()
return self.clear_boss()

View File

@ -25,6 +25,7 @@ class CampaignBase(Map):
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()

View File

@ -123,7 +123,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
continue
# Combat start
if self.appear_then_click(BATTLE_PREPARATION):
if self.appear_then_click(BATTLE_PREPARATION, interval=2):
continue
if self.handle_combat_automation_confirm():
@ -259,6 +259,8 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
continue
if self.handle_battle_status(save_get_items=save_get_items):
continue
if self.handle_popup_confirm():
continue
if self.handle_get_ship():
continue
if self.appear_then_click(EXP_INFO_S):
@ -294,7 +296,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
"""
balance_hp = balance_hp if balance_hp is not None else self.config.ENABLE_HP_BALANCE
emotion_reduce = emotion_reduce if emotion_reduce is not None else self.config.ENABLE_EMOTION_REDUCE
auto = func is None
auto = self.config.COMBAT_AUTO_MODE == 'combat_auto'
call_submarine_at_boss = call_submarine_at_boss if call_submarine_at_boss is not None else self.config.SUBMARINE_CALL_AT_BOSS
save_get_items = save_get_items if save_get_items is not None else self.config.ENABLE_SAVE_GET_ITEMS

View File

@ -28,6 +28,10 @@ MAP_AMBUSH = Button(area=(261, 433, 1280, 449), color=(161, 41, 43), button=(261
MAP_AMBUSH_EVADE = Button(area=(325, 393, 1280, 395), color=(255, 255, 255), button=(979, 444, 1152, 502), file='./assets/handler/MAP_AMBUSH_EVADE.png')
MAP_BUFF = Button(area=(145, 115, 437, 159), color=(103, 118, 118), button=(145, 115, 437, 159), file='./assets/handler/MAP_BUFF.png')
MAP_ENEMY_SEARCHING = Button(area=(531, 320, 864, 382), color=(200, 99, 91), button=(531, 320, 864, 382), file='./assets/handler/MAP_ENEMY_SEARCHING.png')
MAP_GREEN = Button(area=(195, 260, 349, 292), color=(125, 190, 84), button=(195, 260, 349, 292), file='./assets/handler/MAP_GREEN.png')
MAP_STAR_1 = Button(area=(245, 377, 254, 384), color=(251, 233, 143), button=(245, 377, 254, 384), file='./assets/handler/MAP_STAR_1.png')
MAP_STAR_2 = Button(area=(532, 377, 540, 384), color=(251, 233, 144), button=(532, 377, 540, 384), file='./assets/handler/MAP_STAR_2.png')
MAP_STAR_3 = Button(area=(818, 377, 827, 384), color=(251, 233, 143), button=(818, 377, 827, 384), file='./assets/handler/MAP_STAR_3.png')
MYSTERY_ITEM = Button(area=(589, 294, 691, 427), color=(144, 127, 83), button=(589, 294, 691, 427), file='./assets/handler/MYSTERY_ITEM.png')
POPUP_CANCEL = Button(area=(404, 493, 576, 550), color=(166, 169, 172), button=(404, 493, 576, 550), file='./assets/handler/POPUP_CANCEL.png')
POPUP_CONFIRM = Button(area=(704, 493, 876, 550), color=(94, 144, 204), button=(704, 493, 876, 550), file='./assets/handler/POPUP_CONFIRM.png')

View File

@ -13,6 +13,13 @@ fleet_lock.add_status('off', check_button=FLEET_UNLOCKED)
class FastForwardHandler(ModuleBase):
def handle_fast_forward(self):
if not self.appear(MAP_STAR_1) or not self.appear(MAP_STAR_2) or not self.appear(MAP_STAR_3):
logger.info('Campaign is not 3-star cleared.')
return False
if not self.appear(MAP_GREEN):
logger.info('Campaign is not green sea.')
return False
if not fast_forward.appear(main=self):
self.config.ENABLE_FAST_FORWARD = False
self.config.MAP_HAS_AMBUSH = True

View File

@ -90,11 +90,11 @@ class Camera(InfoBarHandler):
known_exception = self.info_bar_count()
if len(self.grids.horizontal) > self.map.shape[1] + 2 or len(self.grids.vertical) > self.map.shape[0] + 2:
if not known_exception:
logger.warn('Perspective Error. Too many lines')
logger.info('Perspective Error. Too many lines')
self.grids.correct = False
if len(self.grids.horizontal) <= 3 or len(self.grids.vertical) <= 3:
if not known_exception:
logger.warn('Perspective Error. Too few lines')
logger.info('Perspective Error. Too few lines')
self.grids.correct = False
if not self.grids.correct:
@ -163,7 +163,7 @@ class Camera(InfoBarHandler):
except PerspectiveError as e:
msg = str(e).split(':')[1].strip()
logger.warning(f'Camera outside map: {msg}')
logger.info(f'Camera outside map: {msg}')
dic = {'to the left': (2, 0), 'to the right': (-2, 0), 'to the lower': (0, 2), 'to the upper': (0, -2)}
self._map_swipe(dic[msg])
continue

View File

@ -245,6 +245,10 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
else:
return 'no_searching'
if 'boss' in expected:
return 'in_stage'
return 'no_searching'
def fleet_at(self, grid, fleet=None):
"""
Args:

View File

@ -55,6 +55,8 @@ class MapOperation(UrgentCommissionHandler, EnemySearchingHandler, FleetPreparat
# Map preparation
if map_timer.reached() and self.appear(MAP_PREPARATION):
self.device.sleep(0.3) # Wait for map information.
self.device.screenshot()
self.handle_fast_forward()
self.device.click(MAP_PREPARATION)
map_timer.reset()

View File

@ -111,7 +111,7 @@ class Perspective:
'\\' if self.right_edge else ' ', len(self.vertical), len(vertical), len(edge_v))
)
if len(horizontal) - len(self.horizontal) >= 3 or len(vertical) - len(self.vertical) >= 3:
logger.warning('Too many deleted lines')
logger.info('Too many deleted lines')
# self.save_error_image()
def load_image(self, image):
@ -308,7 +308,7 @@ class Perspective:
diff = abs(coincident_point[1] - 129)
if diff > 3:
self.correct = False
logger.warning('%s coincident point unexpected: %s' % (
logger.info('%s coincident point unexpected: %s' % (
'Horizontal' if is_horizontal else 'Vertical',
str(coincident_point)))
if diff > 6:

View File

@ -373,10 +373,13 @@ class RewardCommission(UI, InfoBarHandler, PopupHandler):
comm_timer.reset()
if self.handle_popup_confirm():
comm_timer.reset()
pass
if self.appear_then_click(COMMISSION_START, interval=3):
comm_timer.reset()
pass
if self.appear_then_click(COMMISSION_ADVICE, interval=3):
comm_timer.reset()
pass
if self.handle_info_bar():