import type Phaser from 'phaser'
import { GAME_WIDTH, GAME_HEIGHT } from './constants'

/**
 * 创建 Phaser 游戏配置
 * 注意：此文件只在客户端（动态 import 后）执行，不会在 SSR 中运行
 * @param containerId HTML 容器元素的 id
 */
export function createGameConfig(containerId: string): Phaser.Types.Core.GameConfig {
  return {
    type: (globalThis as typeof globalThis & { Phaser?: { AUTO: number } }).Phaser?.AUTO ?? 0,
    width: GAME_WIDTH,
    height: GAME_HEIGHT,
    parent: containerId,
    backgroundColor: '#0a1628',
    scale: {
      mode: 3,        // Phaser.Scale.FIT = 3
      autoCenter: 1,  // Phaser.Scale.CENTER_BOTH = 1
    },
    scene: [], // 场景在 GamePage 中动态注入
    physics: {
      default: 'arcade',
      arcade: { debug: false },
    },
  }
}
