镜牢兔子洞速刷: 每场第一回合超频「空洞」、攻略路线卡包加分
run_task(task="mirror", strategy="rabbit_hole") 时生效, 不带 strategy 时不装: - 选队按 rabbit_hole.json 的编队名(默认「兔子洞」); - 每回合 P → 长按浮士德打开 E.G.O 列表 → OCR 找「空洞」, 第一回合长按卡片超频 (侵蚀「空洞」直接打人; 普通「空洞」只叠弹孔), 其余回合单击 → Enter; 审计 battle/hollow 记 overclock/ego/ego_unavailable/no_option; - 路线卡包加分: 赌徒 → 地狱鸡 → 去·海·边 → 憎恶与绝望 → 2号线(OurPlay 全程困难路线), 按 AALC 默认权重模拟每层都选到路线卡包。 长按点 press_at 出厂未校准: 只记 [ERROR], 照常 P+Enter。 机制和超频操作按零协游戏文本/教程核实; 编队、路线按 codex 检索的 OurPlay/Reddit 攻略。 实机校准步骤见 docs/feedback/2026-11-15/RABBIT-HOLE.md, 台账 R-08。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+192
-9
@@ -716,10 +716,11 @@ def _select_team_by_name(auto, names, log=print, rounds=6):
|
||||
return False
|
||||
|
||||
|
||||
def install_system_team_selection(log=print):
|
||||
def install_system_team_selection(log=print, names=None):
|
||||
"""镜牢选队改成"按队伍体系对应的中文名"在列表里点。
|
||||
|
||||
AALC 原生只认 编队#N; 本账号的编队是自定义名字(流血/斩击/...), 原生逻辑永远选不上。
|
||||
names 给了就不看体系, 直接按这些名字选(兔子洞这类固定编队的打法用)。
|
||||
"""
|
||||
try:
|
||||
from tasks.mirror import mirror as mirror_mod
|
||||
@@ -737,8 +738,8 @@ def install_system_team_selection(log=print):
|
||||
def __init__(self, team_setting, team_num):
|
||||
original_init(self, team_setting, team_num)
|
||||
system = getattr(self, 'system', '')
|
||||
wanted['names'] = (SYSTEM_TEAM_NAMES.get(system, ())
|
||||
+ TEAM_PREFERENCES.get(system, ()))
|
||||
wanted['names'] = tuple(names) if names else (SYSTEM_TEAM_NAMES.get(system, ())
|
||||
+ TEAM_PREFERENCES.get(system, ()))
|
||||
wanted['enter_failed'] = False
|
||||
log('[lc_mcp] 镜牢体系 %s -> 目标编队 %s'
|
||||
% (system or '?', '/'.join(wanted['names']) or '(无配置)'))
|
||||
@@ -1642,6 +1643,7 @@ def theme_pack_bonus(pack, system, bonus):
|
||||
|
||||
体系包给 featured 档, 有这个体系的专属饰品按件数给 unique 档, 社区推荐给 recommend 档, 取最大;
|
||||
社区说这个体系走它不划算(avoid 里有这个体系)就不加; 速刷要避开的(avoid 里有 '*')再减 avoid。
|
||||
打法指定的路线卡包(pack['route'] 是它的加分, 如兔子洞)最后算, 至少给这么多, 不受体系和 avoid 影响。
|
||||
"""
|
||||
score = bonus['featured'] if system in (pack.get('featured') or ()) else 0
|
||||
count = (pack.get('unique') or {}).get(system, 0)
|
||||
@@ -1654,6 +1656,8 @@ def theme_pack_bonus(pack, system, bonus):
|
||||
score = min(score, 0)
|
||||
if '*' in avoid:
|
||||
score -= bonus.get('avoid', 0)
|
||||
if pack.get('route'):
|
||||
score = max(score, pack['route'])
|
||||
return score
|
||||
|
||||
|
||||
@@ -1719,8 +1723,12 @@ def boost_theme_pack_weights(weights, packs, system, bonus, language='zh_cn', ha
|
||||
return result, {k: info[k] for k in ordered}
|
||||
|
||||
|
||||
def install_theme_pack_systems(log=print, env=None):
|
||||
"""镜牢选卡包时按当局体系给卡包加分。返回原 select_theme_pack, 未安装返回 None。"""
|
||||
def install_theme_pack_systems(log=print, env=None, route=None, route_name='路线'):
|
||||
"""镜牢选卡包时按当局体系给卡包加分。返回原 select_theme_pack, 未安装返回 None。
|
||||
|
||||
route 是打法指定的路线卡包 {中文名: 加分}(如兔子洞的 rabbit_hole.json theme_packs), 每个至少加这么多,
|
||||
当局没有体系也照加。
|
||||
"""
|
||||
env = os.environ if env is None else env
|
||||
setting = env.get(THEME_PACK_SYSTEMS_ENV, '').strip()
|
||||
if setting == '0':
|
||||
@@ -1732,6 +1740,14 @@ def install_theme_pack_systems(log=print, env=None):
|
||||
except (OSError, ValueError) as e:
|
||||
log('[ERROR] [lc_mcp] 卡包体系表读不了(%s): %s, 卡包按 AALC 原权重选' % (path, e))
|
||||
return None
|
||||
route = dict(route or {})
|
||||
if route:
|
||||
known = {pack['zh'] for pack in packs}
|
||||
missing = [name for name in route if name not in known]
|
||||
if missing:
|
||||
log('[ERROR] [lc_mcp] %s卡包不在卡包表里, 不加分: %s' % (route_name, '/'.join(missing)))
|
||||
route = {name: extra for name, extra in route.items() if name in known}
|
||||
packs = [dict(pack, route=route[pack['zh']]) if pack['zh'] in route else pack for pack in packs]
|
||||
try:
|
||||
import inspect
|
||||
from tasks.mirror import mirror as mirror_mod
|
||||
@@ -1761,7 +1777,9 @@ def install_theme_pack_systems(log=print, env=None):
|
||||
THEME_PACK_BOOSTED.clear()
|
||||
system = state['system']
|
||||
if system not in SYSTEM_TEAM_NAMES:
|
||||
return original(*args, **kwargs)
|
||||
if not route:
|
||||
return original(*args, **kwargs)
|
||||
system = None # 没有体系: 只加路线分(体系包、专属饰品、社区推荐都按 None 算 0)
|
||||
real = theme_list.get_effective_theme_pack_list
|
||||
|
||||
def get_effective_theme_pack_list(hard_mode, language, *more, **kw):
|
||||
@@ -1773,8 +1791,9 @@ def install_theme_pack_systems(log=print, env=None):
|
||||
log('[lc_mcp] 卡包按体系加分出错(%s: %s), 用 AALC 原权重' % (type(e).__name__, e))
|
||||
return weights
|
||||
if info:
|
||||
log('[lc_mcp] 卡包按体系 %s 加分: %s' % (system, ', '.join(
|
||||
'%s %d→%d' % (key, item['from'], item['to']) for key, item in info.items())))
|
||||
log('[lc_mcp] 卡包按体系 %s%s 加分: %s' % (
|
||||
system or '(无)', ('+' + route_name) if route else '', ', '.join(
|
||||
'%s %d→%d' % (key, item['from'], item['to']) for key, item in info.items())))
|
||||
THEME_PACK_BOOSTED.update(info)
|
||||
return result
|
||||
|
||||
@@ -1784,7 +1803,9 @@ def install_theme_pack_systems(log=print, env=None):
|
||||
select_theme_pack.__wrapped__ = original
|
||||
mirror_mod.Mirror.__init__ = __init__
|
||||
mirror_mod.select_theme_pack = select_theme_pack
|
||||
log('[lc_mcp] patch: 镜牢卡包按体系加分(%s, %d 个卡包)' % (os.path.basename(path), len(packs)))
|
||||
log('[lc_mcp] patch: 镜牢卡包按体系加分(%s, %d 个卡包%s)' % (
|
||||
os.path.basename(path), len(packs),
|
||||
', %s %s' % (route_name, ' '.join('%s+%d' % item for item in route.items())) if route else ''))
|
||||
return original
|
||||
|
||||
|
||||
@@ -1973,3 +1994,165 @@ def install_key_hold(log=print, env=None, user32=None):
|
||||
log('[lc_mcp] patch: 按键按住 %dms 再松开, 前台改发带扫描码的按键(%s)'
|
||||
% (KEY_HOLD * 1000, '/'.join(sorted(originals))))
|
||||
return originals
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 镜牢「兔子洞」速刷: 每回合给浮士德放「空洞」
|
||||
|
||||
# 「兔子洞」(英文社区 Mao Hollow Faust) = 黑兽 - 卯 魁首 浮士德 + 浮士德的 E.G.O「空洞」。游戏数据(零协 2026111301):
|
||||
# 普通「空洞」不打敌人, 只给自己叠 5 发弹孔; 弹孔不低于 1 发时改用「填补空洞」(大伤害); 侵蚀「空洞」随机打人。
|
||||
# E.G.O 被动: 弹孔满 5 发时「空洞」(觉醒、侵蚀)不耗 E.G.O 资源, 每回合开始 +1 发。攻略(OurPlay 777774): 每场第一回合
|
||||
# 超频(强制用侵蚀技能)直接清场。AALC 战斗只会 P+Enter, 不会放 E.G.O。游戏教程: 按住罪人的头像打开 E.G.O 列表
|
||||
# (wiki.gg 写的是按住技能格), 单击 E.G.O 是普通放, 长按 E.G.O 是超频。完整依据见 docs/feedback/2026-11-15/RABBIT-HOLE.md。
|
||||
RABBIT_HOLE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'rabbit_hole.json')
|
||||
RABBIT_HOLE_POPUP_WAIT = 0.6 # 长按松开后等 E.G.O 列表弹出
|
||||
RABBIT_HOLE_SETTLE = 0.4 # 点完 E.G.O 等界面刷新
|
||||
|
||||
|
||||
def load_rabbit_hole(path=RABBIT_HOLE_FILE):
|
||||
"""读兔子洞配置; 格式不对抛 ValueError。"""
|
||||
with open(path, encoding='utf-8') as fh:
|
||||
data = json.load(fh)
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError('配置必须是 JSON 对象')
|
||||
|
||||
def names(field):
|
||||
value = data.get(field)
|
||||
if not isinstance(value, list) or not value or \
|
||||
not all(isinstance(v, str) and normalize_team_name(v) for v in value):
|
||||
raise ValueError('%s 必须是非空字符串列表' % field)
|
||||
return tuple(normalize_team_name(v) for v in value)
|
||||
|
||||
press_at = data.get('press_at')
|
||||
if press_at is not None:
|
||||
if not isinstance(press_at, list) or len(press_at) != 2 or \
|
||||
not all(isinstance(v, (int, float)) and 0 < v < 1 for v in press_at):
|
||||
raise ValueError('press_at 必须是 null 或 [宽比例, 高比例], 都在 0~1 之间')
|
||||
press_at = (float(press_at[0]), float(press_at[1]))
|
||||
hold = data.get('hold_seconds', 1.0)
|
||||
if isinstance(hold, bool) or not isinstance(hold, (int, float)) or not 0.2 <= hold <= 5:
|
||||
raise ValueError('hold_seconds 必须在 0.2~5 秒之间')
|
||||
overclock = data.get('overclock_first_turn', False)
|
||||
if not isinstance(overclock, bool):
|
||||
raise ValueError('overclock_first_turn 必须是 true/false')
|
||||
packs = data.get('theme_packs', {})
|
||||
if not isinstance(packs, dict) or not all(
|
||||
isinstance(k, str) and k.strip() and not isinstance(v, bool) and isinstance(v, int) and 0 < v <= 50
|
||||
for k, v in packs.items()):
|
||||
raise ValueError('theme_packs 必须是 {卡包中文名: 加分(1~50 的整数)}')
|
||||
return {'team_names': names('team_names'), 'ego_names': names('ego_names'),
|
||||
'press_at': press_at, 'hold_seconds': float(hold), 'overclock_first_turn': overclock,
|
||||
'theme_packs': {k.strip(): v for k, v in packs.items()}}
|
||||
|
||||
|
||||
def find_ego_option(lines, ego_names, near=None):
|
||||
"""OCR 逐行结果里找 E.G.O 名字(归一后完全相等); 有几条取离长按点最近的。返回 (文本, x, y) 或 None。"""
|
||||
hits = [(text, x, y) for text, x, y in lines if normalize_team_name(text) in ego_names]
|
||||
if not hits:
|
||||
return None
|
||||
if near is None:
|
||||
return hits[0]
|
||||
return min(hits, key=lambda hit: (hit[1] - near[0]) ** 2 + (hit[2] - near[1]) ** 2)
|
||||
|
||||
|
||||
def rabbit_hole_turn(auto, cfg, config, log=print, overclock=False):
|
||||
"""接管一回合: P → 长按浮士德(press_at)打开 E.G.O 列表 → 选「空洞」→ Enter。
|
||||
|
||||
overclock=True 时长按 E.G.O 卡片(超频: 1.5 倍资源和理智, 强制用侵蚀技能), 否则单击。
|
||||
返回结果: ego / overclock / ego_unavailable / no_option。
|
||||
按过 P 就一定按 Enter(中途出错也一样): 交回 AALC 会再按一次 P, 而 P 是在胜率/伤害之间切换。
|
||||
"""
|
||||
width, height = cfg.set_win_size * 16 / 9, cfg.set_win_size
|
||||
x, y = config['press_at'][0] * width, config['press_at'][1] * height
|
||||
names = config['ego_names']
|
||||
result = 'no_option'
|
||||
auto.key_press('p')
|
||||
try:
|
||||
time.sleep(0.5)
|
||||
auto.mouse_drag(x, y, drag_time=config['hold_seconds'], dx=0, dy=0)
|
||||
time.sleep(RABBIT_HOLE_POPUP_WAIT)
|
||||
auto.take_screenshot()
|
||||
lines = _ocr_lines(auto)
|
||||
hit = find_ego_option(lines, names, near=(x, y))
|
||||
if hit is None:
|
||||
log('[lc_mcp] 兔子洞: 长按 (%d,%d) 后没找到 E.G.O「%s」; 这一屏: %s'
|
||||
% (x, y, '/'.join(names), '/'.join(str(t) for t, _, _ in lines[:20]) or '(空)'))
|
||||
else:
|
||||
if overclock:
|
||||
auto.mouse_drag(hit[1], hit[2], drag_time=config['hold_seconds'], dx=0, dy=0)
|
||||
else:
|
||||
auto.mouse_click(hit[1], hit[2])
|
||||
time.sleep(RABBIT_HOLE_SETTLE)
|
||||
auto.take_screenshot()
|
||||
if find_ego_option(_ocr_lines(auto), names) is None:
|
||||
result = 'overclock' if overclock else 'ego'
|
||||
else:
|
||||
result = 'ego_unavailable' # 列表还开着: 资源不够(灰的)或没点上
|
||||
log('[lc_mcp] 兔子洞: %s「%s」后列表还在(可能 E.G.O 资源不够), 这回合按胜率打'
|
||||
% ('长按' if overclock else '点了', hit[0]))
|
||||
if result not in ('ego', 'overclock'):
|
||||
auto.mouse_click_blank() # 关掉弹出的列表
|
||||
time.sleep(RABBIT_HOLE_SETTLE)
|
||||
finally:
|
||||
auto.key_press('enter')
|
||||
decisions.record('battle', 'hollow', result)
|
||||
return result
|
||||
|
||||
|
||||
def install_rabbit_hole(log=print, config=None):
|
||||
"""镜牢战斗每回合给浮士德放「空洞」。返回原 Battle._battle_operation, 未安装返回 None。"""
|
||||
try:
|
||||
config = config or load_rabbit_hole()
|
||||
except (OSError, ValueError) as e:
|
||||
log('[ERROR] [lc_mcp] 兔子洞配置读不了(%s): %s' % (RABBIT_HOLE_FILE, e))
|
||||
return None
|
||||
try:
|
||||
from tasks.battle.battle import Battle
|
||||
from module.automation import auto
|
||||
from module.config import cfg
|
||||
except Exception as e:
|
||||
log('[lc_mcp] 兔子洞补丁跳过: 无法导入 %s' % e)
|
||||
return None
|
||||
original = getattr(Battle, '_battle_operation', None)
|
||||
if original is None or _source_mentions(original, 'auto.key_press("p")', 'auto.key_press("enter")') is False:
|
||||
log('[ERROR] [lc_mcp] 上游 Battle._battle_operation 不再是 P+Enter 出手, 兔子洞补丁挂不上, 跳过')
|
||||
return None
|
||||
state = {'warned': False}
|
||||
overclock = config.get('overclock_first_turn', False)
|
||||
signature = None
|
||||
if overclock:
|
||||
import inspect
|
||||
try:
|
||||
signature = inspect.signature(original)
|
||||
except (TypeError, ValueError):
|
||||
signature = None
|
||||
if signature is None or 'first_turn' not in signature.parameters:
|
||||
log('[ERROR] [lc_mcp] 上游 Battle._battle_operation 没有 first_turn 参数, 兔子洞第一回合不超频, 只放普通「空洞」')
|
||||
overclock = False
|
||||
|
||||
def first_turn(self, args, kwargs):
|
||||
try:
|
||||
return bool(signature.bind(self, *args, **kwargs).arguments.get('first_turn'))
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
def _battle_operation(self, *args, **kwargs):
|
||||
if config['press_at'] is None:
|
||||
if not state['warned']:
|
||||
state['warned'] = True
|
||||
log('[ERROR] [lc_mcp] 兔子洞: rabbit_hole.json 的 press_at 还没在实机上量, 本次按 AALC 原来的 P+Enter 打')
|
||||
return original(self, *args, **kwargs)
|
||||
try:
|
||||
rabbit_hole_turn(auto, cfg, config, log=log,
|
||||
overclock=overclock and first_turn(self, args, kwargs))
|
||||
except InterruptedError:
|
||||
raise # AALC 的暂停/停止
|
||||
except Exception as e: # Enter 已经在 rabbit_hole_turn 的 finally 里按过, 这回合照常打
|
||||
log('[lc_mcp] 兔子洞: 这回合出错(%s: %s), 已按 Enter' % (type(e).__name__, e))
|
||||
return False # 上游的返回值是「小指良单通的连续防御是否执行」
|
||||
|
||||
_battle_operation.__wrapped__ = original
|
||||
Battle._battle_operation = _battle_operation
|
||||
log('[lc_mcp] patch: 镜牢兔子洞: 每回合给浮士德放 E.G.O「%s」%s(%s)'
|
||||
% ('/'.join(config['ego_names']), ', 每场第一回合超频' if overclock else '',
|
||||
'长按点未校准, 先按 P+Enter' if config['press_at'] is None else '长按 %.3f,%.3f' % config['press_at']))
|
||||
return original
|
||||
|
||||
Reference in New Issue
Block a user