'use strict';
import stateMixins from './stateMixins.js';
export default function initState(duelController) {
  stateMixins.call(this);
  let duelCtrl = duelController;
  this.start = (payload = null) => {
    if (payload) {
      duelCtrl.setData({
        bluePlayer: {
          name: payload.player1Name,
          color: 'blue',
          heroesInPile: [],
          twelveHeroes: [],
          instructions: 'Initializing Game...'
        },
        redPlayer: {
          name: payload.player2Name,
          color: 'red',
          heroesInPile: [],
          twelveHeroes: [],
          instructions: 'Initializing Game...'
        },
        game: {
          allHeroes: duelCtrl.getAllHeroes(),
          deckMode: payload.gameOptions.deck,
          advRules: payload.gameOptions.advRules,
          'waitingFor/blue': false,
          'waitingFor/red': false,
          currentPlayer: '',
          'battleTiles/left': [{ id: 0, name: 'mine', redPoints: 3 }],
          updatePlayerState: 'both'
        }
      });
      // Init state just initialize game data, end it
      duelCtrl.endCurrentState();
    }
  };
  this.update = () => { };
  this.end = () => {
    switch (duelCtrl.getGameData().game.deckMode) {
      case 'faction':
        duelCtrl.setCurrentState('1_SELECT_FACTION');
        duelCtrl.startCurrentState();
        break;
      case 'tournament':
        duelCtrl.setCurrentState('1_SELECT_TOURNAMENT');
        duelCtrl.startCurrentState();
        break;

      case 'draft':
        duelCtrl.setCurrentState('1_SELECT_DRAFT');
        duelCtrl.startCurrentState();
        break;

      default:
        break;
    }
  };
}
