Add bag full mailbox mailing flow

This commit is contained in:
王鹏
2026-05-07 08:33:10 +08:00
parent a9e162f00e
commit 2ee9f9d10d
7 changed files with 807 additions and 3 deletions

View File

@@ -256,6 +256,7 @@ class AutoBotMove:
turn_error_key=None,
turn_error_hold_sec=None,
distance_interact_pause_sec=None,
mailbox_route_path=None,
):
self.last_tab_time = 0
self.last_interaction_time = 0 # 记录上一次按互动键的时间
@@ -324,6 +325,17 @@ class AutoBotMove:
self.logistics_manager = LogisticsManager(vendor_file)
self.logistics_manager.bag_full_hearthstone = bool(layout.get("bag_full_hearthstone", False))
self.logistics_manager.hearthstone_key = str(layout.get("hearthstone_key", "b") or "b")
self.logistics_manager.enable_bag_full_mail = bool(layout.get("enable_bag_full_mail", False))
self.logistics_manager.mailbox_route_file = str(
mailbox_route_path
or layout.get("mailbox_route_json", os.path.join("recorder", "mailbox.json"))
or os.path.join("recorder", "mailbox.json")
)
self.logistics_manager.mailbox_interact_key = str(layout.get("mailbox_interact_key", "8") or "8")
self.logistics_manager.mail_recipient_key = str(layout.get("mail_recipient_key", "") or "")
self.logistics_manager.mail_send_key = str(layout.get("mail_send_key", "f8") or "f8")
self.logistics_manager.mailbox_open_wait_sec = float(layout.get("mailbox_open_wait_sec", 2.0))
self.logistics_manager.mail_send_wait_sec = float(layout.get("mail_send_wait_sec", 60.0))
def _has_prepare_route(self) -> bool:
return bool(self.prepare_route_waypoints)
@@ -721,8 +733,19 @@ class AutoBotMove:
self.patrol_controller.stop_all()
self.is_moving = False
self.patrol_controller.reset_stuck()
# 勾选"包满炉石回城":按炉石后触发停止回调
if self.logistics_manager.bag_full_hearthstone:
bag_full_now = int(state.get('free_slots', 0) or 0) < 2
if bag_full_now and self.logistics_manager.enable_bag_full_mail:
get_state_fn = (lambda: None if self._should_stop() else parse_game_state())
self.logistics_manager.run_bag_full_mail_flow(
get_state_fn,
self.patrol_controller,
stop_check=self._should_stop,
)
if callable(getattr(self, '_on_hearthstone_stop', None)):
self._on_hearthstone_stop()
return
# 勾选"包满炉石回城":只有真正包满时才炉石;耐久低仍走修理路线
if bag_full_now and self.logistics_manager.bag_full_hearthstone:
get_state_fn = (lambda: None if self._should_stop() else parse_game_state())
self.logistics_manager.use_hearthstone_and_stop(get_state=get_state_fn)
if callable(getattr(self, '_on_hearthstone_stop', None)):