0-initState.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. import stateMixins from './stateMixins';
  3. export default function initState(duelController) {
  4. stateMixins.call(this);
  5. let duelCtrl = duelController;
  6. this.start = (payload = null) => {
  7. if (payload) {
  8. duelCtrl.setData({
  9. bluePlayer: {
  10. name: payload.player1Name,
  11. color: 'blue',
  12. twelveHeroes: []
  13. },
  14. redPlayer: {
  15. name: payload.player2Name,
  16. color: 'red',
  17. twelveHeroes: []
  18. },
  19. game: {
  20. allHeroes: duelCtrl.getAllHeroes(),
  21. deckMode: payload.gameOptions.deck,
  22. advRules: payload.gameOptions.advRules,
  23. 'waitingFor/blue': false,
  24. 'waitingFor/red': false,
  25. currentPlayer: '',
  26. 'battleTiles/left': [{ id: 0, name: 'mine', redPoints: 3 }]
  27. }
  28. });
  29. // Init state just initialize game data, end it
  30. duelCtrl.endCurrentState();
  31. }
  32. };
  33. this.update = () => {};
  34. this.end = () => {
  35. switch (duelCtrl.getGameData().game.deckMode) {
  36. case 'faction':
  37. duelCtrl.setCurrentState('1_SELECT_FACTION');
  38. duelCtrl.startCurrentState();
  39. break;
  40. case 'tournament':
  41. duelCtrl.setCurrentState('1_SELECT_TOURNAMENT');
  42. duelCtrl.startCurrentState();
  43. break;
  44. case 'draft':
  45. duelCtrl.setCurrentState('1_SELECT_DRAFT');
  46. duelCtrl.startCurrentState();
  47. break;
  48. default:
  49. break;
  50. }
  51. };
  52. }