持续化刷取: 修复 TEAMS 界面判定与狂气读取重试
为"反复刷镜牢+经验、不消费狂气"的持续运行做的两处加固: 1. on_teams_screen() 判定漏判 (scripts/auto_cycle.py) 实测 OCR 把 "SIN COST" 输出成 "SINICOST"(无空格), 而判定写死了带空格的 'SIN COST', 于是 ensure_team1() 以为不在 TEAMS 页, 去点 Sinners 按钮空转, 每轮都报 "未能确认选中 TEAMS #1"。改为去空格后再比, 并同时接受 ALLIDENTITIES / ALLE.G.O 等 OCR 变体。 2. read_lunacy() 增加重试 (scripts/auto_cycle.py) 狂气校验是"不许消费"的唯一防线, 但 OCR 偶尔漏掉 LUNACY 标签, 旧代码直接 返回 None 并静默放行("读不到狂气余额, 跳过校验") —— 等于没校验。 改为重试 2 次(每次间隔 2 秒)。 3. 计划任务支持持续刷取 (scripts/install_unattended.ps1) 新增 -EveryHours N: 每 N 小时重复一轮, 而不是每天一次。 顺带修掉两处过时注释("每 5 分钟" -> 1 分钟, 实际早已是 1 分钟)。 4. 补 BOM (scripts/install_unattended.ps1, install_logon_task.ps1) Windows PowerShell 5.1 对无 BOM 的 UTF-8 按 GBK 解析, 中文串会乱码报错 (10-04 坑 6)。keep_display.ps1 本来就有, 这两个安装脚本漏了。 注意: 改动 install_unattended.ps1 会让文件 LF 变 CRLF, 属正常。 新增测试 6 个(on_teams_screen 4 个 + read_lunacy 2 个), 全套 213/213 通过。
This commit is contained in:
@@ -80,5 +80,57 @@ class RunAalcTest(unittest.TestCase):
|
||||
self.assertEqual(mcp.calls[0], ('run_task', {'count': 2, 'task': 'mirror'}))
|
||||
|
||||
|
||||
class ScreenDetectTest(unittest.TestCase):
|
||||
"""TEAMS / 网格的界面判定。
|
||||
|
||||
2026-10-13 实机: OCR 把 "SIN COST" 输出成 "SINICOST"(无空格), 而判定写死了
|
||||
带空格的 'SIN COST', 于是 ensure_team1() 以为不在 TEAMS 页, 去点 Sinners
|
||||
按钮空转, 每轮都报 "未能确认选中 TEAMS #1"。判定必须容忍空格。
|
||||
"""
|
||||
|
||||
def test_teams_screen_without_space_is_recognised(self):
|
||||
# 这是本机 OCR 的真实输出
|
||||
self.assertTrue(auto_cycle.on_teams_screen(
|
||||
'TEAMS#1 | Details | SINICOST | 000 | Dante | All Idensities'))
|
||||
|
||||
def test_teams_screen_with_space_still_recognised(self):
|
||||
self.assertTrue(auto_cycle.on_teams_screen(
|
||||
'TEAMS #1 | Details | SIN COST | 000 | Dante | All E.G.O'))
|
||||
|
||||
def test_grid_is_not_teams_screen(self):
|
||||
t = 'TEAMS#1 | IDENTITIES | E.G.O | Facades | Details'
|
||||
self.assertFalse(auto_cycle.on_teams_screen(t))
|
||||
self.assertTrue(auto_cycle.on_grid(t))
|
||||
|
||||
def test_main_menu_is_neither(self):
|
||||
t = 'Inferno | MIRROROF | Window | Sinners | Drive | Extract'
|
||||
self.assertFalse(auto_cycle.on_teams_screen(t))
|
||||
self.assertFalse(auto_cycle.on_grid(t))
|
||||
|
||||
|
||||
class LunacyReadTest(unittest.TestCase):
|
||||
"""狂气校验是"不许消费"的唯一防线, 读不到就是没校验, 所以要重试。"""
|
||||
|
||||
def test_retries_until_the_label_shows_up(self):
|
||||
calls = []
|
||||
|
||||
def fake_items():
|
||||
calls.append(1)
|
||||
if len(calls) < 3:
|
||||
return [{'text': 'LV 042', 'x': 60, 'y': 800}] # 这一帧没有 LUNACY
|
||||
return [{'text': 'LUNACY', 'x': 668, 'y': 795},
|
||||
{'text': '5864', 'x': 664, 'y': 823}]
|
||||
|
||||
with mock.patch.object(auto_cycle, 'items', fake_items), \
|
||||
mock.patch.object(auto_cycle.time, 'sleep', lambda s: None):
|
||||
self.assertEqual(auto_cycle.read_lunacy(), 5864)
|
||||
self.assertEqual(len(calls), 3)
|
||||
|
||||
def test_gives_up_after_retries(self):
|
||||
with mock.patch.object(auto_cycle, 'items', lambda: [{'text': 'LV 042', 'x': 60, 'y': 800}]), \
|
||||
mock.patch.object(auto_cycle.time, 'sleep', lambda s: None):
|
||||
self.assertIsNone(auto_cycle.read_lunacy())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user