Add: 增加了掉船的截图, 修复丢失截图的问题

- 调整了战斗模块的函数
- 修改了GUI的文字说明
- 修复有文字窗口时紧急委托截图的问题
This commit is contained in:
LmeSzinc 2020-04-15 21:44:11 +08:00
parent 8ce405f28a
commit b94baf8831
6 changed files with 60 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -84,4 +84,5 @@ class ModuleBase:
return self.device.image.crop(button.area) return self.device.image.crop(button.area)
def interval_reset(self, button): def interval_reset(self, button):
self.interval_timer[button.name].reset() if button.name in self.interval_timer:
self.interval_timer[button.name].reset()

View File

@ -16,6 +16,7 @@ BATTLE_STATUS_S = Button(area=(633, 297, 722, 320), color=(233, 241, 127), butto
COMBAT_AUTO = Button(area=(136, 573, 167, 604), color=(229, 242, 255), button=(136, 573, 167, 604), file='./assets/combat/COMBAT_AUTO.png') COMBAT_AUTO = Button(area=(136, 573, 167, 604), color=(229, 242, 255), button=(136, 573, 167, 604), file='./assets/combat/COMBAT_AUTO.png')
COMBAT_AUTO_SWITCH = Button(area=(18, 38, 36, 56), color=(179, 198, 235), button=(18, 38, 36, 56), file='./assets/combat/COMBAT_AUTO_SWITCH.png') COMBAT_AUTO_SWITCH = Button(area=(18, 38, 36, 56), color=(179, 198, 235), button=(18, 38, 36, 56), file='./assets/combat/COMBAT_AUTO_SWITCH.png')
EXP_INFO_A = Button(area=(389, 100, 444, 116), color=(236, 231, 116), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_A.png') EXP_INFO_A = Button(area=(389, 100, 444, 116), color=(236, 231, 116), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_A.png')
EXP_INFO_CONFIRM = Button(area=(1001, 632, 1173, 689), color=(229, 159, 66), button=(1001, 632, 1173, 689), file='./assets/combat/EXP_INFO_CONFIRM.png')
EXP_INFO_S = Button(area=(396, 122, 457, 137), color=(233, 241, 127), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_S.png') EXP_INFO_S = Button(area=(396, 122, 457, 137), color=(233, 241, 127), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_S.png')
GET_ITEMS_1 = Button(area=(538, 217, 741, 253), color=(160, 192, 248), button=(1000, 631, 1055, 689), file='./assets/combat/GET_ITEMS_1.png') GET_ITEMS_1 = Button(area=(538, 217, 741, 253), color=(160, 192, 248), button=(1000, 631, 1055, 689), file='./assets/combat/GET_ITEMS_1.png')
GET_ITEMS_2 = Button(area=(538, 146, 742, 182), color=(160, 192, 248), button=(1000, 631, 1055, 689), file='./assets/combat/GET_ITEMS_2.png') GET_ITEMS_2 = Button(area=(538, 146, 742, 182), color=(160, 192, 248), button=(1000, 631, 1055, 689), file='./assets/combat/GET_ITEMS_2.png')

View File

@ -22,6 +22,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
CombatAuto, CombatManual): CombatAuto, CombatManual):
_automation_set_timer = Timer(1) _automation_set_timer = Timer(1)
_emotion: Emotion _emotion: Emotion
battle_status_click_interval = 0
@property @property
def emotion(self): def emotion(self):
@ -200,8 +201,6 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
continue continue
# End # End
# if self.appear_then_click(BATTLE_STATUS):
# break
if self.handle_battle_status(save_get_items=save_get_items): if self.handle_battle_status(save_get_items=save_get_items):
break break
@ -213,12 +212,16 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
Returns: Returns:
bool: bool:
""" """
if self.appear_then_click(BATTLE_STATUS_S, screenshot=save_get_items, genre='status'): if self.appear_then_click(BATTLE_STATUS_S, screenshot=save_get_items, genre='status',
self.device.sleep((0.25, 0.5)) interval=self.battle_status_click_interval):
if not save_get_items:
self.device.sleep((0.25, 0.5))
return True return True
if self.appear_then_click(BATTLE_STATUS_A, screenshot=save_get_items, genre='status'): if self.appear_then_click(BATTLE_STATUS_A, screenshot=save_get_items, genre='status',
self.device.sleep((0.25, 0.5)) interval=self.battle_status_click_interval):
logger.warning('Battle status: A') logger.warning('Battle status: A')
if not save_get_items:
self.device.sleep((0.25, 0.5))
return True return True
return False return False
@ -231,15 +234,50 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
Returns: Returns:
bool: bool:
""" """
if self.appear_then_click(GET_ITEMS_1, screenshot=save_get_items, genre='get_items', offset=5): if self.appear_then_click(GET_ITEMS_1, screenshot=save_get_items, genre='get_items', offset=5,
interval=self.battle_status_click_interval):
self.interval_reset(BATTLE_STATUS_S)
self.interval_reset(BATTLE_STATUS_A)
return True
if self.appear_then_click(GET_ITEMS_2, screenshot=save_get_items, genre='get_items', offset=5,
interval=self.battle_status_click_interval):
self.interval_reset(BATTLE_STATUS_S)
self.interval_reset(BATTLE_STATUS_A)
return True return True
if self.appear_then_click(GET_ITEMS_2, screenshot=save_get_items, genre='get_items', offset=5):
return False
return False return False
def handle_get_ship(self): def handle_exp_info(self, save_get_items=False):
if self.appear_then_click(GET_SHIP): """
Args:
save_get_items (bool):
Returns:
bool:
"""
if save_get_items:
return self.appear_then_click(EXP_INFO_CONFIRM, interval=self.battle_status_click_interval)
else:
if self.appear_then_click(EXP_INFO_S):
if not save_get_items:
self.device.sleep((0.25, 0.5))
return True
if self.appear_then_click(EXP_INFO_A):
if not save_get_items:
self.device.sleep((0.25, 0.5))
return True
return False
def handle_get_ship(self, save_get_items=False):
"""
Args:
save_get_items (bool):
Returns:
bool:
"""
if self.appear_then_click(GET_SHIP, screenshot=save_get_items, genre='get_ship'):
return True return True
return False return False
@ -255,19 +293,15 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
self.device.screenshot() self.device.screenshot()
# Combat status # Combat status
if self.handle_get_ship(save_get_items=save_get_items):
continue
if self.handle_get_items(save_get_items=save_get_items): if self.handle_get_items(save_get_items=save_get_items):
continue continue
if self.handle_battle_status(save_get_items=save_get_items): if self.handle_battle_status(save_get_items=save_get_items):
continue continue
if self.handle_popup_confirm(): if self.handle_popup_confirm():
continue continue
if self.handle_get_ship(): if self.handle_exp_info(save_get_items=save_get_items):
continue
if self.appear_then_click(EXP_INFO_S):
self.device.sleep((0.25, 0.5))
continue
if self.appear_then_click(EXP_INFO_A):
self.device.sleep((0.25, 0.5))
continue continue
if self.handle_urgent_commission(save_get_items=save_get_items): if self.handle_urgent_commission(save_get_items=save_get_items):
continue continue
@ -299,6 +333,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
auto = self.config.COMBAT_AUTO_MODE == 'combat_auto' 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 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 save_get_items = save_get_items if save_get_items is not None else self.config.ENABLE_SAVE_GET_ITEMS
self.battle_status_click_interval = 3 if save_get_items else 0
# if not hasattr(self, 'emotion'): # if not hasattr(self, 'emotion'):
# self.emotion = Emotion(config=self.config) # self.emotion = Emotion(config=self.config)

View File

@ -156,7 +156,7 @@ def main(ini_name=''):
rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['', ''], help='SSR') rarity.add_argument('--退役金皮', default=default('--退役金皮'), choices=['', ''], help='SSR')
# 掉落记录 # 掉落记录
drop = setting_parser.add_argument_group('掉落记录', '保存掉落物品的截图, 启用后会减慢结算时的点击速度') drop = setting_parser.add_argument_group('掉落记录', '保存掉落物品的截图, 启用后会放缓结算时的点击速度')
drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['', '']) drop.add_argument('--启用掉落记录', default=default('--启用掉落记录'), choices=['', ''])
drop.add_argument('--掉落保存目录', default=default('--掉落保存目录')) drop.add_argument('--掉落保存目录', default=default('--掉落保存目录'))
@ -257,7 +257,7 @@ def main(ini_name=''):
# ==========主线图========== # ==========主线图==========
main_parser = subs.add_parser('主线图') main_parser = subs.add_parser('主线图')
# 选择关卡 # 选择关卡
stage = main_parser.add_argument_group('选择关卡', '主线图出击, 目前仅支持7-2') stage = main_parser.add_argument_group('选择关卡', '主线图出击, 目前仅支持前三章和7-2')
stage.add_argument('--主线地图出击', default=default('--主线地图出击'), help='例如 7-2') stage.add_argument('--主线地图出击', default=default('--主线地图出击'), help='例如 7-2')
# ==========活动图========== # ==========活动图==========

View File

@ -15,11 +15,12 @@ class UrgentCommissionHandler(InfoBarHandler):
if save_get_items is None: if save_get_items is None:
save_get_items = self.config.ENABLE_SAVE_GET_ITEMS save_get_items = self.config.ENABLE_SAVE_GET_ITEMS
appear = self.appear_then_click(GET_MISSION, offset=True, interval=2) appear = self.appear(GET_MISSION, offset=True, interval=2)
if appear: if appear:
logger.info('Get urgent commission') logger.info('Get urgent commission')
if save_get_items: if save_get_items:
if self.handle_info_bar(): if self.handle_info_bar():
self.device.screenshot() self.device.screenshot()
self.device.save_screenshot('get_mission') self.device.save_screenshot('get_mission')
self.device.click(GET_MISSION)
return appear return appear