---
name: path_elimination_rules.aigameplay
description: 路径消除玩法核心规则（PGS）。棋盘上有多条彩色折线路径，末端有方向箭头。玩家点击箭头头部：出口方向空闲则消除路径；被阻挡则扣命。全部路径消除后胜利，生命耗尽或倒计时归零则失败。
triggers: 需要生成路径消除类玩法的 reducer、PGS schema、关卡规则时触发。
---

# 路径消除玩法（Path Elimination）

## 玩法说明

棋盘上有若干彩色折线路径（polyline），每条路径末端有一个方向箭头。玩家点击箭头头部尝试消除该路径：

- **成功消除**：箭头方向上到棋盘边界的所有格子均空闲 → 路径滑出动画 → 加入已消除集合 → 连击计数
- **阻挡失败**：出口方向被其他路径占据 → 阻挡动画 → 扣除 1 条命 → 连击重置
- **胜利**：所有路径消除（`removedPaths.size >= level.paths.length`）
- **失败**：生命值归零（`currentLives <= 0`）或倒计时归零（仅当 `levelTime > 0`）

## Recipe

```json
{
  "kind": "pgs",
  "pgsVersion": "1.0",
  "gameplayType": "path_elimination",
  "rules": {
    "gridSizeDynamic": true,
    "livesInitial": 3,
    "timerOptional": true,
    "comboEnabled": true
  }
}
```

完整 PGS Schema 见 `ref/pgs-schema.json`。

## Result

产物为 `ref/pgs-schema.json`，描述完整的路径消除玩法规则，包含：

- 实体定义（grid / path / lives / timer / combo）
- 规则（命中检测 / 消除逻辑 / 阻挡逻辑 / 连击 / 输入锁）
- 关卡数据 schema（RawLevelJson 格式）
- 算法步骤（8 步主循环）
- 胜负条件
- 5 个测试用例

## Binding

```json
{
  "role": "gameplayRule",
  "target": "src/game/",
  "type": "gameplay-module-reference",
  "constraints": {
    "requiredComponents": [
      "arrow_path_data_format.aicomponent",
      "path_renderer.aicomponent",
      "path_animation.aicomponent",
      "path_input_handler.aicomponent",
      "level_lifecycle.aicomponent"
    ]
  }
}
```

## Skill Definition

```yaml
tools:
  - read_file
  - write_file
inputs:
  - pgsSchema: ref/pgs-schema.json
outputs:
  - reducerTemplate: game logic reducer based on PGS schema
```

## 与旧 arrow_escape_core.aigameplay 的区别

| 维度 | 旧版（已废弃） | 新版 |
|-----|------------|-----|
| 玩法描述 | 玩家放置箭头引导角色到出口（roguelike 移动） | 玩家点击路径箭头头部消除（拼图消除） |
| 网格模型 | 固定 6×6，cell 有 arrow/wall/trap/exit 类型 | 动态尺寸，path 为折线实体，grid 仅作坐标系 |
| 输入 | 放置/旋转箭头（消耗步数） | 点击路径头部（不消耗步数，有生命值） |
| 胜负 | 角色到达 exit / 到达 trap 或出界 | 路径全消除 / 生命归零或超时 |
| 消除机制 | 不存在 | 路径沿方向滑出棋盘（需出口方向空闲） |

旧版 `arrow_escape_core.aigameplay` 已被本 skill 替代，可安全删除。
