'use strict';
import stateMixins from './stateMixins';
export default function changeUpTo3Cards(duelController) {
  stateMixins.call(this);
  let duelCtrl = duelController;
  this.start = () => {
    console.log('Start state 2');
    let gameData = duelCtrl.getGameData();
    console.log('gameData :>> ', gameData);
    duelCtrl.storeData(gameData);
  };

  // Should receive in paylod : {color, faction}
  this.update = (payload = null) => {
    let gameData = duelCtrl.getGameData();
    if (payload) {
      console.log('payload :>> ', payload);

      /**  TODO : process player response */
      gameData.game['waitingFor/' + payload.color] = false;
      duelCtrl.storeData(gameData);
    }

    if (
      gameData.game['waitingFor/blue'] === false &&
      gameData.game['waitingFor/red'] === false
    ) {
      duelCtrl.endCurrentState();
    }
  };

  this.end = () => {
    console.log('Go to next game state : 3...');

    // duelCtrl.setCurrentState('3...');
    // duelCtrl.startCurrentState();
  };
}
