Fix: 修复了一堆bug

- 修复了上一场战斗的队伍位置信息会保留到下一场战斗的问题
- 修复了领取大量任务时, 不会等待的问题
- 修复了不计算BOSS队心情消耗的问题
- 增加了碰磁BOSS所有刷新点的方法
- 修复了没有检测到BOSS时停滞的问题
- 修复了处理夜间委托
- 修复了丢失地图信息补全不起作用的问题
- 修复了换装滑动失败后, 陷入死循环的问题
- 删除了微层混合AB图的一些多余逻辑
- 7-2现在会优先捡全部问号了, 不需要先捡附近的来减少行走距离.
This commit is contained in:
LmeSzinc 2020-04-07 01:52:47 +08:00
parent 7523847fac
commit 87554793d3
22 changed files with 119 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -53,6 +53,9 @@ class Campaign(CampaignBase, HardEquipment):
self._goto(grids[0])
raise CampaignEnd('BOSS Clear.')
logger.warning('BOSS not detected, trying all boss spawn point.')
self.clear_potential_boss()
return False
def equipment_take_off_when_finished(self):

View File

@ -57,7 +57,7 @@ class Campaign(CampaignBase):
ignore = SelectedGrids([A2])
if self.fleet_at(G3, fleet=2):
ignore = SelectedGrids([H3])
self.clear_all_mystery(nearby=True, ignore=ignore)
self.clear_all_mystery(nearby=False, ignore=ignore)
if self.clear_roadblocks([ROAD_MAIN]):
return True

View File

@ -55,9 +55,6 @@ class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_boss():
return True
if self.clear_siren():
return True

View File

@ -40,9 +40,6 @@ class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_boss():
return True
if self.clear_siren():
return True

View File

@ -47,9 +47,6 @@ class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_boss():
return True
if self.clear_siren():
return True

View File

@ -38,9 +38,6 @@ class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_boss():
return True
if self.clear_siren():
return True

View File

@ -43,9 +43,6 @@ class Campaign(CampaignBase):
MAP = MAP
def battle_0(self):
if self.clear_boss():
return True
if self.clear_siren():
return True

View File

@ -77,14 +77,14 @@ class Button:
This method is irreversible, this would be only use in some special occasion.
Args:
image (PIL.Image.Image): Another screenshot.
image: Another screenshot.
Returns:
tuple: Color (r, g, b).
"""
color = get_color(image, self.area)
self.color = color
return color
self.color = get_color(image, self.area)
self.image = np.array(image.crop(self.area))
return self.color
def ensure_template(self):
"""

View File

@ -90,7 +90,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
logger.info('Combat preparation.')
if emotion_reduce and not self.config.ENABLE_MAP_FLEET_LOCK:
self.emotion.wait()
self.emotion.wait(fleet=fleet_index)
if balance_hp:
self.balance_scout_hp()
# logger.info('start combat')
@ -263,27 +263,22 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
if expected_end():
break
def combat(self, banlance_hp=None, emotion_reduce=None, func=None, call_submarine_at_boss=None, save_get_items=None,
expected_end=None):
def combat(self, balance_hp=None, emotion_reduce=None, func=None, call_submarine_at_boss=None, save_get_items=None,
expected_end=None, fleet_index=1):
"""
Execute a combat.
"""
banlance_hp = banlance_hp if banlance_hp is not None else self.config.ENABLE_HP_BALANCE
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
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
if expected_end == 'in_stage':
emotion_reduce = False
fleet_index = 2
else:
fleet_index = 1
# if not hasattr(self, 'emotion'):
# self.emotion = Emotion(config=self.config)
self.combat_preparation(
balance_hp=banlance_hp, emotion_reduce=emotion_reduce, auto=auto, fleet_index=fleet_index)
balance_hp=balance_hp, emotion_reduce=emotion_reduce, auto=auto, fleet_index=fleet_index)
self.combat_execute(
func=func, call_submarine_at_boss=call_submarine_at_boss, save_get_items=save_get_items)
self.combat_status(

View File

@ -62,7 +62,12 @@ class Emotion:
self.record()
def recovered_time(self, fleet=(1, 2)):
# fleet = [2, 3] if self.config.USING_SPARE_FLEET else [1, 2]
"""
Args:
fleet (int, tuple):
"""
if isinstance(fleet, int):
fleet = (fleet,)
recover_count = [
(self.emotion_limit(index) - int(self.emotion[config_name][f'fleet_{index}_emotion'])) \
// self.recover_value(index) for index in fleet]
@ -85,9 +90,13 @@ class Emotion:
def emotion_recovered(self, fleet):
pass
def wait(self):
def wait(self, fleet=(1, 2)):
"""
Args:
fleet (int, tuple):
"""
self.update()
recovered_time = self.recovered_time()
recovered_time = self.recovered_time(fleet=fleet)
while 1:
if datetime.now() > recovered_time:
break

View File

@ -46,3 +46,12 @@ class Device(Screenshot, Control):
"""
self.handle_night_commission()
return super().screenshot()
def click(self, button, adb=False):
self.handle_night_commission()
return super().click(button, adb=adb)
def swipe(self, vector, box=(123, 159, 1193, 628), random_range=(0, 0, 0, 0), padding=15, duration=(0.1, 0.2)):
self.handle_night_commission()
return super().swipe(vector=vector, box=box, random_range=random_range, padding=padding, duration=duration)

View File

@ -15,3 +15,4 @@ FLEET_NEXT = Button(area=(1234, 327, 1254, 356), color=(72, 93, 125), button=(12
FLEET_PREV = Button(area=(26, 327, 46, 356), color=(72, 93, 125), button=(26, 327, 46, 356), file='./assets/equipment/FLEET_PREV.png')
OCR_FLEET_INDEX = Button(area=(958, 124, 984, 155), color=(46, 72, 117), button=(958, 124, 984, 155), file='./assets/equipment/OCR_FLEET_INDEX.png')
SWIPE_AREA = Button(area=(220, 167, 580, 527), color=(165, 172, 194), button=(220, 167, 580, 527), file='./assets/equipment/SWIPE_AREA.png')
SWIPE_CHECK = Button(area=(190, 353, 610, 455), color=(171, 180, 198), button=(190, 353, 610, 455), file='./assets/equipment/SWIPE_CHECK.png')

View File

@ -4,22 +4,33 @@ from module.handler.info_bar import InfoBarHandler
from module.logger import logger
from module.ui.assets import BACK_ARROW
SWIPE_DISTANCE = (350, 0)
SWIPE_DISTANCE = 250
SWIPE_RANDOM_RANGE = (-40, -20, 40, 20)
class Equipment(InfoBarHandler):
equipment_has_take_on = False
def _view_swipe(self, distance):
while 1:
SWIPE_CHECK.load_color(self.device.image)
self.device.swipe(vector=(distance, 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
padding=0, duration=(0.1, 0.12))
while 1:
self.device.screenshot()
if SWIPE_CHECK.match(self.device.image):
continue
if self.appear(EQUIPMENT_OPEN):
break
if not SWIPE_CHECK.match(self.device.image):
break
def _view_next(self):
self.device.swipe(vector=(-SWIPE_DISTANCE[0], 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
padding=0, duration=(0.1, 0.12))
self.wait_until_appear(EQUIPMENT_OPEN)
self._view_swipe(distance=-SWIPE_DISTANCE)
def _view_prev(self):
self.device.swipe(vector=(SWIPE_DISTANCE[0], 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
padding=0, duration=(0.1, 0.12))
self.wait_until_appear(EQUIPMENT_OPEN)
self._view_swipe(distance=SWIPE_DISTANCE)
def _equip_enter(self, enter):
enter_timer = Timer(5)

View File

@ -100,7 +100,7 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
# break
if self.combat_appear():
self.combat(expected_end=self._expected_combat_end)
self.combat(expected_end=self._expected_combat_end, fleet_index=self.fleet_current_index)
arrived = True
result = 'combat'
self.battle_count += 1
@ -233,7 +233,7 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation):
if data.get('battle') == self.battle_count and data.get('boss', 0):
return 'in_stage'
if data.get('battle') == self.battle_count + 1:
if data.get('enemy', 0) > 0:
if data.get('enemy', 0) + data.get('siren', 0) > 0:
return 'with_searching'
else:
return 'no_searching'

View File

@ -167,3 +167,11 @@ class GridInfo:
self.is_boss = False
self.is_ammo = False
self.is_siren = False
def reset(self):
self.wipe_out()
self.is_fleet = False
self.is_current_fleet = False
self.is_submarine = False
self.is_cleared = False

View File

@ -14,8 +14,8 @@ class Map(Fleet):
logger.info('Clear enemy: %s' % grid)
expected = f'combat_{expected}' if expected else 'combat'
self.show_fleet()
if self.config.ENABLE_EMOTION_REDUCE and self.config.ENABLE_MAP_FLEET_LOCK and 'boss' not in expected:
self.emotion.wait()
if self.config.ENABLE_EMOTION_REDUCE and self.config.ENABLE_MAP_FLEET_LOCK:
self.emotion.wait(fleet=self.fleet_current_index)
self.goto(grid, expected=expected)
self.full_scan(battle_count=self.battle_count, mystery_count=self.mystery_count, siren_count=self.siren_count)
@ -258,8 +258,29 @@ class Map(Fleet):
self.clear_chosen_enemy(grids[0], expected='boss')
raise CampaignEnd('BOSS Clear.')
logger.warning('BOSS not detected, trying all boss spawn point.')
self.clear_potential_boss()
return False
def clear_potential_boss(self):
"""
Method to step on all boss spawn point when boss not detected.
"""
grids = self.map.select(may_boss=True, is_accessible=True)
logger.info('May boss: %s' % self.map.select(may_boss=True))
battle_count = self.battle_count
for grid in grids:
logger.hr('Clear BOSS')
grids = grids.sort(cost=True, weight=True)
logger.info('Grid: %s' % str(grid))
self.clear_chosen_enemy(grid, expected='boss')
if self.battle_count - battle_count > 0:
raise CampaignEnd('BOSS Clear.')
else:
logger.info('Boss guessing incorrect.')
def clear_siren(self):
grids = self.map.select(may_siren=True, is_enemy=True, is_accessible=True)
grids = grids.add(self.map.select(may_siren=True, is_siren=True, is_accessible=True))

View File

@ -128,8 +128,7 @@ class CampaignMap:
def reset(self):
for grid in self:
grid.wipe_out()
grid.is_cleared = False
grid.reset()
def reset_fleet(self):
for grid in self:
@ -319,8 +318,15 @@ class CampaignMap:
missing[attr] -= 1
for grid in self:
if grid.is_fleet or grid.is_mystery or grid.is_siren:
upper = tuple(np.array(grid.location) + (0, -1))
if not grid.is_fleet and not grid.is_mystery and not grid.is_siren:
continue
cover = [(0, -1)]
if grid.is_current_fleet:
cover.append((0, -2))
for upper in cover:
upper = tuple(np.array(grid.location) + upper)
if upper in self:
upper = self[upper]
for attr in may.keys():
@ -345,7 +351,7 @@ class CampaignMap:
# predict
for grid in self:
if not grid.is_fleet or not grid.is_mystery:
if not grid.is_fleet and not grid.is_mystery:
continue
cover = [(0, -1)]

View File

@ -16,7 +16,7 @@ COMMISSION_URGENT = Button(area=(35, 231, 68, 281), color=(215, 188, 124), butto
EXP_INFO_S_REWARD = Button(area=(498, 140, 557, 154), color=(233, 241, 127), button=(498, 140, 557, 154), file='./assets/reward/EXP_INFO_S_REWARD.png')
MISSION_MULTI = Button(area=(1041, 8, 1101, 39), color=(226, 192, 142), button=(1041, 8, 1101, 39), file='./assets/reward/MISSION_MULTI.png')
MISSION_NOTICE = Button(area=(940, 670, 945, 681), color=(183, 83, 66), button=(940, 670, 945, 681), file='./assets/reward/MISSION_NOTICE.png')
MISSION_SIGNAL = Button(area=(1093, 118, 1179, 177), color=(115, 155, 218), button=(1093, 118, 1179, 177), file='./assets/reward/MISSION_SIGNAL.png')
MISSION_SINGLE = Button(area=(1093, 118, 1179, 177), color=(115, 155, 218), button=(1093, 118, 1179, 177), file='./assets/reward/MISSION_SIGNAL.png')
OIL = Button(area=(162, 64, 182, 91), color=(71, 72, 71), button=(162, 64, 182, 91), file='./assets/reward/OIL.png')
REWARD_1 = Button(area=(383, 285, 503, 297), color=(238, 168, 81), button=(383, 285, 503, 297), file='./assets/reward/REWARD_1.png')
REWARD_2 = Button(area=(383, 404, 503, 444), color=(233, 165, 67), button=(383, 404, 503, 444), file='./assets/reward/REWARD_2.png')

View File

@ -428,11 +428,13 @@ class RewardCommission(UI, InfoBarHandler):
logger.hr('Commission run', level=2)
if self.daily_choose:
for comm in self.daily_choose:
self._commission_ensure_mode('daily')
if not self._commission_ensure_mode('daily'):
self._commission_mode_reset()
self._commission_find_and_start(comm)
if self.urgent_choose:
for comm in self.urgent_choose:
self._commission_ensure_mode('urgent')
if not self._commission_ensure_mode('urgent'):
self._commission_mode_reset()
self._commission_find_and_start(comm)
if not self.daily_choose and not self.urgent_choose:
logger.info('No commission chose')

View File

@ -65,6 +65,7 @@ class Reward(RewardCommission):
for button in [EXP_INFO_S_REWARD, GET_ITEMS_1, GET_ITEMS_2, GET_SHIP]:
if self.appear(button, interval=1):
self.device.click(REWARD_SAVE_CLICK)
click_timer.reset()
exit_timer.reset()
reward = True
continue
@ -73,6 +74,7 @@ class Reward(RewardCommission):
if not click_timer.reached():
continue
if self.appear_then_click(button, interval=1):
btn.remove(button)
exit_timer.reset()
click_timer.reset()
reward = True
@ -99,27 +101,37 @@ class Reward(RewardCommission):
reward = False
exit_timer = Timer(1)
click_timer = Timer(1)
timeout = Timer(10)
exit_timer.start()
timeout.start()
while 1:
self.device.screenshot()
for button in [GET_ITEMS_1, GET_ITEMS_2, GET_SHIP]:
if self.appear_then_click(button, interval=1):
for button in [GET_ITEMS_1, GET_ITEMS_2]:
if self.appear_then_click(button, offset=(30, 30), interval=1):
exit_timer.reset()
reward = True
continue
for button in [MISSION_MULTI, MISSION_SIGNAL]:
for button in [MISSION_MULTI, MISSION_SINGLE]:
if not click_timer.reached():
continue
if self.appear_then_click(button, interval=1):
exit_timer.reset()
click_timer.reset()
reward = True
continue
if not self.appear(MISSION_CHECK):
if self.appear_then_click(GET_SHIP, interval=1):
click_timer.reset()
exit_timer.reset()
continue
# End
if exit_timer.reached():
if reward and exit_timer.reached():
break
if timeout.reached():
logger.warning('Wait get items timeout.')
break
self.ui_goto(page_main, skip_first_screenshot=True)