text: !function(n){var r={};function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=n,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,n){"use strict";n.r(t);var r=n(1),i=n(3),o=new r.default,s=new i.default;o.events(),s.events()},function(e,t,n){"use strict";n.r(t);var s=n(2);function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function o(e,t,n,r,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),this.buttonRoll=s.elements.buttonRoll,this.buttonHold=s.elements.buttonHold,this.buttonNew=s.elements.buttonNew,this.dice1=s.elements.dice1,this.dice2=s.elements.dice2,this.current0=s.elements.current0,this.current1=s.elements.current1,this.player0Panel=s.elements.player0Panel,this.player1Panel=s.elements.player1Panel,this.score=s.elements.score,this.score0=s.elements.score0,this.score1=s.elements.score1,this.name=s.elements.name,this.name0=s.elements.name0,this.name1=s.elements.name1,this.winner=s.elements.winner,this.changeScoreForm=s.elements.changeScoreForm,this.defaultScore=s.elements.defaultScore,this.currentScore=s.elements.currentScore,this.scores=e,this.roundScore=t,this.input=n,this.activePlayer=r,this.gamePlaying=i,this.initialize,this.events,this.nextPlayer,this.changeScore}var e,t,n;return e=o,(t=[{key:"events",value:function(){var t=this;this.initialize(),this.changeScoreForm.addEventListener("submit",function(e){return t.changeScore(e)}),this.buttonRoll.addEventListener("click",function(){return t.rollDice()}),this.buttonHold.addEventListener("click",function(){return t.holdButton()}),this.buttonNew.addEventListener("click",function(){return t.initialize()})}},{key:"rollDice",value:function(){if(1==this.gamePlaying){var e=Math.floor(6*Math.random())+1,t=Math.floor(6*Math.random())+1;this.dice1.style.display="block",this.dice2.style.display="block",this.dice1.src="assets/images/dice-"+e+".png",this.dice2.src="assets/images/dice-"+t+".png",1!==e&&1!==t?(this.roundScore+=e+t,document.querySelector("#current-"+this.activePlayer).textContent=this.roundScore):(alert("Ooops you rolled two 1"),this.nextPlayer())}}},{key:"holdButton",value:function(){1==this.gamePlaying&&(this.scores[this.activePlayer]+=this.roundScore,""==this.defaultScore.value&&(this.defaultScore.value=100),document.querySelector("#score-"+this.activePlayer).textContent=this.scores[this.activePlayer],this.scores[this.activePlayer]>=this.defaultScore.value?(document.querySelector("#name-"+this.activePlayer).textContent="Winner",this.dice1.style.display="none",this.dice2.style.display="none",document.querySelector(".player__"+this.activePlayer+"-panel").classList.add(this.winner),document.querySelector(".player__"+this.activePlayer+"-panel").classList.remove(this.playerActive),this.gamePlaying=!1):this.nextPlayer())}},{key:"initialize",value:function(){this.scores=[0,0],this.activePlayer=0,this.roundScore=0,this.dice1.style.display="none",this.dice2.style.display="none",this.score0.textContent="0",this.score1.textContent="0",this.current0.textContent="0",this.current1.textContent="0",this.name0.textContent="Player 1",this.name1.textContent="Player 2",this.player0Panel.classList.remove(this.winner),this.player1Panel.classList.remove(this.winner),this.player0Panel.classList.remove("player--active"),this.player0Panel.classList.add("player--active"),this.player1Panel.classList.remove("player--active"),this.gamePlaying=!0}},{key:"nextPlayer",value:function(){0===this.activePlayer?this.activePlayer=1:this.activePlayer=0,this.roundScore=0,this.current0.textContent="0",this.current1.textContent="0",this.player0Panel.classList.toggle("player--active"),this.player1Panel.classList.toggle("player--active"),this.dice1.style.display="none",this.dice2.style.display="none"}},{key:"changeScore",value:function(e){e.preventDefault(),this.currentScore.innerHTML="".concat(this.defaultScore.value)}}])&&r(e.prototype,t),n&&r(e,n),o}();t.default=i},function(e,t,n){"use strict";n.r(t),n.d(t,"elements",function(){return r}),n.d(t,"instructionElements",function(){return i});var r={buttonRoll:document.querySelector(".button--roll"),dice1:document.getElementById("dice-1"),dice2:document.getElementById("dice-2"),buttonHold:document.querySelector(".button--hold"),buttonNew:document.querySelector(".button--new"),current0:document.getElementById("current-0"),current1:document.getElementById("current-1"),player0Panel:document.querySelector(".player__0-panel"),player1Panel:document.querySelector(".player__1-panel"),score0:document.getElementById("score-0"),score1:document.getElementById("score-1"),name0:document.getElementById("name-0"),name1:document.getElementById("name-1"),winner:document.querySelector(".winner"),score:document.querySelector("#score-"),name:document.querySelector("#name-"),changeScoreForm:document.querySelector(".changeScoreForm"),defaultScore:document.getElementById("defaultScore"),currentScore:document.getElementById("currentScore")},i={openInstructionModal:document.querySelector(".open-instruction-modal"),instructionModal:document.querySelector(".instruction-modal"),instructionModalClose:document.querySelector(".instruction-modal__close")}},function(e,t,n){"use strict";n.r(t);var i=n(2);function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var r=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.openInstructionModal=i.instructionElements.openInstructionModal,this.instructionModal=i.instructionElements.instructionModal,this.instructionModalClose=i.instructionElements.instructionModalClose,this.document=document.body,this.events,this.openModal,this.closeModal,this.keyPressHandler}var t,n,r;return t=e,(n=[{key:"events",value:function(){var e=this;this.openInstructionModal.addEventListener("click",function(){return e.openModal()}),this.instructionModalClose.addEventListener("click",function(){return e.closeModal()}),this.document.addEventListener("keydown",function(){return e.keyPressHandler(event)})}},{key:"keyPressHandler",value:function(e){27==e.which&&this.closeModal()}},{key:"openModal",value:function(){return this.instructionModal.classList.add("instruction-modal--is-visible"),!1}},{key:"closeModal",value:function(){this.instructionModal.classList.remove("instruction-modal--is-visible")}}])&&o(t.prototype,n),r&&o(t,r),e}();t.default=r}]);