Files
lc-mcp/scripts/lc_scene_aliases.py
T
Codex Agent 0ddd8650b7 镜牢决策补强: 确认重试回退、快感合成闸门与英文 OCR 别名
- aalc_engine: window_move 下按压保持 0.5s, 避免 Unity 漏点
- jev_mirror_agent: 技能描述抖动时 Enter 未推进改点已核对按钮并限制连续重试;
  结果页指纹忽略剧情与时钟变化; 追加的苦难不再误判为单个饰品场景;
  第 3 层起离开商店前强制做一次有界快感合成检查
- lc_scene_aliases: 补 Mounting Trials / Acquire E.G.O Gift 等标签,
  识别拆分的 Win/Bate 胜率按钮与 Max HP / Defense Level 文本
- tests: 覆盖上述回归点
2026-10-22 15:44:02 +08:00

121 lines
7.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Normalize observed English UI labels for the existing mirror controller."""
import re
LABELS = {
'confirm':'确认', 'continue':'继续', 'proceed':'继续', 'enter':'进入', 'cancel':'取消',
'leave':'离开', 'close':'关闭', 'startbattle':'开始战斗', 'startcombat':'开始战斗',
'battle!':'开始战斗', 'chainbattle!':'开始战斗',
'select':'选择', 'selectasinner':'选择一位罪人', 'chooseasinner':'选择一位罪人',
'commence':'进行判定', 'commencecheck':'进行判定', 'performcheck':'进行判定', 'checksuccess':'判定成功',
'checkfailure':'判定失败', 'checkpassed':'判定成功', 'checkfailed':'判定失败',
'result':'结果', 'options':'选项', 'choices':'选项', 'veryhigh':'极高',
'high':'高', 'shop':'商店', 'specialshop':'特殊商店', 'refresh':'刷新',
'enhancegifts':'强化饰品', 'enhancee.g.ogifts':'强化饰品', 'purchase':'购买',
'buy':'购买', 'purchased':'已购买', 'currentownedskills':'当前持有技能', 'skillsowned':'当前持有技能',
'thunderbranch':'雷枝', '雷击木':'雷枝', 'talismanbundle':'成捆的符咒',
'standard-dutybattery':'标准负载电池', 'standarddutybattery':'标准负载电池',
'thrill':'快感', 'selecte.g.ogifts':'选择E.G.O饰品',
'selecte.g.ogift':'选择E.G.O饰品', 'declinegifts':'拒绝饰品',
'declinegift':'拒绝饰品', 'refusegifts':'拒绝饰品',
'refusegift':'拒绝饰品', 'selectede.g.ogift':'选择E.G.O饰品',
'gaine.g.ogift':'获得E.G.O饰品', 'gaine.g.ogift!':'获得E.G.O饰品!',
'obtaine.g.ogift!':'获得E.G.O饰品!', 'e.g.ogiftobservation':'饰品观测',
'e.g.ogiftget!':'获得E.G.O饰品!',
'e.g.ogiftsearch':'额外观测', 'eg.dgiftsearch':'额外观测',
'nextfloor':'下一层', 'gotonextfloor':'前往下一层', 'proceedtonextfloor':'前往下一层', 'claim':'领取',
'additionalhardship':'追加的苦难', 'additionalhardships':'追加的苦难',
'mountingtrials':'追加的苦难', 'acquiree.g.ogift':'获得E.G.O饰品',
'acquiree.g.ogift!':'获得E.G.O饰品!', 'skilsowned':'当前持有技能',
'obtaine.g.ogift':'获得E.G.O饰品', 'obtaine.g.ogifts':'获得E.G.O饰品',
'claimrewards':'领取奖励', 'explorationcomplete':'探索完成',
'explorationcompleted':'探索完成', 'dungeoncomplete':'探索完成',
'drive':'驾驶席', 'sinners':'罪人', 'exploring:':'探索状态',
'beforeentry':'入场前', 'retry':'重试', 'dungeonprogress':'迷宫进度',
}
def normalize(state):
if state.get('_lc_labels_normalized'):
return state
rate_items = []
source_items = state.get('items') or []
for item in source_items:
raw = item['text']
compact = re.sub(r'\s+', '', raw).lower().lstrip('×x')
compact = compact.replace('e.g.0', 'e.g.o')
compact = re.sub(r'fl[o0]{2}r', 'floor', compact)
text = LABELS.get(compact, raw)
screen = state.get('screen', {})
if item.get('x', 0) > screen.get('w', 1920) * .65 and item.get('y', 0) > screen.get('h', 1080) * .5:
if compact in ('winrate', 'damage'):
text = '胜率' if compact == 'winrate' else '伤害'
elif compact == 'win' and any(
re.sub(r'\s+', '', other['text']).lower() in ('rate', 'bate')
and abs(other['x'] - item['x']) < 40
and 0 < other['y'] - item['y'] < 35 for other in source_items):
text = '胜率'
if compact == 'enhance' and any(re.sub(r'\s+', '', other['text']).lower() == 'gifts'
and abs(other['x'] - item['x']) < 80 and 0 < other['y'] - item['y'] < 70
for other in source_items):
text = '强化饰品'
if text == raw:
if compact.startswith('aservererrorhasoccurred'):
text = '服务器发生错误'
elif re.fullmatch(r'retry(?:\d+|[>→»]+)?', compact):
text = '重试'
elif re.match(r'gain[0-9~〜+\-]+cost', compact):
text = '经费 ' + raw
elif re.match(r'e\.?g\.?o\.?resource', compact):
text = '资源 ' + raw
match = re.search(r'select(?:the)?(?:floor)?(\d+)(?:st|nd|rd|th)?floorthemepack', compact)
if not match:
match = re.search(r'selectfloorthemepack(?:for)?floor(\d+)', compact)
if not match:
match = re.search(r'selectfloor(\d+)themepack', compact)
if match:
text = '选择%s层主题卡包' % match[1]
elif re.search(r'(?:select|choose).*encounterreward', compact):
text = '选择遭遇战奖励卡'
elif re.search(r'exploring(?:floor)?\d+', compact):
text = '正在探索第%s层' % re.search(r'\d+', compact)[0]
elif compact.startswith('exploringfloor'):
# A missing/misread floor number still identifies the map.
# Leave the stored floor unchanged rather than invent a digit.
text = '正在探索 ' + raw
elif compact.startswith('select') and re.search(r'\d+/\d+', compact):
text = '选择' + re.search(r'\d+/\d+', compact)[0]
elif compact.startswith('refresh'):
text = raw.replace(raw[:7], '刷新')
elif compact.startswith('chooseacharactertoperform'):
text = '选择一位罪人'
elif re.match(r'who(?:will|should)', compact):
text = '应该让谁 ' + raw
elif (compact.startswith('skillreplacement') or compact.startswith('replaceskill')
or re.match(r'(?:replace|change).*skil', compact)):
text = '技能替换 ' + raw
elif 'spend' in compact and 'replac' in compact and 'skil' in compact:
text = '是否消耗 技能替换 ' + raw
# English OCR sometimes merges several adjacent probability labels.
# Keep each explicit Very High span as a separate observed candidate.
if item.get('y', 0) > state.get('screen', {}).get('h', 1080) * .8 and 'veryhigh' in compact:
for match in re.finditer('veryhigh', compact):
center = item['x'] + (match.start() + len(match[0]) / 2) * item['w'] / len(compact)
rate_items.append(dict(item, text='极高', original_text=raw,
x=round(center - 25), w=50))
for english, chinese in [('Sinclair','辛克莱'), ('Hong Lu','鸿璐'),
('Heathcliff','希斯克利夫'), ('Outis','奥提斯'), ('Gregor','格里高尔'),
('Ryoshu','良秀'), ('Faust','浮士德')]:
text = text.replace(english, chinese)
text = re.sub(r'Max\s*HP', '体力上限', text, flags=re.I)
text = re.sub(r'Defense\s*Level', '防御等级', text, flags=re.I)
if re.fullmatch(r'\d+/\d+', compact) and any(
re.sub(r'\s+', '', other['text']).lower() in ('select', '选择')
and 0 < item['x'] - other['x'] < 150
and abs(item['y'] - other['y']) < 30 for other in source_items):
text = '选择' + compact
if text != raw:
item['original_text'] = raw
item['text'] = text
state['items'] = (state.get('items') or []) + rate_items
state['_lc_labels_normalized'] = True
return state