---
name: game_scene.aicomponent
description: Phaser 主游戏场景（协调器）。持有并协调棋盘布局、玩法逻辑、UI 组件、输入处理、动画管理等所有游戏子系统的实例化和生命周期。
triggers: 需要实现游戏主场景、协调各子系统初始化时触发。
---

# 主游戏场景（Main Game Scene）

## 说明

`Game` 是游戏的主 Phaser 场景，作为所有子系统的**协调器**（Coordinator）：

- 初始化并持有：`BoardLayout`、`InputHandler`、`AnimationManager`、`LevelLifecycle`、`ComboManager`、`TutorialManager` 等所有子系统实例
- 在 `create()` 中依次初始化棋盘、绘制路径、绑定输入、创建 UI
- 在 `update()` 中处理帧逻辑（倒计时等）
- 持有共享状态：`removedPaths`、`blockedPaths`、`animatingPaths`、`currentLives`、`zoom` 等

## Scaffold

| 目标路径 | 来源 | 说明 |
|---------|-----|-----|
| `src/game/scenes/Game.ts` | `ref/Game.ts` | 完整主游戏场景 |

## Recipe

| 决策 | 原因 |
|------|------|
| **协调器模式，不含业务逻辑** | Game.ts 只负责「把谁注册到哪里」，业务逻辑在 InputHandler/AnimationManager/LevelLifecycle 中；Game.ts 不直接操作路径消除逻辑，避免成为难以维护的 God Object |
| **共享状态挂在 GameScene** | `removedPaths`、`currentLives`、`isInputLocked` 等需多个子系统读写的状态集中在 Game 实例上，子系统通过 `InputGameRef`/`LevelLifecycleGameRef` 接口访问，避免相互直接引用 |
| **DAG 顶层节点** | GameScene 是最上层协调者，无被其他 skill 依赖（除 phaser_scene_lifecycle 约定的注册位置）；所有依赖关系单向向下 |

## Adapter

- **Role**: `gameMainScene` — Phaser 主游戏场景（DAG 顶层协调器）
- **Provides**: `Game` class（Phaser 主场景，`create()` 协调初始化 + `update()` 帧逻辑）
- **Requires**: `phaser.aicomponent`、`phaser_scene_lifecycle.aicomponent`、`grid_board_layout.aicomponent`、`path_elimination_rules.aigameplay`
- **Consumed by**: 无（DAG 顶层节点）；被 `phaser.aicomponent` 的 `scene: [Preloader, Game]` 注册
- **Integration point**: `src/game/scenes/Game.ts` → `src/game/index.ts` `scene: [Preloader, Game]` 第二个场景

## Imports

- `phaser.aicomponent`（硬依赖）
- `phaser_scene_lifecycle.aicomponent`（硬依赖）
- `grid_board_layout.aicomponent`（硬依赖）
- `path_elimination_rules.aigameplay`（硬依赖：玩法规则）

## Skill Definition

```yaml
tools:
  - read_file
  - write_file
inputs:
  - source: src/game/scenes/Game.ts
outputs:
  - gameScene: Game class (main Phaser scene coordinator)
```
