diff --git a/scripts/convert_modules.py b/scripts/convert_modules.py index 4dc4c94..178eb57 100644 --- a/scripts/convert_modules.py +++ b/scripts/convert_modules.py @@ -525,6 +525,9 @@ def main(argv=None): break time.sleep(3) log('合成前狂气(OCR, 作相对比对用): %s' % lunacy_before) + # 读到就记进报告 —— 后面可能因为体力不足提前收工, 那时这条读数不该丢。 + _result['lunacy_before'] = lunacy_before + _result['converted'] = False # 体力读数也要重试。单次读成 None 的话, 下面"体力不足就收工"这层判断会被 # 整个跳过, 于是明明只是体力不够, 却要去点合成、最后报成 FAIL(退出码 1) —— @@ -552,6 +555,7 @@ def main(argv=None): ok, info, got = convert_once() _result['steps'].append({'step': '合成', 'ok': ok, 'info': info}) + _result['converted'] = bool(got) log('合成: %s (%s)' % ('OK' if ok else 'FAIL', info)) time.sleep(2) @@ -583,7 +587,6 @@ def main(argv=None): _result['lunacy_before'] = lunacy_before _result['lunacy_after'] = lunacy_after _result['lunacy_checked'] = (lunacy_before is not None and lunacy_after is not None) - if not args.keep_game: close_game() diff --git a/scripts/modules_status.py b/scripts/modules_status.py index 7e1842a..29b8761 100644 --- a/scripts/modules_status.py +++ b/scripts/modules_status.py @@ -43,12 +43,17 @@ def summarize(rows): checked = r.get('lunacy_checked') if checked is None: # 老报告没这个字段 checked = lb is not None and la is not None + converted = r.get('converted') + if converted is None: + # 老报告没有 converted, 按结果文本推断 + converted = '合成完成' in (r.get('result') or '') out.append({ 'started': r.get('started', '?'), 'ok': bool(r.get('ok')), 'result': r.get('result', ''), 'elapsed_s': r.get('elapsed_s'), 'info': conv.get('info', ''), + 'converted': bool(converted), 'lunacy_before': lb, 'lunacy_after': la, 'lunacy_checked': bool(checked), @@ -61,6 +66,10 @@ def lunacy_cell(r): """狂气那格的显示。没比对上时明说, 不装作校过了。""" if r['lunacy_alarm']: return '⚠️ %s -> %s' % (r['lunacy_before'], r['lunacy_after']) + if not r['converted']: + # 这轮压根没合成, 没什么可比 —— 和"合成过但没读到"是两回事 + n = r['lunacy_before'] + return '未合成(读到 %s)' % n if n is not None else '未合成' if not r['lunacy_checked']: return '未比对' return '%s 前后一致' % r['lunacy_after'] @@ -94,20 +103,22 @@ def main(argv=None): print('还没有合成记录(%s)' % args.dir) return 0 - got = sum(1 for r in rows if '+1' in r['info'] or '模组' in r['info'] and '->' in r['info']) + got = sum(1 for r in rows if r['converted']) fails = [r for r in rows if not r['ok']] alarms = [r for r in rows if r['lunacy_alarm']] - unchecked = [r for r in rows if not r['lunacy_checked']] + # 只统计"真的合成过却没能比对"的 —— 没合成的轮次没什么可比, 混进来会虚高 + unchecked = [r for r in rows if r['converted'] and not r['lunacy_checked']] - print('共 %d 轮: 换到模块 %d 轮, 失败 %d 轮, 狂气告警 %d 轮, 未比对 %d 轮' + print('共 %d 轮: 换到模块 %d 轮, 失败 %d 轮, 狂气告警 %d 轮, 该比对却没比对 %d 轮' % (len(rows), got, len(fails), len(alarms), len(unchecked))) if alarms: print('⚠️ 有狂气告警, 需要人工核查:') for r in alarms: print(' %s %s' % (r['started'], r['result'])) - if unchecked and not alarms: - print(' 提示: 有 %d 轮没读到狂气(前后至少一次是 None), 那几轮等于没校过。' - % len(unchecked)) + if unchecked: + print('⚠️ 这些轮次合成过但狂气没读全, 等于没校过:') + for r in unchecked: + print(' %s %s' % (r['started'], r['result'])) # 连着失败(最新几条都不是好结果)要醒目 —— 那说明流程坏了 streak = 0 for r in rows: diff --git a/tests/test_modules_status.py b/tests/test_modules_status.py index 136add1..8f1830d 100644 --- a/tests/test_modules_status.py +++ b/tests/test_modules_status.py @@ -67,24 +67,52 @@ class LunacyColumnTest(unittest.TestCase): """ def test_checked_run_shows_agreement(self): - r = ms.summarize([{'started': 'x', 'ok': True, 'result': 'r', 'elapsed_s': 10, + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', 'elapsed_s': 10, + 'converted': True, 'lunacy_before': 9699, 'lunacy_after': 9699, 'lunacy_checked': True}])[0] self.assertTrue(r['lunacy_checked']) self.assertIn('9699', ms.lunacy_cell(r)) def test_unchecked_run_says_so(self): - r = ms.summarize([{'started': 'x', 'ok': True, 'result': 'r', 'elapsed_s': 10, + # 合成过但狂气没读全 -> 必须明说"未比对"(不能装作校过了) + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', 'elapsed_s': 10, + 'converted': True, 'lunacy_before': None, 'lunacy_after': 9699, 'lunacy_checked': False}])[0] self.assertFalse(r['lunacy_checked']) - # 不能装作校过了 self.assertEqual(ms.lunacy_cell(r), '未比对') + def test_skipped_run_is_not_counted_as_unchecked(self): + """没合成的轮次没什么可比, 不该混进"该比对却没比对"。 + + 混进去会让这个数字虚高, 掩盖真正有问题的那几轮。 + """ + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '体力不足(4<20), 本轮无需合成', 'elapsed_s': 10, + 'converted': False, 'lunacy_before': 9699, + 'lunacy_checked': False}])[0] + self.assertFalse(r['converted']) + self.assertEqual(ms.lunacy_cell(r), '未合成(读到 9699)') + + def test_old_report_infers_converted_from_result_text(self): + # 老报告没有 converted 字段, 按结果文本推断 + r = ms.summarize([{'started': 'x', 'ok': True, + 'result': '合成完成: 模组 29 -> 30 (+1)', + 'elapsed_s': 10}])[0] + self.assertTrue(r['converted']) + r2 = ms.summarize([{'started': 'y', 'ok': True, + 'result': '体力不足(4<20), 本轮无需合成', + 'elapsed_s': 10}])[0] + self.assertFalse(r2['converted']) + def test_alarm_is_visible_in_the_cell(self): r = ms.summarize([{'started': 'x', 'ok': False, 'result': '⚠️ 狂气读数发生变化 9699 -> 6300, 立即停止并人工核查', - 'elapsed_s': 10, 'lunacy_before': 9699, 'lunacy_after': 6300, + 'elapsed_s': 10, 'converted': True, + 'lunacy_before': 9699, 'lunacy_after': 6300, 'lunacy_checked': True}])[0] self.assertTrue(r['lunacy_alarm']) self.assertIn('⚠️', ms.lunacy_cell(r))