人格升级自动化: 长按入口、选队定位缺陷与一轮驱动脚本
把人格升级/同步这条只存在于 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:
@@ -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())
|
||||||
Reference in New Issue
Block a user