修复复核发现的问题: 坐标缩放、升级/同步判定、看门狗诊断、卡死检测

Browse Source
- scripts/lc_ui.py: 脚本坐标按 1600x900 书写, OCR 结果与点击/拖动按实际客户区换算; 去掉写死的 D:\lc-mcp 路径
- levelup.py: 升级以详情页等级/经验条变化判定成功; 同步先判断弹窗是否仍在, 无过场时不再多按 ESC、不再盲点取消
- auto_cycle.py: task_status 连续报 stall 即停任务; exit 0 但有 errors 判失败
- tasks.py: 运行中日志尾部"配队人数OCR得到"刷屏时返回 stall 字段
- keep_display.ps1: tscon 改用 -EncodedCommand 并记录退出码; 会话号自动取游戏所在会话
- 更正 10-05 README 选队结论、summary 卡死①统计、PITFALLS 坑 13 根因

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-10-13 03:03:49 +00:00
co-authored by Claude Opus 5.5
parent 0153414fba
commit 6b129ddba3
11 changed files with 412 additions and 138 deletions
+47 -72
View File
@@ -19,17 +19,15 @@
退出码: 0 成功 / 1 失败 退出码: 0 成功 / 1 失败
""" """
import json
import subprocess
import sys import sys
import time import time
PY = r'D:\lc-mcp\vendor\aalc\.venv\Scripts\python.exe' from lc_ui import click, keypress, long_press, screen_text, state
PROBE = r'D:\lc-mcp\scripts\mcp_probe.py'
# 网格布局 # 网格布局(1600x900 坐标, 由 lc_ui 换算到实际客户区)。
# 第 4 行在 y=942, 超出客户区, 需要滚动才能看到, 这里不处理。
COLS = [335, 508, 681, 853, 1026, 1198] COLS = [335, 508, 681, 853, 1026, 1198]
ROWS = [260, 487, 715, 942] ROWS = [260, 487, 715]
# 固定控件坐标 # 固定控件坐标
BACK = (85, 75) BACK = (85, 75)
@@ -44,43 +42,6 @@ UPTIE_DONE_CONFIRM = (772, 661)
UPTIE_CANCEL = (526, 660) UPTIE_CANCEL = (526, 660)
def probe(tool, args=None, quiet=False):
cmd = [PY, '-X', 'utf8', PROBE, tool]
if args is not None:
cmd.append(json.dumps(args, ensure_ascii=False))
r = subprocess.run(cmd, capture_output=True, text=True,
encoding='utf-8', errors='replace')
out = (r.stdout or '').strip()
for line in reversed(out.splitlines()):
line = line.strip()
if line.startswith('{'):
try:
return json.loads(line)
except json.JSONDecodeError:
continue
if not quiet:
print('[warn] probe %s 无 JSON 输出: %r' % (tool, out[:200]))
return {}
def state():
return probe('get_state')
def click(x, y, times=1):
return probe('click', {'x': int(x), 'y': int(y), 'times': times})
def long_press(x, y):
"""drag 起点==终点 即长按(实测可打开人格详情)。"""
return probe('drag', {'from_x': int(x), 'from_y': int(y),
'to_x': int(x), 'to_y': int(y)})
def screen_text(items):
return ' | '.join(i.get('text', '') for i in items)
def near(items, cx, cy, dx=100, dy=115): def near(items, cx, cy, dx=100, dy=115):
return [i for i in items return [i for i in items
if abs(i.get('x', 0) - cx) < dx and abs(i.get('y', 0) - cy) < dy] if abs(i.get('x', 0) - cx) < dx and abs(i.get('y', 0) - cy) < dy]
@@ -151,9 +112,13 @@ def ticket_balance():
return bal return bal
def do_level_up(): def do_level_up(hint=None):
"""在已打开的人格详情页执行升级。返回 (ok, 描述)""" """在已打开的人格详情页执行升级。返回 (ok, 描述), ok 为 None 表示没有券可用。
before = None
成败看详情页的等级/经验条在升级前后是否变化。不能看 'Level Up'/'Uptie'
字样: 详情页上它们一直都在, 升级失败也会被判成成功。
"""
lvl0, _, bar0 = read_detail(hint)
click(*BTN_LEVEL_UP) click(*BTN_LEVEL_UP)
time.sleep(3.5) time.sleep(3.5)
items = state().get('items', []) items = state().get('items', [])
@@ -189,21 +154,30 @@ def do_level_up():
target = nums[-1] target = nums[-1]
click(*POWERUP_CONFIRM) click(*POWERUP_CONFIRM)
time.sleep(4.5) time.sleep(4.5)
items = state().get('items', []) txt = screen_text(state().get('items', []))
txt = screen_text(items) if 'Owned' in txt and 'Cancel' in txt:
ok = 'Uptie' in txt or 'Level Up' in txt click(*POWERUP_CANCEL)
return ok, '升级前券=%s 目标等级=%s' % (before, target) time.sleep(2)
return False, 'Confirm 后 Power-up 窗口仍在, 已取消(券=%s)' % before
lvl1, _, bar1 = read_detail(hint=target or lvl0 or hint)
desc = '券=%s 目标=%s 等级 %s->%s 经验 %s->%s' % (before, target, lvl0, lvl1, bar0, bar1)
if lvl0 is not None and lvl1 is not None and lvl1 > lvl0:
return True, desc
if bar0 is not None and bar1 is not None and bar1 != bar0:
return True, desc
return False, '升级未确认: ' + desc
def skip_cutscene(): def skip_cutscene(press_esc=True):
"""同步到三阶会解锁人格剧情并自动播放。ESC 会弹"是否跳过", 点 Confirm。 """同步到三阶会解锁人格剧情并自动播放。ESC 会弹"是否跳过", 点 Confirm。
返回 True 表示确实跳过一个过场。 press_esc=False 时只处理已经弹出的跳过框, 不主动按 ESC——没有过场时按 ESC
会关掉当前弹窗或退出详情页。返回 True 表示确实跳过一个过场。
""" """
items = state().get('items', []) items = state().get('items', [])
txt = screen_text(items) txt = screen_text(items)
if 'skip' not in txt.lower(): if 'skip' not in txt.lower() and press_esc:
probe('keypress', {'key': 'esc'}) keypress('esc')
time.sleep(2) time.sleep(2)
items = state().get('items', []) items = state().get('items', [])
txt = screen_text(items) txt = screen_text(items)
@@ -238,22 +212,25 @@ def do_uptie():
click(*UPTIE_CONFIRM) click(*UPTIE_CONFIRM)
time.sleep(4.5) time.sleep(4.5)
if skip_cutscene(): txt = screen_text(state().get('items', []))
# 弹窗还在(仍显示材料需求)说明没同步成。必须先判断这个: 弹窗里本身就有
# 'Skills Gained', 放在成功判定后面会把失败认成成功。
if 'Currency Req' in txt or 'Egoshard' in txt:
click(*UPTIE_CANCEL)
time.sleep(2)
return False, '同步未生效(通常缺自我碎片): ' + txt[:160]
if skip_cutscene(press_esc=False):
time.sleep(3) time.sleep(3)
return True, '同步成功(并跳过了解锁的人格剧情)' return True, '同步成功(并跳过了解锁的人格剧情)'
items = state().get('items', [])
txt = screen_text(items)
if 'Uptied' in txt or 'Enhanced' in txt or 'Gained' in txt: if 'Uptied' in txt or 'Enhanced' in txt or 'Gained' in txt:
click(*UPTIE_DONE_CONFIRM) click(*UPTIE_DONE_CONFIRM)
time.sleep(2.5) time.sleep(2.5)
return True, '同步成功' return True, '同步成功'
if 'Owned' in txt or 'Egoshard' in txt: # 什么都没认出: 可能是剧情已经在播但还没出跳过提示, 这时才按 ESC
click(*UPTIE_CANCEL) if skip_cutscene(press_esc=True):
time.sleep(2) time.sleep(3)
return False, '同步未生效(通常缺自我碎片): ' + txt[:160] return True, '同步成功(并跳过了解锁的人格剧情)'
click(*UPTIE_CANCEL) # 画面未知时不盲点坐标, 交给调用方按网格判断退回
time.sleep(2)
return False, '同步结果未知: ' + txt[:160] return False, '同步结果未知: ' + txt[:160]
@@ -327,7 +304,7 @@ def level_from_bar(cur, need, hint=None):
def read_detail(hint=None): def read_detail(hint=None):
"""从已打开的人格详情页读 (真实等级, 名字)。 """从已打开的人格详情页读 (真实等级, 名字, 经验条 (cur, need))。
网格里的小号艺术字 OCR 极不可靠(实测 LV14->'Lv.1', LV24->'LV2H'); 网格里的小号艺术字 OCR 极不可靠(实测 LV14->'Lv.1', LV24->'LV2H');
详情页的大号等级也常被漏认(实测 LCB 罪人页只认出 '547/885')。 详情页的大号等级也常被漏认(实测 LCB 罪人页只认出 '547/885')。
@@ -361,12 +338,10 @@ def read_detail(hint=None):
if abs(from_bar - direct) > 2: if abs(from_bar - direct) > 2:
print(' [warn] 进度条推算 Lv.%d 与直读 Lv.%d 不符, 取进度条' print(' [warn] 进度条推算 Lv.%d 与直读 Lv.%d 不符, 取进度条'
% (from_bar, direct)) % (from_bar, direct))
return from_bar, name return from_bar, name, bar
if from_bar is not None: if from_bar is not None:
return from_bar, name return from_bar, name, bar
if direct is not None: return direct, name, bar
return direct, name
return None, name
def cmd_progress(target=34, uptie=True, max_try=6): def cmd_progress(target=34, uptie=True, max_try=6):
@@ -389,7 +364,7 @@ def cmd_progress(target=34, uptie=True, max_try=6):
if 'Level Up' not in txt: if 'Level Up' not in txt:
print(' 长按未打开详情, 跳过') print(' 长按未打开详情, 跳过')
continue continue
true_lvl, true_name = read_detail(hint=ocr_lvl) true_lvl, true_name, _ = read_detail(hint=ocr_lvl)
print(' 详情页: %s 真实等级=%s' % (true_name, true_lvl)) print(' 详情页: %s 真实等级=%s' % (true_name, true_lvl))
if true_lvl is None: if true_lvl is None:
# 详情页读不到时退回网格值——网格会误读, 但总比跳过整张卡好 # 详情页读不到时退回网格值——网格会误读, 但总比跳过整张卡好
@@ -400,7 +375,7 @@ def cmd_progress(target=34, uptie=True, max_try=6):
click(*BACK) click(*BACK)
time.sleep(2.5) time.sleep(2.5)
continue continue
ok, desc = do_level_up() ok, desc = do_level_up(hint=true_lvl)
print(' 升级: %s (%s)' % ('OK' if ok else ('SKIP' if ok is None else 'FAIL'), desc)) print(' 升级: %s (%s)' % ('OK' if ok else ('SKIP' if ok is None else 'FAIL'), desc))
if uptie: if uptie:
ok2, desc2 = do_uptie() ok2, desc2 = do_uptie()