Add: 增加阵型选择

- 修复了开关控制点击的按钮错误的问题
This commit is contained in:
LmeSzinc 2020-04-10 00:55:49 +08:00
parent 95d84d11ac
commit 40298c4e23
16 changed files with 87 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -56,11 +56,13 @@ class Switch:
else: else:
main.device.screenshot() main.device.screenshot()
matched = None
current = 'unknown' current = 'unknown'
for data in self.status_list: for data in self.status_list:
if main.appear(data['check_button'], offset=data['offset']): if main.appear(data['check_button'], offset=data['offset']):
current = data['status'] current = data['status']
logger.attr(self.name, current) logger.attr(self.name, current)
matched = data
if current == status: if current == status:
return changed return changed
if current == 'unknown': if current == 'unknown':
@ -68,6 +70,6 @@ class Switch:
for data in self.status_list: for data in self.status_list:
if data['status'] == status: if data['status'] == status:
main.device.click(data['click_button']) main.device.click(data['click_button'] if matched is None else matched['click_button'])
main.device.sleep(data['sleep']) main.device.sleep(data['sleep'])
changed = True changed = True

View File

@ -8,6 +8,10 @@ FAST_FORWARD_OFF = Button(area=(984, 587, 1021, 606), color=(252, 252, 252), but
FAST_FORWARD_ON = Button(area=(1025, 587, 1063, 606), color=(252, 252, 252), button=(1025, 587, 1063, 606), file='./assets/handler/FAST_FORWARD_ON.png') FAST_FORWARD_ON = Button(area=(1025, 587, 1063, 606), color=(252, 252, 252), button=(1025, 587, 1063, 606), file='./assets/handler/FAST_FORWARD_ON.png')
FLEET_LOCKED = Button(area=(1197, 502, 1274, 519), color=(146, 186, 179), button=(1197, 502, 1274, 519), file='./assets/handler/FLEET_LOCKED.png') FLEET_LOCKED = Button(area=(1197, 502, 1274, 519), color=(146, 186, 179), button=(1197, 502, 1274, 519), file='./assets/handler/FLEET_LOCKED.png')
FLEET_UNLOCKED = Button(area=(1197, 502, 1274, 519), color=(195, 168, 168), button=(1197, 502, 1274, 519), file='./assets/handler/FLEET_UNLOCKED.png') FLEET_UNLOCKED = Button(area=(1197, 502, 1274, 519), color=(195, 168, 168), button=(1197, 502, 1274, 519), file='./assets/handler/FLEET_UNLOCKED.png')
FORMATION_1 = Button(area=(1108, 415, 1170, 477), color=(80, 82, 93), button=(1108, 415, 1170, 477), file='./assets/handler/FORMATION_1.png')
FORMATION_2 = Button(area=(1108, 415, 1170, 477), color=(80, 82, 92), button=(1108, 415, 1170, 477), file='./assets/handler/FORMATION_2.png')
FORMATION_3 = Button(area=(1108, 415, 1170, 477), color=(79, 82, 92), button=(1108, 415, 1170, 477), file='./assets/handler/FORMATION_3.png')
FORMATION_LOCATION = Button(area=(145, 115, 437, 159), color=(103, 118, 118), button=(145, 115, 437, 159), file='./assets/handler/FORMATION_LOCATION.png')
GET_AMMO = Button(area=(792, 315, 794, 333), color=(251, 250, 255), button=(792, 315, 794, 333), file='./assets/handler/GET_AMMO.png') GET_AMMO = Button(area=(792, 315, 794, 333), color=(251, 250, 255), button=(792, 315, 794, 333), file='./assets/handler/GET_AMMO.png')
GET_ITEMS_1 = Button(area=(538, 217, 741, 253), color=(160, 192, 248), button=(924, 653, 943, 672), file='./assets/handler/GET_ITEMS_1.png') GET_ITEMS_1 = Button(area=(538, 217, 741, 253), color=(160, 192, 248), button=(924, 653, 943, 672), file='./assets/handler/GET_ITEMS_1.png')
GET_MISSION = Button(area=(553, 491, 727, 551), color=(96, 144, 204), button=(553, 491, 727, 551), file='./assets/handler/GET_MISSION.png') GET_MISSION = Button(area=(553, 491, 727, 551), color=(96, 144, 204), button=(553, 491, 727, 551), file='./assets/handler/GET_MISSION.png')
@ -22,4 +26,9 @@ 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_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_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_ENEMY_SEARCHING = Button(area=(531, 320, 864, 382), color=(200, 99, 91), button=(531, 320, 864, 382), file='./assets/handler/MAP_ENEMY_SEARCHING.png')
MYSTERY_ITEM = Button(area=(589, 294, 691, 427), color=(144, 127, 83), button=(589, 294, 691, 427), file='./assets/handler/MYSTERY_ITEM.png') MYSTERY_ITEM = Button(area=(589, 294, 691, 427), color=(144, 127, 83), button=(589, 294, 691, 427), file='./assets/handler/MYSTERY_ITEM.png')
STRATEGY_OPEN_1 = Button(area=(1176, 366, 1275, 393), color=(128, 155, 218), button=(1060, 406, 1092, 485), file='./assets/handler/STRATEGY_OPEN_1.png') STRATEGY_OPEN = Button(area=(1198, 411, 1269, 471), color=(81, 85, 101), button=(1198, 411, 1269, 471), file='./assets/handler/STRATEGY_OPEN.png')
STRATEGY_OPENED = Button(area=(1176, 366, 1275, 393), color=(128, 155, 218), button=(1060, 406, 1092, 485), file='./assets/handler/STRATEGY_OPENED.png')
SUBMARINE_HUNT_OFF = Button(area=(1200, 415, 1262, 477), color=(125, 127, 132), button=(1200, 415, 1262, 477), file='./assets/handler/SUBMARINE_HUNT_OFF.png')
SUBMARINE_HUNT_ON = Button(area=(1200, 415, 1262, 477), color=(124, 125, 132), button=(1200, 415, 1262, 477), file='./assets/handler/SUBMARINE_HUNT_ON.png')
SUBMARINE_VIEW_OFF = Button(area=(1108, 415, 1170, 477), color=(129, 130, 135), button=(1108, 415, 1170, 477), file='./assets/handler/SUBMARINE_VIEW_OFF.png')
SUBMARINE_VIEW_ON = Button(area=(1108, 415, 1170, 477), color=(134, 135, 141), button=(1108, 415, 1170, 477), file='./assets/handler/SUBMARINE_VIEW_ON.png')

View File

@ -1,11 +1,76 @@
from module.handler.assets import STRATEGY_OPEN_1 from module.base.switch import Switch
from module.handler.assets import *
from module.handler.info_bar import InfoBarHandler from module.handler.info_bar import InfoBarHandler
from module.logger import logger
formation = Switch('Formation')
formation.add_status('1', check_button=FORMATION_1, offset=120)
formation.add_status('2', check_button=FORMATION_2, offset=120)
formation.add_status('3', check_button=FORMATION_3, offset=120)
submarine_view = Switch('Submarine_view')
submarine_view.add_status('on', check_button=SUBMARINE_VIEW_ON, offset=120)
submarine_view.add_status('off', check_button=SUBMARINE_VIEW_OFF, offset=120)
submarine_hunt = Switch('Submarine_hunt')
submarine_hunt.add_status('on', check_button=SUBMARINE_HUNT_ON, offset=120)
submarine_hunt.add_status('off', check_button=SUBMARINE_HUNT_OFF, offset=120)
class StrategyHandler(InfoBarHandler): class StrategyHandler(InfoBarHandler):
fleet_1_formation_fixed = False
fleet_2_formation_fixed = False
def handle_opened_strategy_bar(self): def handle_opened_strategy_bar(self):
if self.appear_then_click(STRATEGY_OPEN_1): if self.appear_then_click(STRATEGY_OPENED, offset=120):
self.device.sleep(0.5) self.device.sleep(0.5)
return True return True
return False return False
def strategy_open(self):
self.device.click(STRATEGY_OPEN)
self.device.sleep(0.5)
def strategy_close(self):
self.appear_then_click(STRATEGY_OPENED, offset=120)
self.device.sleep(0.5)
def strategy_set_execute(self, formation_index=2, sub_view=False, sub_hunt=False):
"""
Args:
formation_index (int):
sub_view (bool):
sub_hunt (bool):
"""
logger.info(f'Strategy set: formation={formation_index}, submarine_view={sub_view}, submarine_hunt={sub_hunt}')
self.strategy_open()
self.device.screenshot()
formation.set(str(formation_index), main=self)
if submarine_view.appear(main=self):
submarine_view.set('on' if sub_view else 'off', main=self)
if submarine_hunt.appear(main=self):
submarine_hunt.set('on' if sub_hunt else 'off', main=self)
self.strategy_close()
def handle_strategy(self, index):
"""
Args:
index (int): Fleet index.
Returns:
bool: If changed.
"""
if self.__getattribute__(f'fleet_{index}_formation_fixed'):
return False
self.strategy_set_execute(
formation_index=self.config.__getattribute__(f'FLEET_{index}_FORMATION'),
sub_view=False,
sub_hunt=self.config.SUBMARINE and self.config.SUBMARINE_MODE == 'hunt_only'
)
self.__setattr__(f'fleet_{index}_formation_fixed', True)
return True

View File

@ -48,6 +48,7 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
self.fleet_switch_click() self.fleet_switch_click()
self.fleet_current_index = 1 if self.fleet_current_index == 2 else 2 self.fleet_current_index = 1 if self.fleet_current_index == 2 else 2
self.camera = self.fleet_current self.camera = self.fleet_current
self.handle_strategy(index=self.fleet_current_index)
self.update() self.update()
self.find_path_initial() self.find_path_initial()
self.map.show_cost() self.map.show_cost()
@ -227,6 +228,7 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
self.map = map_ self.map = map_
self.map.reset() self.map.reset()
self.hp_init() self.hp_init()
self.handle_strategy(index=self.fleet_current_index)
self.ensure_edge_insight(preset=self.map.in_map_swipe_preset_data) self.ensure_edge_insight(preset=self.map.in_map_swipe_preset_data)
self.full_scan(battle_count=self.battle_count, mystery_count=self.mystery_count, siren_count=self.siren_count) self.full_scan(battle_count=self.battle_count, mystery_count=self.mystery_count, siren_count=self.siren_count)
self.find_current_fleet() self.find_current_fleet()

View File

@ -1,6 +1,7 @@
from module.base.timer import Timer from module.base.timer import Timer
from module.handler.enemy_searching import EnemySearchingHandler from module.handler.enemy_searching import EnemySearchingHandler
from module.handler.fast_forward import FastForwardHandler from module.handler.fast_forward import FastForwardHandler
from module.handler.strategy import StrategyHandler
from module.handler.urgent_commission import UrgentCommissionHandler from module.handler.urgent_commission import UrgentCommissionHandler
from module.logger import logger from module.logger import logger
from module.map.assets import * from module.map.assets import *
@ -9,7 +10,8 @@ from module.map.map_fleet_preparation import FleetPreparation
from module.retire.retirement import Retirement from module.retire.retirement import Retirement
class MapOperation(UrgentCommissionHandler, EnemySearchingHandler, FleetPreparation, Retirement, FastForwardHandler): class MapOperation(UrgentCommissionHandler, EnemySearchingHandler, FleetPreparation, Retirement, FastForwardHandler,
StrategyHandler):
def fleet_switch_click(self): def fleet_switch_click(self):
""" """
Switch fleet. Switch fleet.