import Phaser from 'phaser';
import './style.css';
import { MAP_KEYS } from './game/data';
import { BootScene } from './game/scenes/BootScene';
import { EndingScene } from './game/scenes/EndingScene';
import { TitleScene } from './game/scenes/TitleScene';
import { UIScene } from './game/scenes/UIScene';
import { WorldScene } from './game/scenes/WorldScene';
import { director } from './game/CorruptionDirector';

declare global {
  interface Window { __HONEY_GAME__: Phaser.Game }
}

const game = new Phaser.Game({
  type: Phaser.WEBGL,
  parent: 'game',
  backgroundColor: '#79cce4',
  pixelArt: true,
  roundPixels: true,
  width: 320,
  height: 180,
  scale: {
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    autoRound: true,
    zoom: Phaser.Scale.MAX_ZOOM,
    width: 320,
    height: 180,
  },
  physics: {
    default: 'arcade',
    arcade: { debug: false },
  },
  dom: { createContainer: true },
  render: { antialias: false, pixelArt: true, roundPixels: true },
  scene: [
    BootScene,
    TitleScene,
    ...MAP_KEYS.map((key) => new WorldScene(key)),
    UIScene,
    EndingScene,
  ],
});

game.registry.set('director', director);
window.__HONEY_GAME__ = game;
