|
|
@@ -0,0 +1,32 @@
|
|
|
+"""heal_guard — 战斗任务共用的喝药防线。
|
|
|
+
|
|
|
+每个战斗任务(t02-t05/t08)入口调用 ensure_heal(ctx):
|
|
|
+读态已 on → 零帧直返; off → 切一次验证; 高危图(沃玛/蜈蚣)验证失败
|
|
|
+即拒绝开跑(裸奔送死 — 2026-10-01 姚孤沃玛双杀双死实证)。
|
|
|
+"""
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+from pbot.game.heal import enable_auto_heal
|
|
|
+from pipeline.ctx import PipelineContext, TaskResult
|
|
|
+
|
|
|
+_HIGH_RISK_FAIL = "高危图喝药保护未开启 — 拒绝开跑(防裸奔送死)"
|
|
|
+
|
|
|
+
|
|
|
+def ensure_heal(ctx: PipelineContext, high_risk: bool = False) -> TaskResult | None:
|
|
|
+ """确保喝药保护 on。
|
|
|
+
|
|
|
+ 返回 None=已 on 可继续; 返回 TaskResult=失败(detail 含状态),
|
|
|
+ high_risk=True 时读态任何非 on 都拒绝, 否则告警放行(低危图)。
|
|
|
+ """
|
|
|
+ state = None
|
|
|
+ for _ in range(2):
|
|
|
+ state = enable_auto_heal(ctx.conn, ctx.sid, want_on=True,
|
|
|
+ world=ctx.world)
|
|
|
+ if state == "on":
|
|
|
+ ctx.log.info("[喝药✓] on")
|
|
|
+ return None
|
|
|
+ ctx.log.warning("[喝药✗] state=%s — 重试一轮", state)
|
|
|
+ if high_risk or state == "off":
|
|
|
+ return TaskResult.fail(f"{_HIGH_RISK_FAIL}(终态={state})")
|
|
|
+ ctx.log.warning("[喝药?] 终态=%s(低危图继续)", state)
|
|
|
+ return None
|