人格升级自动化: 长按入口、选队定位缺陷与一轮驱动脚本

Browse Source
把人格升级/同步这条只存在于 GUI 的链路自动化, 并定位到一个静默选错队伍的配置陷阱。

关键发现:
- 人格详情页是"长按"打开的, 单击只会选中/取消选中。lc-mcp 无 long-press 工具,
  但 drag 起终点相同即长按, 实测稳定可复现。
- select_team_by_order: true 按坐标位置点队伍, 列表位移几十像素就会点到隔壁;
  实测导致 AALC 选中空队伍 TEAMS #2 并空转 26 分钟。改回按名字查找后连续 4 次全中。
  该开关当初是为绕过"编队名匹配失败"而加, 但那个问题的真因是 sinner_order 全 0,
  修好之后名字匹配本可用——为症状加的开关在根因修好后反而成了新故障源。

新增 scripts/levelup.py (长按->详情->升级->同步) 与 scripts/auto_cycle.py
(刷材料->升级->同步->前后对比, 刻意只做一轮以便逐轮核对)。

实测: Rosespanner Workshop Fixer Lv.04->Lv.36 (HP 87->173) 并同步至三阶,
解锁 Skill 3 与新被动; N Corp. Mittelhammer Lv.14->Lv.26。
This commit is contained in:
Codex Agent
2026-10-05 14:37:34 +08:00
parent 3547d9c43f
commit aebedbcec8
3 changed files with 615 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
# 2026-10-05 人格升级自动化与选队定位缺陷
接 `docs/feedback/2026-10-04/`。这一天的工作从"能刷"推进到"能养":
把**人格升级/同步**这条原本只存在于 GUI 的链路自动化,并定位到一个会
静默选错队伍的配置陷阱。
## 结果
```text
daily 一轮 18 分钟,exit 0,0 错误
自动化一整轮 刷材料 -> 升级 -> 同步 -> 前后对比,约 20 分钟
实测升级 N Corp. Mittelhammer Lv.14 -> Lv.26
实测升级 Rosespanner Workshop Fixer Lv.04 -> Lv.36
HP 87->173,Defense Level 4->36
实测同步 Rosespanner Uptie 二阶->三阶
解锁 Skill 3「Saddled Tasks」+ 新被动 Chronic Fatigue
```
## 一、人格详情页是长按打开的 ★
**这是整件事的关键,也是最反直觉的一点。**
罪人界面(Sinners → Identities)的卡片:
| 操作 | 结果 |
|---|---|
| 单击 | 只是**选中/取消选中**(在队伍预设里增删成员) |
| 长按 | **打开人格详情页** |
单击试遍了卡片头像、SELECTED 横幅、名字等级区、双击、右侧面板、
左侧罪人栏、右上 `i`、Details 按钮——**全都只能选中**。长按一下,
详情页里 `Level Up` 和 `Uptie` 两个按钮就在那里。
**自动化实现**:lc-mcp 没有 long-press 工具,但 `drag` 是
`按下 -> 移动 -> 抬起`,**起点终点相同**就是长按:
```python
probe('drag', {'from_x': x, 'from_y': y, 'to_x': x, 'to_y': y})
```
实测稳定可复现。
### 完整坐标(1600x900 客户区)
```text
罪人界面网格 列 x = 335 508 681 853 1026 1198
行 y = 260 487 715 942
人格详情页 Level Up (1164, 235) Uptie (1367, 235)
升级(Power-up)窗口 券档位行 y = 383(IV) 490(III) 598(II)
「全部投入」按钮 x = 1133(每行同 x)
Confirm (1030, 670) Cancel (603, 670)
同步(Uptie)窗口 Uptie (1085, 580) 完成 Confirm (772, 661)
取消 (526, 660)
```
## 二、`select_team_by_order: true` 会静默选错队伍 ★
**这个坑比看上去严重:它不报错,只是"刷了半天什么也没发生"。**
`tasks/teams/team_formation.py` 有两条选队路径:
```python
if cfg.select_team_by_order:
# 按"位置"点击:first_position + 行高 × 序号
first_position = [position[0], position[1] + 70 * scale]
...
auto.mouse_click(first_position[0],
first_position[1] + _ordered_team_click_offset(...) * scale)
else:
# 按"名字"查找
team_name_en = [f"TEAMS #{num}", f"TEAMS#{num}", f"TFAMS#{num}"]
if team_position := auto.find_language_text(team_name_zh, team_name_en, ...):
auto.mouse_action_with_pos(team_position, offset=False)
```
**位置法对列表滚动位置极其脆弱**:代码虽然会先做几次"复位滑动"
(`_team_list_reset_swipe_count`),但只要复位不完美、或列表因为
某些原因整体位移(实测位移了 75px),点击就会落到隔壁队伍上。
**实测后果**:
```text
13:21:40 最后一次里程碑
... 26 分钟没有任何日志(日志在涨,但只是 OCR 空转)
画面 TEAMS #2 | You haven't Deployed any Sinners.
Participant Limit 0/5
```
队伍预设被切到了一个**空队伍**,AALC 找不到可用队伍 → 空转。
**修复**:改回按名字查找。
```yaml
select_team_by_order: false
```
修复后连续 4 次选队全部命中,日志行号从 `team_formation.py:163`
(位置法)变成 `:188`(名字法),可以直接从日志判断走的是哪条路:
```text
13:51:12 成功找到队伍 # 1
13:54:26 成功找到队伍 # 1
13:57:45 成功找到队伍 # 1
14:00:27 成功找到队伍 # 1
```
> **教训**:当初开 `select_team_by_order` 是为了绕过"编队名匹配失败"。
> 但那个问题的真因是 `sinner_order` 全 0(见 10-04 的记录),
> 修好之后名字匹配本来就能用。**为一个症状加的开关,在根因修好后
> 反而变成了新的故障源。**
## 三、等级与材料数值(wiki 查证)
```text
人格等级上限 新手期 Lv.40;通关 Canto V 后每章 +5(当前版本最高 Lv.65)
经验本档位 AALC 按 x 从大到小遍历(最右优先),失败才降级——已是最优策略
产量低是因为账号只解锁了前几档,不是选错
训练券价值 I=50 II=200 III=1000 IV=3000 EXP
升级到 Lv.40 累计 91,700 EXP(Lv.34 时已累计 55,048)
同步(3★) II=20纺锤 III=80纺锤 IV=150纺锤+50自我碎片
跳战 给 +50% 奖励但耗 2 倍体力模组——单位体力效率反而更低
```
**实战消耗**:`Rosespanner` 从 Lv.04 拉到 Lv.36 用了
52 张 III 券 + 71 张 II 券(共 66,200 EXP)+ 10 纺锤。
## 四、新增脚本
### `scripts/levelup.py`
长按打开人格详情 → 升级 → 同步。支持:
```bash
python levelup.py list # 列出网格里的人格及等级/是否在队伍
python levelup.py weakest [--uptie] # 对队内等级最低者执行升级
python levelup.py card <col> <row> # 对指定卡片执行
python levelup.py back # 返回网格
```
**判定弹窗时不要用模糊字样**:详情页本身就有 `Uptie+`,
用它判断"同步弹窗是否打开"会永远为真。要用弹窗独有文本:
```python
# 升级窗口: 'Owned' + 'Cancel'
# 同步窗口: 'Currency Req' / 'Stats Increased' / 'Skills Gained'
```
**券余额不要靠券名判定档位**:OCR 会把 `III` 认成小写 `lll`,
`'III' in text` 直接失效。改用行的 y 坐标(三行固定为 IV/III/II)。
### `scripts/auto_cycle.py`
一整轮:`daily` → 进网格 → 升最弱者 + 同步 → 输出前后对比。
**刻意只做一轮,不做无限循环**——由外层按轮驱动,便于每轮核对与中止,
避免无人监督地长时间空转。
## 五、又一个自己制造的事故:返回键会进剧情
恢复流程里我从主界面点左上返回键(85, 75),**结果进了剧情 Drive**,
掉进过场动画,还得靠 `reward` 任务的 `返回主界面` 才救回来。
**修复**:恢复路径只点 `Sinners` 按钮,返回键改成"只在确实需要退一层时"
才按,且每次按完都检查是否已到目标界面。
## 仍未解决 / 已知限制
1. **升级后界面判断可能残留**:`do_level_up` 里目标等级靠 `▶` 字符解析,
OCR 常把它认丢。已加"两段等级且后者更大"的兜底,但仍是启发式。
2. **`daily` 产量受账号解锁进度限制**,无法通过配置提高。
3. **看门狗只覆盖桌面变黑**,界面走丢(如本次进剧情)仍需外部恢复。
4. 本轮只验证了**单个人格连升 + 同步**,多轮连续运行的稳定性未验证。
+145
View File
@@ -0,0 +1,145 @@
# -*- coding: utf-8 -*-
"""一轮自动推进: 刷材料 -> 升级最弱人格 -> 同步 -> 报告。
用法: python auto_cycle.py [--rounds N]
退出码: 0 正常完成一轮 / 1 失败
设计: 只做"一轮",不做无限循环——由外层(goal 轮次)负责重复与判断,
避免无人监督地长时间空转。每轮输出结构化报告供上层核对。
"""
import json
import subprocess
import sys
import time
PY = r'D:\lc-mcp\vendor\aalc\.venv\Scripts\python.exe'
HERE = r'D:\lc-mcp\scripts'
PROBE = HERE + r'\mcp_probe.py'
LEVELUP = HERE + r'\levelup.py'
# 导航
BTN_SINNERS = (1130, 805) # 主界面底部 Sinners
TAB_ALL_IDENTITIES = (1472, 245) # TEAMS 页 -> All Identities
# daily 轮询上限
DAILY_TIMEOUT_S = 45 * 60
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):
print('[%s] %s' % (time.strftime('%H:%M:%S'), msg), flush=True)
def goto_identities():
"""从任意位置尽力走到 罪人 -> Identities 网格。
只点 Sinners 按钮, 绝不点左上返回键——主界面上的返回键会进入剧情(Drive),
实测会掉进过场动画, 需要额外恢复。
"""
for attempt in range(5):
items = probe('get_state').get('items', [])
txt = ' | '.join(i.get('text', '') for i in items)
if 'IDENTITIES' in txt and 'Facades' in txt:
return True
if 'TEAMS #1' in txt or 'SIN COST' in txt or 'All Idensities' in txt:
click(*TAB_ALL_IDENTITIES)
time.sleep(3)
continue
if 'LUXCAVATION' in txt.upper() or 'MIRROR' in txt.upper():
# 在副本/关卡菜单里, 先回主界面
probe('keypress', {'key': 'esc'})
time.sleep(2)
continue
click(*BTN_SINNERS)
time.sleep(3.5)
items = probe('get_state').get('items', [])
txt = ' | '.join(i.get('text', '') for i in items)
return 'IDENTITIES' in txt and 'Facades' in txt
def run_daily():
log('起 daily(经验本x3 + 纽本x3)')
r = probe('run_task', {'task': 'daily'})
if not r.get('ok'):
return False, 'run_task 失败: %s' % r
log('daily 已启动, 开始轮询')
t0 = time.time()
while time.time() - t0 < DAILY_TIMEOUT_S:
time.sleep(60)
st = probe('task_status', {'lines': 1})
s = st.get('state')
if s != 'running':
el = int(time.time() - t0)
log('daily 结束: state=%s elapsed=%ds exit=%s'
% (s, el, st.get('exit_code')))
return s == 'succeeded', 'state=%s elapsed=%ds' % (s, el)
if int(time.time() - t0) % 600 < 60:
log(' ...running %ds' % int(time.time() - t0))
probe('stop_task')
return False, '超时 %ds' % DAILY_TIMEOUT_S
def report_grid():
out = run([PY, '-X', 'utf8', LEVELUP, 'list'])
return out.strip()
def main():
t_start = time.time()
log('=== 一轮开始 ===')
ok, info = run_daily()
log('刷材料: %s (%s)' % ('OK' if ok else 'FAIL', info))
if not ok:
log('=== 本轮失败: 刷材料未成功 ===')
return 1
# daily 结束后应回到主界面
time.sleep(8)
if not goto_identities():
log('无法进入 Identities 网格, 放弃本轮')
return 1
log('已进入 Identities 网格')
log('升级前:\n' + report_grid())
log('对队内最低者升级 + 同步')
out = run([PY, '-X', 'utf8', LEVELUP, 'weakest', '--uptie'])
for line in out.strip().splitlines():
log(' ' + line)
time.sleep(5)
if not goto_identities():
log('升级后无法回到网格')
return 1
log('升级后:\n' + report_grid())
log('=== 一轮结束, 耗时 %ds ===' % int(time.time() - t_start))
return 0
if __name__ == '__main__':
raise SystemExit(main())
+298
View File
@@ -0,0 +1,298 @@
# -*- coding: utf-8 -*-
"""人格升级/同步自动化。
流程(全部基于实测坐标,1600x900 客户区):
罪人界面 IDENTITIES 网格
-> 长按卡片(drag 起终点相同) 打开人格详情
-> 点 Level Up
-> 对每种训练券点 »(全部投入)
-> Confirm
-> 关窗
-> (可选) 点 Uptie -> Uptie -> Confirm -> 关窗
-> 返回网格
用法:
python levelup.py list 列出网格里队内(SELECTED)人格及等级
python levelup.py weakest [--uptie] 对队内等级最低者执行升级(可选同步)
python levelup.py card <col> <row> [--uptie]
python levelup.py back 返回网格
退出码: 0 成功 / 1 失败
"""
import json
import subprocess
import sys
import time
PY = r'D:\lc-mcp\vendor\aalc\.venv\Scripts\python.exe'
PROBE = r'D:\lc-mcp\scripts\mcp_probe.py'
# 网格布局
COLS = [335, 508, 681, 853, 1026, 1198]
ROWS = [260, 487, 715, 942]
# 固定控件坐标
BACK = (85, 75)
BTN_LEVEL_UP = (1164, 235)
BTN_UPTIE = (1367, 235)
TICKET_MAX_X = 1133
TICKET_ROWS = [383, 490, 598] # IV / III / II
POWERUP_CONFIRM = (1030, 670)
POWERUP_CANCEL = (603, 670)
UPTIE_CONFIRM = (1085, 580)
UPTIE_DONE_CONFIRM = (772, 661)
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):
return [i for i in items
if abs(i.get('x', 0) - cx) < dx and abs(i.get('y', 0) - cy) < dy]
def parse_level(text):
"""'LV36' / 'Lv.04' / 'Lv-30' -> int;失败返回 None"""
digits = ''.join(ch for ch in str(text) if ch.isdigit())
return int(digits) if digits else None
def scan_grid(items):
"""返回 [(col, row, x, y, level, selected, name)]"""
cards = []
for ri, ry in enumerate(ROWS):
for ci, cx in enumerate(COLS):
ins = near(items, cx, ry)
if not ins:
continue
lvl = None
for it in ins:
t = it.get('text', '')
if t[:2].lower() == 'lv' and parse_level(t) is not None:
lvl = parse_level(t)
break
if lvl is None:
continue
sel = any('SELECTED' in it.get('text', '') for it in ins)
name = ' '.join(it.get('text', '') for it in ins
if it.get('y', 0) > ry
and not it.get('text', '')[:2].lower() == 'lv'
and 'SELECTED' not in it.get('text', ''))
cards.append((ci, ri, cx, ry, lvl, sel, name.strip()))
return cards
def cmd_list():
items = state().get('items', [])
cards = scan_grid(items)
if not cards:
print('网格为空或不在 IDENTITIES 界面')
print('当前画面: ' + screen_text(items)[:200])
return 1
print('%-4s %-4s %-6s %-9s %s' % ('col', 'row', 'lv', 'inTeam', 'name'))
for ci, ri, cx, ry, lvl, sel, name in cards:
print('%-4d %-4d %-6d %-9s %s' % (ci, ri, lvl, 'Y' if sel else '-', name))
return 0
def ticket_balance():
"""当前 Power-up 界面上的券余额 -> {tier: owned}
不靠券名文字判定档位(OCR 会把 III 认成 lll),改用行的 y 坐标:
三行固定为 IV / III / II。'Owned:o' 里的 o/O 视作 0。
"""
items = state().get('items', [])
bal = {}
for it in items:
t = it.get('text', '')
if 'Owned' not in t:
continue
tail = t.split('Owned')[-1]
digits = ''.join(ch for ch in tail if ch.isdigit())
val = int(digits) if digits else 0
y = it.get('y', 0)
tier = 'IV' if y < 390 else ('III' if y < 500 else 'II')
bal[tier] = val
return bal
def do_level_up():
"""在已打开的人格详情页执行升级。返回 (ok, 描述)"""
before = None
click(*BTN_LEVEL_UP)
time.sleep(3.5)
items = state().get('items', [])
txt = screen_text(items)
# Power-up 弹窗独有 'Items' 分页与 'Owned' 字样
if 'Owned' not in txt or 'Cancel' not in txt:
return False, '未打开 Power-up 界面: ' + txt[:160]
before = ticket_balance()
if not any(v > 0 for v in before.values()):
click(*POWERUP_CANCEL)
time.sleep(2)
return None, '没有可用训练券(余额=%s), 跳过升级' % before
for y in TICKET_ROWS:
click(TICKET_MAX_X, y)
time.sleep(1.2)
items = state().get('items', [])
txt = screen_text(items)
target = None
for it in items:
t = it.get('text', '')
if '▶' in t:
nums = [parse_level(p) for p in t.split('▶')]
nums = [n for n in nums if n is not None]
if len(nums) >= 2:
target = nums[-1]
if target is None:
# OCR 常把 ▶ 认成 · 或丢失, 退而求其次看是否有两段等级
for it in items:
t = it.get('text', '')
nums = [parse_level(p) for p in t.replace('·', '▶').split('▶')]
nums = [n for n in nums if n is not None]
if len(nums) >= 2 and nums[-1] > nums[0]:
target = nums[-1]
click(*POWERUP_CONFIRM)
time.sleep(4.5)
items = state().get('items', [])
txt = screen_text(items)
ok = 'Uptie' in txt or 'Level Up' in txt
return ok, '升级前券=%s 目标等级=%s' % (before, target)
def do_uptie():
"""在人格详情页执行同步。返回 (ok, 描述)"""
for attempt in range(2):
click(*BTN_UPTIE)
time.sleep(4)
items = state().get('items', [])
txt = screen_text(items)
# Uptie 弹窗独有: 'Currency Req' / 'Stats Increased' / 'Skills Gained'
if ('Currency Req' in txt or 'Stats Increased' in txt
or 'Skills Gained' in txt or 'Skills Upgraded' in txt):
break
else:
return False, '未打开 Uptie 弹窗: ' + txt[:160]
click(*UPTIE_CONFIRM)
time.sleep(4.5)
items = state().get('items', [])
txt = screen_text(items)
if 'Uptied' in txt or 'Enhanced' in txt or 'Gained' in txt:
click(*UPTIE_DONE_CONFIRM)
time.sleep(2.5)
return True, '同步成功'
click(*UPTIE_CANCEL)
time.sleep(2)
return False, '同步未生效: ' + txt[:160]
def cmd_card(ci, ri, uptie=False):
if not (0 <= ci < len(COLS) and 0 <= ri < len(ROWS)):
print('坐标越界')
return 1
cx, cy = COLS[ci], ROWS[ri]
print('长按卡片 col=%d row=%d @(%d,%d)' % (ci, ri, cx, cy))
long_press(cx, cy)
time.sleep(4)
items = state().get('items', [])
txt = screen_text(items)
if 'Level Up' not in txt and 'Uptie' not in txt:
print('长按未打开详情页: ' + txt[:200])
return 1
print('详情页已打开')
ok, desc = do_level_up()
print('升级: %s (%s)' % ('OK' if ok else 'FAIL', desc))
if uptie:
ok2, desc2 = do_uptie()
print('同步: %s (%s)' % ('OK' if ok2 else 'FAIL', desc2))
click(*BACK)
time.sleep(2.5)
# 只在还不在网格时再退一层——避免多余返回键落到主界面上(那里会进剧情)
items = state().get('items', [])
txt = screen_text(items)
if not ('IDENTITIES' in txt and 'Facades' in txt):
click(*BACK)
time.sleep(2.5)
items = state().get('items', [])
txt = screen_text(items)
if not ('IDENTITIES' in txt and 'Facades' in txt):
print('[warn] 未能回到 Identities 网格, 当前: ' + txt[:160])
return 0 if ok else 1
def cmd_weakest(uptie=False):
items = state().get('items', [])
cards = scan_grid(items)
team = [c for c in cards if c[5]]
if not team:
print('未找到队内(SELECTED)人格')
return 1
team.sort(key=lambda c: c[4])
ci, ri, cx, ry, lvl, sel, name = team[0]
print('队内最低: Lv.%d %s (col=%d row=%d)' % (lvl, name, ci, ri))
return cmd_card(ci, ri, uptie=uptie)
def cmd_back():
click(*BACK)
time.sleep(2.5)
click(*BACK)
time.sleep(2.5)
print('已返回')
return 0
def main():
args = sys.argv[1:]
if not args:
print(__doc__)
return 2
if args[0] == 'list':
return cmd_list()
if args[0] == 'back':
return cmd_back()
if args[0] == 'weakest':
return cmd_weakest(uptie='--uptie' in args)
if args[0] == 'card' and len(args) >= 3:
return cmd_card(int(args[1]), int(args[2]), uptie='--uptie' in args)
print(__doc__)
return 2
if __name__ == '__main__':
raise SystemExit(main())