修复复核发现的问题: 坐标缩放、升级/同步判定、看门狗诊断、卡死检测
- 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:
+31
-50
@@ -7,17 +7,14 @@
|
|||||||
设计: 只做"一轮",不做无限循环——由外层(goal 轮次)负责重复与判断,
|
设计: 只做"一轮",不做无限循环——由外层(goal 轮次)负责重复与判断,
|
||||||
避免无人监督地长时间空转。每轮输出结构化报告供上层核对。
|
避免无人监督地长时间空转。每轮输出结构化报告供上层核对。
|
||||||
"""
|
"""
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
PY = r'D:\lc-mcp\vendor\aalc\.venv\Scripts\python.exe'
|
from lc_ui import HERE, PY, click, drag, items, keypress, probe, run
|
||||||
HERE = r'D:\lc-mcp\scripts'
|
|
||||||
PROBE = HERE + r'\mcp_probe.py'
|
LEVELUP = os.path.join(HERE, 'levelup.py')
|
||||||
LEVELUP = HERE + r'\levelup.py'
|
# 手动抽卡花掉狂气后, 删掉这个文件重新记基线, 否则每轮都会中止
|
||||||
LUNACY_BASELINE = os.path.expanduser(r'~\lc_mcp\lunacy_baseline.txt')
|
LUNACY_BASELINE = os.path.expanduser(os.path.join('~', 'lc_mcp', 'lunacy_baseline.txt'))
|
||||||
|
|
||||||
# 导航
|
# 导航
|
||||||
BACK = (85, 75) # 只在 Sinners 内部退层用, 主界面上按它会进剧情
|
BACK = (85, 75) # 只在 Sinners 内部退层用, 主界面上按它会进剧情
|
||||||
@@ -26,31 +23,8 @@ TAB_ALL_IDENTITIES = (1472, 245) # TEAMS 页 -> All Identities
|
|||||||
|
|
||||||
# daily 轮询上限
|
# daily 轮询上限
|
||||||
DAILY_TIMEOUT_S = 45 * 60
|
DAILY_TIMEOUT_S = 45 * 60
|
||||||
|
# task_status 连续几次报 stall 就判定卡死并停任务(每次轮询间隔 60 秒)
|
||||||
|
STALL_POLLS = 2
|
||||||
def run(cmd):
|
|
||||||
r = subprocess.run(cmd, capture_output=True, text=True,
|
|
||||||
encoding='utf-8', errors='replace')
|
|
||||||
return (r.stdout or '') + (r.stderr or '')
|
|
||||||
|
|
||||||
|
|
||||||
def probe(tool, args=None):
|
|
||||||
cmd = [PY, '-X', 'utf8', PROBE, tool]
|
|
||||||
if args is not None:
|
|
||||||
cmd.append(json.dumps(args, ensure_ascii=False))
|
|
||||||
out = run(cmd)
|
|
||||||
for line in reversed(out.strip().splitlines()):
|
|
||||||
line = line.strip()
|
|
||||||
if line.startswith('{'):
|
|
||||||
try:
|
|
||||||
return json.loads(line)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
continue
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
def click(x, y):
|
|
||||||
return probe('click', {'x': int(x), 'y': int(y), 'times': 1})
|
|
||||||
|
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
@@ -64,8 +38,8 @@ def goto_identities():
|
|||||||
实测会掉进过场动画, 需要额外恢复。
|
实测会掉进过场动画, 需要额外恢复。
|
||||||
"""
|
"""
|
||||||
for attempt in range(5):
|
for attempt in range(5):
|
||||||
items = probe('get_state').get('items', [])
|
its = items()
|
||||||
txt = ' | '.join(i.get('text', '') for i in items)
|
txt = ' | '.join(i.get('text', '') for i in its)
|
||||||
if 'IDENTITIES' in txt and 'Facades' in txt:
|
if 'IDENTITIES' in txt and 'Facades' in txt:
|
||||||
return True
|
return True
|
||||||
if 'TEAMS #1' in txt or 'SIN COST' in txt or 'All Idensities' in txt:
|
if 'TEAMS #1' in txt or 'SIN COST' in txt or 'All Idensities' in txt:
|
||||||
@@ -74,13 +48,13 @@ def goto_identities():
|
|||||||
continue
|
continue
|
||||||
if 'LUXCAVATION' in txt.upper() or 'MIRROR' in txt.upper():
|
if 'LUXCAVATION' in txt.upper() or 'MIRROR' in txt.upper():
|
||||||
# 在副本/关卡菜单里, 先回主界面
|
# 在副本/关卡菜单里, 先回主界面
|
||||||
probe('keypress', {'key': 'esc'})
|
keypress('esc')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
continue
|
continue
|
||||||
click(*BTN_SINNERS)
|
click(*BTN_SINNERS)
|
||||||
time.sleep(3.5)
|
time.sleep(3.5)
|
||||||
items = probe('get_state').get('items', [])
|
its = items()
|
||||||
txt = ' | '.join(i.get('text', '') for i in items)
|
txt = ' | '.join(i.get('text', '') for i in its)
|
||||||
return 'IDENTITIES' in txt and 'Facades' in txt
|
return 'IDENTITIES' in txt and 'Facades' in txt
|
||||||
|
|
||||||
|
|
||||||
@@ -100,8 +74,8 @@ def ensure_team1():
|
|||||||
"找不到队伍 # 1" 然后整轮空转。所以每轮开跑前先把列表拉回顶部。
|
"找不到队伍 # 1" 然后整轮空转。所以每轮开跑前先把列表拉回顶部。
|
||||||
"""
|
"""
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
items = probe('get_state').get('items', [])
|
its = items()
|
||||||
txt = ' | '.join(i.get('text', '') for i in items)
|
txt = ' | '.join(i.get('text', '') for i in its)
|
||||||
if on_teams_screen(txt):
|
if on_teams_screen(txt):
|
||||||
break
|
break
|
||||||
if on_grid(txt):
|
if on_grid(txt):
|
||||||
@@ -112,8 +86,8 @@ def ensure_team1():
|
|||||||
time.sleep(3.5)
|
time.sleep(3.5)
|
||||||
|
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
items = probe('get_state').get('items', [])
|
its = items()
|
||||||
cand = [i for i in items
|
cand = [i for i in its
|
||||||
if i.get('text', '').strip().replace(' ', '') in
|
if i.get('text', '').strip().replace(' ', '') in
|
||||||
('TEAMS#1', 'TFAMS#1') and i.get('x', 999) < 320]
|
('TEAMS#1', 'TFAMS#1') and i.get('x', 999) < 320]
|
||||||
if cand:
|
if cand:
|
||||||
@@ -122,8 +96,7 @@ def ensure_team1():
|
|||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
return True
|
return True
|
||||||
# 向下拖拽 = 列表内容下移 = 露出更靠前的预设
|
# 向下拖拽 = 列表内容下移 = 露出更靠前的预设
|
||||||
probe('drag', {'from_x': 190, 'from_y': 400,
|
drag(190, 400, 190, 700)
|
||||||
'to_x': 190, 'to_y': 700})
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -135,17 +108,25 @@ def run_daily():
|
|||||||
return False, 'run_task 失败: %s' % r
|
return False, 'run_task 失败: %s' % r
|
||||||
log('daily 已启动, 开始轮询')
|
log('daily 已启动, 开始轮询')
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
stalled = 0
|
||||||
while time.time() - t0 < DAILY_TIMEOUT_S:
|
while time.time() - t0 < DAILY_TIMEOUT_S:
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
st = probe('task_status', {'lines': 1})
|
st = probe('task_status', {'lines': 1})
|
||||||
s = st.get('state')
|
s = st.get('state')
|
||||||
|
el = int(time.time() - t0)
|
||||||
if s != 'running':
|
if s != 'running':
|
||||||
el = int(time.time() - t0)
|
|
||||||
log('daily 结束: state=%s elapsed=%ds exit=%s'
|
log('daily 结束: state=%s elapsed=%ds exit=%s'
|
||||||
% (s, el, st.get('exit_code')))
|
% (s, el, st.get('exit_code')))
|
||||||
|
# AALC 单次战斗失败后仍会 exit 0, succeeded 还要看 errors
|
||||||
|
if s == 'succeeded' and st.get('errors'):
|
||||||
|
return False, 'exit 0 但日志有报错: %s' % st['errors'][-1]
|
||||||
return s == 'succeeded', 'state=%s elapsed=%ds' % (s, el)
|
return s == 'succeeded', 'state=%s elapsed=%ds' % (s, el)
|
||||||
if int(time.time() - t0) % 600 < 60:
|
stalled = stalled + 1 if st.get('stall') else 0
|
||||||
log(' ...running %ds' % int(time.time() - t0))
|
if stalled >= STALL_POLLS:
|
||||||
|
probe('stop_task')
|
||||||
|
return False, '卡死(%s), 已停止任务 elapsed=%ds' % (st['stall'], el)
|
||||||
|
if el % 600 < 60:
|
||||||
|
log(' ...running %ds' % el)
|
||||||
probe('stop_task')
|
probe('stop_task')
|
||||||
return False, '超时 %ds' % DAILY_TIMEOUT_S
|
return False, '超时 %ds' % DAILY_TIMEOUT_S
|
||||||
|
|
||||||
@@ -157,16 +138,16 @@ def report_grid():
|
|||||||
|
|
||||||
def read_lunacy():
|
def read_lunacy():
|
||||||
"""从主界面读狂气余额(LUNACY 标签右下方的数字)。读不到返回 None。"""
|
"""从主界面读狂气余额(LUNACY 标签右下方的数字)。读不到返回 None。"""
|
||||||
items = probe('get_state').get('items', [])
|
its = items()
|
||||||
lab = None
|
lab = None
|
||||||
for it in items:
|
for it in its:
|
||||||
if 'LUNACY' in it.get('text', '').upper():
|
if 'LUNACY' in it.get('text', '').upper():
|
||||||
lab = it
|
lab = it
|
||||||
break
|
break
|
||||||
if not lab:
|
if not lab:
|
||||||
return None
|
return None
|
||||||
best = None
|
best = None
|
||||||
for it in items:
|
for it in its:
|
||||||
t = it.get('text', '').strip()
|
t = it.get('text', '').strip()
|
||||||
if t.isdigit() and len(t) >= 3:
|
if t.isdigit() and len(t) >= 3:
|
||||||
dy = it.get('y', 0) - lab.get('y', 0)
|
dy = it.get('y', 0) - lab.get('y', 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user