'use strict';

/* eslint-disable no-unused-vars */

import MenuController from './menu/control/menu-controller';
import Phaser from 'phaser';

function startGame() {
  console.log('start Game');

  let phaserConfig = {
    type: Phaser.AUTO,
    pixelArt: true,
    scale: {
      mode: Phaser.Scale.RESIZE,
      autoCenter: Phaser.Scale.CENTER_BOTH,
      width: window.innerWidth,
      height: window.innerHeight
    },
    physics: {
      default: 'arcade',
      arcade: {
        debug: true,
        gravity: { y: 250 },
      }
    },
    parent: 'phaser-parent',
    dom: {
      createContainer: true
    }
  };
  let phaserEngine = new Phaser.Game(phaserConfig);
  let menuController = new MenuController(phaserEngine);
  menuController.displayMainMenu();
}

let app = {
  // Application Constructor
  initialize: function () {
    console.log('app initialize');
    document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
  },

  onDeviceReady: function () {
    startGame();
  },

};

console.log('cordova env ? :', process.env.CORDOVA);

if (process.env.CORDOVA && process.env.CORDOVA === true) {

  app.initialize();
} else {
  startGame();
}
