升级环节三个实测缺陷: 满级判定、弹窗卡死、坐标定位
2026-10-13 18:00 那轮升级报"前 6 个候选都不需要升级或无法读取", 逐层复盘出三个缺陷, 它们互相叠加, 单看每一个都不像问题: 1. 满级人格被误判成"长按没打开详情" (scripts/levelup.py) 详情页判定写的是 'Level Up' not in txt, 但满级(Lv.40)时那个按钮显示的是 MAX。 实测 Zwei 满级后长按成功, 却因画面里没有 'Level Up' 被判失败跳过。 抽成 detail_page_open(): Level Up / Uptie / Summary+Sanity 任一即可。 顺带统一了 cmd_progress 与 cmd_card 两处不一致的判定。 2. 满级时进度条反推等级偏低 6 级 (scripts/levelup.py) 满级后进度条分母是"下一级"的需求, 而等级已封顶: Zwei 是 LV40/MAX、 进度条 0/6075, 而 6075 在表里对应 Lv.35, 反推成 34。 改为满级时以直读的 LV 为准(取最大值, 避开技能等级)。 3. Uptie 弹窗关不掉, 一直挡着后续所有输入 (scripts/levelup.py, lc_ui.py) Tier IV 弹窗多了 Shard::Thread Exchange 一排, Cancel 实际在 (380,675), 而代码写死 (526,660) —— 落在 Cancel 与 Use Egoshard Crate 之间的空白, 点下去毫无反应。弹窗是模态的, 之后每一次长按都被它吞掉, 于是六张卡全跳过。 加 lc_ui.click_text(): 按文本找元素并点识别框**中心**。 实测 OCR 返回的 (x,y) 是文本框左上角, 直接点常常落空(346,660 无效, 380,675 才中)。 再加 levelup.dismiss_modal(): 每次长按前先清残留弹窗, 比事后补救可靠。 实测结果(N Corp 与 LCB Sinner 各自 33->40): 详情页: Zwei 真实等级=40 已达目标, 跳过 (修复前报"长按未打开详情") 详情页: N Corp 真实等级=33 升级: OK 33->40 (弹窗未关也按详情页判定) 新增测试 6 个(detail_page_open 4 个 + 满级读取 2 个), 全套 223/223 通过。
This commit is contained in:
@@ -93,6 +93,35 @@ def click(x, y, times=1):
|
||||
return probe('click', {'x': cx, 'y': cy, 'times': times})
|
||||
|
||||
|
||||
def find_text(needle, contains=True):
|
||||
"""按文本找画面元素; 返回元素本身(含 x/y/w/h)或 None。
|
||||
|
||||
默认子串匹配、忽略大小写。OCR 结果里 w/h 可能缺失, 调用方要能容忍。
|
||||
"""
|
||||
needle = needle.lower()
|
||||
for it in items():
|
||||
t = it.get('text', '').lower()
|
||||
if (needle in t) if contains else (needle == t):
|
||||
return it
|
||||
return None
|
||||
|
||||
|
||||
def click_text(needle, contains=True):
|
||||
"""按文本点击元素, 点的是识别框的**中心**。
|
||||
|
||||
实测坑: 直接点 OCR 返回的 (x, y) 是文本框左上角, 按下去常常落空
|
||||
(2026-10-13 Uptie 弹窗的 Cancel: 文本在 (346,660), 实际可点区域中心在
|
||||
(380,675), 点前者毫无反应, 弹窗一直卡着挡住后续所有输入)。
|
||||
"""
|
||||
it = find_text(needle, contains=contains)
|
||||
if not it:
|
||||
return False
|
||||
w = it.get('w') or 0
|
||||
h = it.get('h') or 0
|
||||
click(it['x'] + w / 2.0, it['y'] + h / 2.0)
|
||||
return True
|
||||
|
||||
|
||||
def drag(from_x, from_y, to_x, to_y):
|
||||
fx, fy = _to_client(from_x, from_y)
|
||||
tx, ty = _to_client(to_x, to_y)
|
||||
|
||||
+56
-4
@@ -22,7 +22,7 @@
|
||||
import sys
|
||||
import time
|
||||
|
||||
from lc_ui import click, keypress, long_press, screen_text, state
|
||||
from lc_ui import click, click_text, keypress, long_press, screen_text, state
|
||||
|
||||
# 网格布局(1600x900 坐标, 由 lc_ui 换算到实际客户区)。
|
||||
# 第 4 行在 y=942, 超出客户区, 需要滚动才能看到, 这里不处理。
|
||||
@@ -200,6 +200,44 @@ def skip_cutscene(press_esc=True):
|
||||
return False
|
||||
|
||||
|
||||
def dismiss_modal():
|
||||
"""关掉可能残留的 Uptie / Power-up 弹窗, 返回 True 表示画面已干净。
|
||||
|
||||
实测坑(2026-10-13): Tier IV 同步弹窗的 Cancel 按钮, 旧代码写死坐标
|
||||
(526,660), 而那一版弹窗多了 Shard::Thread Exchange 一排, 实际 Cancel
|
||||
在 (380,675) —— 点空处毫无反应, 弹窗一直卡着挡住后续所有输入, 结果
|
||||
六张卡的长按全部失效, 升级环节空跑还报"无需升级"。
|
||||
所以这里: (1) 按文本点识别框中心, 找不到才退回固定坐标;
|
||||
(2) 每次长按前先清一遍, 比事后补救可靠。
|
||||
"""
|
||||
for _ in range(3):
|
||||
its = state().get('items', [])
|
||||
txt = screen_text(its)
|
||||
if 'Currency Req' in txt or 'Skills Upgraded' in txt:
|
||||
if not click_text('Cancel'):
|
||||
click(*UPTIE_CANCEL)
|
||||
time.sleep(2.5)
|
||||
continue
|
||||
if 'Owned' in txt and 'Cancel' in txt: # Power-up 弹窗
|
||||
if not click_text('Cancel'):
|
||||
click(*POWERUP_CANCEL)
|
||||
time.sleep(2.5)
|
||||
continue
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def detail_page_open(txt):
|
||||
"""人格详情页是否已打开。
|
||||
|
||||
不能只看 'Level Up': 满级(Lv.40)时那个按钮显示的是 **MAX** ——
|
||||
2026-10-13 实测 Zwei 满级后长按成功, 却因 'Level Up' 不在画面里被判成
|
||||
"长按未打开详情"而跳过。详情页独有的还有 Uptie 按钮与 Summary/Sanity 区块,
|
||||
网格上都不会出现。
|
||||
"""
|
||||
return ('Level Up' in txt) or ('Uptie' in txt) or ('Summary' in txt and 'Sanity' in txt)
|
||||
|
||||
|
||||
def do_uptie():
|
||||
"""在人格详情页执行同步。返回 (ok, 描述)
|
||||
|
||||
@@ -223,7 +261,8 @@ def do_uptie():
|
||||
# 弹窗还在(仍显示材料需求)说明没同步成。必须先判断这个: 弹窗里本身就有
|
||||
# 'Skills Gained', 放在成功判定后面会把失败认成成功。
|
||||
if 'Currency Req' in txt or 'Egoshard' in txt:
|
||||
click(*UPTIE_CANCEL)
|
||||
if not click_text('Cancel'):
|
||||
click(*UPTIE_CANCEL)
|
||||
time.sleep(2)
|
||||
return False, '同步未生效(通常缺自我碎片): ' + txt[:160]
|
||||
if skip_cutscene(press_esc=False):
|
||||
@@ -247,11 +286,12 @@ def cmd_card(ci, ri, uptie=False):
|
||||
return 1
|
||||
cx, cy = COLS[ci], ROWS[ri]
|
||||
print('长按卡片 col=%d row=%d @(%d,%d)' % (ci, ri, cx, cy))
|
||||
dismiss_modal()
|
||||
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:
|
||||
if not detail_page_open(txt):
|
||||
print('长按未打开详情页: ' + txt[:200])
|
||||
return 1
|
||||
print('详情页已打开')
|
||||
@@ -340,6 +380,15 @@ def read_detail(hint=None):
|
||||
direct = min(lv_cands) if lv_cands else None
|
||||
from_bar = level_from_bar(bar[0], bar[1], hint=hint) if bar else None
|
||||
|
||||
# 满级时进度条反推必然偏低: 分母是"下一级"的需求, 而等级已经封顶。
|
||||
# 2026-10-13 实测 Zwei 满级(LV40/MAX, 进度条 0/6075), 反推成 Lv.34,
|
||||
# 还顺带报了一句"与直读不符"。满级时直接读到的 LV 才是对的。
|
||||
maxed = any('MAX' in it.get('text', '').upper() for it in items)
|
||||
if maxed:
|
||||
direct_max = max(lv_cands) if lv_cands else None
|
||||
if direct_max is not None:
|
||||
return direct_max, name, bar
|
||||
|
||||
if from_bar is not None and direct is not None:
|
||||
# 两者都有时以进度条为准(数字识别比艺术字可靠), 但差异过大时告警
|
||||
if abs(from_bar - direct) > 2:
|
||||
@@ -364,11 +413,14 @@ def cmd_progress(target=34, uptie=True, max_try=6):
|
||||
return 1
|
||||
for ci, ri, cx, ry, ocr_lvl, sel, nm in team[:max_try]:
|
||||
print('--- 候选 col=%d row=%d (网格读作 Lv.%s %s)' % (ci, ri, ocr_lvl, nm))
|
||||
# 长按前先清残留弹窗: 一张卡没关干净, 后面每张都会被挡住
|
||||
if not dismiss_modal():
|
||||
print(' [warn] 有弹窗关不掉, 长按可能无效')
|
||||
long_press(cx, ry)
|
||||
time.sleep(4)
|
||||
items = state().get('items', [])
|
||||
txt = screen_text(items)
|
||||
if 'Level Up' not in txt:
|
||||
if not detail_page_open(txt):
|
||||
print(' 长按未打开详情, 跳过')
|
||||
continue
|
||||
true_lvl, true_name, _ = read_detail(hint=ocr_lvl)
|
||||
|
||||
@@ -151,5 +151,58 @@ class UptieVerdictTest(unittest.TestCase):
|
||||
self.assertEqual(screens.clicks[-1], (900, 600))
|
||||
|
||||
|
||||
class DetailPageDetectTest(unittest.TestCase):
|
||||
"""详情页判定。
|
||||
|
||||
2026-10-13 实机: Zwei 满级后详情页上的按钮是 MAX 而不是 Level Up,
|
||||
代码却用 'Level Up' not in txt 判断"长按有没有打开详情", 于是把成功的
|
||||
长按判成失败, 六张卡全部跳过, 升级环节空跑还报"无需升级"。
|
||||
"""
|
||||
|
||||
def test_normal_detail_page(self):
|
||||
self.assertTrue(levelup.detail_page_open('Level Up | Uptie | 547/885'))
|
||||
|
||||
def test_maxed_identity_without_level_up_label(self):
|
||||
# 满级: 有 MAX 和 Uptie, 但没有 'Level Up'
|
||||
t = 'Zwei Assoc. South Section 6 | LV40 | 0/6075 | MAX | Uptie++ | Summary | Sanity'
|
||||
self.assertTrue(levelup.detail_page_open(t))
|
||||
|
||||
def test_sections_only(self):
|
||||
self.assertTrue(levelup.detail_page_open('Summary | Skill | E.G.O | Sanity'))
|
||||
|
||||
def test_grid_is_not_detail_page(self):
|
||||
t = 'TEAMS#1 | IDENTITIES | E.G.O | Facades | Details | ALL | SELECTED'
|
||||
self.assertFalse(levelup.detail_page_open(t))
|
||||
|
||||
|
||||
class MaxLevelReadTest(unittest.TestCase):
|
||||
"""满级时进度条反推会偏低, 要以直读为准。
|
||||
|
||||
实测 Zwei LV40/MAX 的进度条是 0/6075, 而 6075 在表里对应 Lv.35,
|
||||
反推成 34 —— 比真实等级低了 6 级。
|
||||
"""
|
||||
|
||||
def _read(self, items):
|
||||
screens = Screens([(i['text'], i['x'], i['y']) for i in items])
|
||||
with screens.patch():
|
||||
return levelup.read_detail(hint=None)
|
||||
|
||||
def test_maxed_uses_direct_level(self):
|
||||
items = [{'text': 'Zwei Assoc. South Section 6', 'x': 1079, 'y': 155},
|
||||
{'text': 'LV40', 'x': 900, 'y': 218},
|
||||
{'text': '0/6075', 'x': 1000, 'y': 234},
|
||||
{'text': 'MAX', 'x': 700, 'y': 240}]
|
||||
lvl, name, bar = self._read(items)
|
||||
self.assertEqual(lvl, 40)
|
||||
|
||||
def test_non_maxed_still_prefers_bar(self):
|
||||
# 进度条 547/885 反推 Lv.17, 直读 LV17 一致
|
||||
items = [{'text': 'LCB Sinner', 'x': 900, 'y': 155},
|
||||
{'text': 'LV17', 'x': 900, 'y': 218},
|
||||
{'text': '547/885', 'x': 1000, 'y': 234}]
|
||||
lvl, name, bar = self._read(items)
|
||||
self.assertEqual(lvl, 17)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user