text: import Phaser from 'phaser';
  import HeroesMenu from '../game_hud_components/heroesMenu';
  import ActionsMenu from '../game_hud_components/actionsMenu';
  import EnemiesMenu from '../game_hud_components/enemiesMenu';
  import Message from '../game_hud_components/message';
  
  class GameUIScene extends Phaser.Scene {
    constructor() {
      super('GameUI');
    }
  
    remapHeroes() {
      const { heroes } = this.battleScene;
      this.heroesMenu.remap(heroes);
    }
  
    remapEnemies() {
      const { enemies } = this.battleScene;
      this.enemiesMenu.remap(enemies);
    }
  
    createMenu() {
      this.remapHeroes();
      this.remapEnemies();
      this.battleScene.nextTurn();
    }
  
    onEnemy(index) {
      this.heroesMenu.deselect();
      this.actionsMenu.deselect();
      this.enemiesMenu.deselect();
      this.currentMenu = null;
      this.battleScene.receivePlayerSelection('attack', index);
    }
  
    onPlayerSelect(id) {
      this.heroesMenu.select(id);
      this.actionsMenu.select(0);
      this.currentMenu = this.actionsMenu;
    }
  
    onSelectEnemies() {
      this.currentMenu = this.enemiesMenu;
      this.enemiesMenu.select(0);
    }
  
    onKeyInput(event) {
      if (this.currentMenu && this.currentMenu.selected) {
        if (event.code === 'ArrowUp') {
          this.currentMenu.moveSelectionUp();
        } else if (event.code === 'ArrowDown') {
          this.currentMenu.moveSelectionDown();
        } else if (event.code === 'ArrowRight' || event.code === 'Shift') {
          // return nothing
        } else if (event.code === 'Space' || event.code === 'ArrowLeft') {
          this.currentMenu.confirm();
        }
      }
    }
  
    create() {
      this.graphics = this.add.graphics();
      this.graphics.lineStyle(1, 0xffffff);
      this.graphics.fillStyle(0x031f4c, 1);
      this.graphics.strokeRect(60, 430, 240, 170);
      this.graphics.fillRect(60, 430, 240, 170);
      this.graphics.strokeRect(320, 430, 240, 170);
      this.graphics.fillRect(320, 430, 240, 170);
      this.graphics.strokeRect(580, 430, 240, 170);
      this.graphics.fillRect(580, 430, 240, 170);
  
      this.menus = this.add.container();
  
      this.heroesMenu = new HeroesMenu(600, 435, this);
      this.actionsMenu = new ActionsMenu(340, 435, this);
      this.enemiesMenu = new EnemiesMenu(80, 435, this);
  
      this.currentMenu = this.actionsMenu;
  
      this.menus.add(this.heroesMenu);
      this.menus.add(this.actionsMenu);
      this.menus.add(this.enemiesMenu);
  
      this.battleScene = this.scene.get('Battle');
  
      this.input.keyboard.on('keydown', this.onKeyInput, this);
  
      this.battleScene.events.on('PlayerSelect', this.onPlayerSelect, this);
  
      this.events.on('SelectEnemies', this.onSelectEnemies, this);
  
      this.events.on('Enemy', this.onEnemy, this);
  
      this.sys.events.on('wake', this.createMenu, this);
  
      this.message = new Message(this, this.battleScene.events);
      this.add.existing(this.message);
  
      this.createMenu();
    }
  }
  
  export default GameUIScene;