2020-03-28 17:22:46 +00:00
|
|
|
from module.base.timer import Timer
|
|
|
|
from module.equipment.assets import *
|
2020-05-15 06:18:14 +00:00
|
|
|
from module.handler.info_handler import InfoHandler
|
2020-03-28 17:22:46 +00:00
|
|
|
from module.logger import logger
|
|
|
|
from module.ui.assets import BACK_ARROW
|
|
|
|
|
2020-04-06 17:52:47 +00:00
|
|
|
SWIPE_DISTANCE = 250
|
2020-03-28 17:22:46 +00:00
|
|
|
SWIPE_RANDOM_RANGE = (-40, -20, 40, 20)
|
|
|
|
|
|
|
|
|
2020-05-15 06:18:14 +00:00
|
|
|
class Equipment(InfoHandler):
|
2020-03-28 17:22:46 +00:00
|
|
|
equipment_has_take_on = False
|
|
|
|
|
2020-04-06 17:52:47 +00:00
|
|
|
def _view_swipe(self, distance):
|
2020-05-08 11:07:06 +00:00
|
|
|
swipe_timer = Timer(3, count=3)
|
2020-04-06 17:52:47 +00:00
|
|
|
while 1:
|
|
|
|
SWIPE_CHECK.load_color(self.device.image)
|
2020-05-08 11:07:06 +00:00
|
|
|
if not swipe_timer.started() or swipe_timer.reached():
|
|
|
|
swipe_timer.reset()
|
|
|
|
self.device.swipe(vector=(distance, 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
|
|
|
|
padding=0, duration=(0.1, 0.12))
|
2020-04-06 17:52:47 +00:00
|
|
|
|
Add: 适配第一章, 修复大量bug
- 修复处理夜间委托时, 出现递归调用的问题
- 增加红脸出击确认的功能
- 增加了透视识别错误图片保存的开关
- 修复了地图太小时, 透视识别报错的问题
- 修复了相机位于地图外时, 透视识别出错的问题
- 修复了离开退役时, 会连击的问题
- 修复了同时出现低心情和船坞已满弹窗时, 卡住的问题
- 更新了一键退役实装后的安全点击的位置
- 修复了换装滑动失败时, 卡住的问题
- 修复了关闭自动收获后, 出现委托完成的提示是, 进图卡住的问题
- 修复了, 无正在跑的委托时, 报错的问题
2020-04-11 07:23:51 +00:00
|
|
|
self.device.screenshot()
|
|
|
|
if SWIPE_CHECK.match(self.device.image):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if self.appear(EQUIPMENT_OPEN) and not SWIPE_CHECK.match(self.device.image):
|
2020-04-06 17:52:47 +00:00
|
|
|
break
|
|
|
|
|
2020-03-28 17:22:46 +00:00
|
|
|
def _view_next(self):
|
2020-04-06 17:52:47 +00:00
|
|
|
self._view_swipe(distance=-SWIPE_DISTANCE)
|
2020-03-28 17:22:46 +00:00
|
|
|
|
|
|
|
def _view_prev(self):
|
2020-04-06 17:52:47 +00:00
|
|
|
self._view_swipe(distance=SWIPE_DISTANCE)
|
2020-03-28 17:22:46 +00:00
|
|
|
|
|
|
|
def _equip_enter(self, enter):
|
|
|
|
enter_timer = Timer(5)
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
if enter_timer.reached():
|
|
|
|
self.device.long_click(enter, duration=(1.5, 1.7))
|
|
|
|
enter_timer.reset()
|
|
|
|
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if self.appear(EQUIPMENT_OPEN):
|
|
|
|
break
|
|
|
|
|
|
|
|
def _equip_exit(self, out):
|
|
|
|
quit_timer = Timer(3)
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
# End
|
|
|
|
if self.appear(out):
|
|
|
|
break
|
|
|
|
|
|
|
|
if quit_timer.reached() and self.appear(BACK_ARROW):
|
|
|
|
# self.device.sleep(1)
|
|
|
|
self.device.click(BACK_ARROW)
|
|
|
|
self.device.sleep((0.2, 0.3))
|
|
|
|
quit_timer.reset()
|
|
|
|
continue
|
|
|
|
|
|
|
|
def _equip_take_off_one(self):
|
|
|
|
bar_timer = Timer(5)
|
|
|
|
off_timer = Timer(5)
|
|
|
|
confirm_timer = Timer(5)
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
if bar_timer.reached() and not self.appear(EQUIP_1, offset=10):
|
|
|
|
self.device.click(EQUIPMENT_OPEN)
|
|
|
|
bar_timer.reset()
|
|
|
|
continue
|
|
|
|
|
|
|
|
if off_timer.reached() and not self.info_bar_count() and self.appear_then_click(EQUIP_OFF, offset=10):
|
|
|
|
off_timer.reset()
|
|
|
|
continue
|
|
|
|
|
2020-04-13 15:00:19 +00:00
|
|
|
if confirm_timer.reached() and self.handle_popup_confirm():
|
2020-03-28 17:22:46 +00:00
|
|
|
confirm_timer.reset()
|
|
|
|
continue
|
|
|
|
|
|
|
|
# End
|
|
|
|
# if self.handle_info_bar():
|
|
|
|
# break
|
|
|
|
if off_timer.started() and self.info_bar_count():
|
|
|
|
break
|
|
|
|
|
|
|
|
def equipment_take_off(self, enter, out, fleet):
|
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
enter (Button): Long click to edit equipment.
|
|
|
|
out (Button): Button to confirm exit success.
|
|
|
|
fleet (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
|
|
|
|
"""
|
|
|
|
logger.hr('Equipment take off')
|
|
|
|
self._equip_enter(enter)
|
|
|
|
|
|
|
|
for index in '9'.join([str(x) for x in fleet if x > 0]):
|
|
|
|
index = int(index)
|
|
|
|
if index == 9:
|
|
|
|
self._view_next()
|
|
|
|
else:
|
|
|
|
self._equip_take_off_one()
|
|
|
|
|
|
|
|
self._equip_exit(out)
|
|
|
|
self.equipment_has_take_on = False
|
|
|
|
|
|
|
|
def _equip_take_on_one(self, index):
|
|
|
|
bar_timer = Timer(5)
|
|
|
|
on_timer = Timer(5)
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
self.device.screenshot()
|
|
|
|
|
|
|
|
if bar_timer.reached() and not self.appear(EQUIP_1, offset=10):
|
|
|
|
self.device.click(EQUIPMENT_OPEN)
|
|
|
|
# self.device.sleep(0.3)
|
|
|
|
bar_timer.reset()
|
|
|
|
continue
|
|
|
|
|
|
|
|
if on_timer.reached() and self.appear(EQUIP_1, offset=10) and not self.info_bar_count():
|
|
|
|
if index == 1:
|
|
|
|
self.device.click(EQUIP_1)
|
|
|
|
elif index == 2:
|
|
|
|
self.device.click(EQUIP_2)
|
|
|
|
elif index == 3:
|
|
|
|
self.device.click(EQUIP_3)
|
|
|
|
|
|
|
|
on_timer.reset()
|
|
|
|
continue
|
|
|
|
|
|
|
|
# End
|
|
|
|
# if self.handle_info_bar():
|
|
|
|
# break
|
|
|
|
if on_timer.started() and self.info_bar_count():
|
|
|
|
break
|
|
|
|
|
|
|
|
def equipment_take_on(self, enter, out, fleet):
|
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
enter (Button): Long click to edit equipment.
|
|
|
|
out (Button): Button to confirm exit success.
|
|
|
|
fleet (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
|
|
|
|
"""
|
|
|
|
logger.hr('Equipment take on')
|
|
|
|
self._equip_enter(enter)
|
|
|
|
|
|
|
|
for index in '9'.join([str(x) for x in fleet if x > 0]):
|
|
|
|
index = int(index)
|
|
|
|
if index == 9:
|
|
|
|
self._view_next()
|
|
|
|
else:
|
|
|
|
self._equip_take_on_one(index=index)
|
|
|
|
|
|
|
|
self._equip_exit(out)
|
|
|
|
self.equipment_has_take_on = True
|