{"size": 15354, "ext": "js", "max_stars_repo_path": "build/js/scripts.min.js", "max_stars_repo_name": "Borrouz/JavaScript_GameProject", "max_stars_repo_stars_event_min_datetime": "2019-04-04T14:37:23.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-09T15:51:26.000Z", "max_issues_repo_path": "build/js/scripts.min.js", "max_issues_repo_name": "ospkiev/JavaScript_GameProject", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "build/js/scripts.min.js", "max_forks_repo_name": "ospkiev/JavaScript_GameProject", "max_forks_repo_forks_event_min_datetime": "2018-12-07T11:14:23.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-02T12:51:23.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 5, "avg_line_length": 15354.0, "max_line_length": 15354, "alphanum_fraction": 0.7801875733}
"use strict";function move(e){moveCharacter((compHero.getBoundingClientRect().left-userHero.getBoundingClientRect().right)/2+40,userHero,globalObj.userCharacter,"left",e)}function compMove(e){moveCharacter((compHero.getBoundingClientRect().left-userHero.getBoundingClientRect().right)/2+40,compHero,globalObj.compCharacter,"right",e)}function moveCharacter(e,t,a,o,l){t.style[o]=e+"px",t.style.backgroundImage="url(./img/hero/"+a+"/user-"+a+"_run.gif)",t.style.width="20vh",t.style.height="20vh",t.style.marginTop="2vh",setTimeout(function(){console.log("attack USER",l),t.style.backgroundImage="url("+l+")",t.style.width="20vh",t.style.height="20vh",t.style.marginTop="2vh",kickFunction()},1e3),setTimeout(function(){t.style.backgroundImage="url(./img/hero/"+a+"/user-"+a+"_run.gif)",t.style.transform="left"===o?"scaleX(-1)":"scaleX(1)",t.style.width="20vh",t.style.height="20vh",t.style.marginTop="2vh",t.style[o]="0"},2e3),setTimeout(function(){t.style.backgroundImage="url(./img/hero/user-"+a+".gif)",t.style.transform="left"===o?"scaleX(1)":"scaleX(-1)",t.style.width="24vh",t.style.height="24vh",t.style.marginTop="0vh"},3e3)}var btn=document.querySelector("#submit");function pcAction(){var e=Math.floor(11*Math.random()+10),t=Math.floor(16*Math.random()+5),a=Math.floor(13*Math.random()+8),o=["head","body","legs"],l=o[Math.floor(Math.random()*o.length)];globalObj.computer.atack=l;var r=["head","body","legs"],n=r[Math.floor(Math.random()*r.length)];globalObj.computer.defence=n,"head"===globalObj.computer.atack?globalObj.computer.damage=e:"body"===globalObj.computer.atack?globalObj.computer.damage=t:"legs"===globalObj.computer.atack&&(globalObj.computer.damage=a)}btn=document.querySelector("#submit");var consoleDiv=document.querySelector(".console-log");function describeFight(){var e=null,t=null,a=null,o=null,l=void 0,r=void 0;l=0===globalObj.computer.damage?"Урон заблокирован.":" Полученный урон составляет: "+globalObj.computer.damage,r=0===globalObj.user.damage?"Урон заблокирован.":"Полученный урон составляет: "+globalObj.user.damage,e="head"===globalObj.user.atack?"атаковал голову,":"body"===globalObj.user.atack?"атаковал живот,":"legs"===globalObj.user.atack?"атаковал ноги,":"не атаковал",t="head"===globalObj.user.defence?"защитил голову":"body"===globalObj.user.defence?"защитил живот":"legs"===globalObj.user.defence?"защитил ноги":"и пропустил удар",a="head"===globalObj.computer.atack?"атаковал голову,":"body"===globalObj.computer.atack?"атаковал живот,":"legs"===globalObj.computer.atack?"атаковал ноги,":"не атаковал",o="head"===globalObj.computer.defence?"защитил голову":"body"===globalObj.computer.defence?"защитил живот":"legs"===globalObj.computer.defence?"защитил ноги":"и пропустил удар";var n=document.createElement("div");n.classList.add("console_pDiv-style");var c=document.createElement("p");c.classList.add("console_pRound-style"),c.textContent="Round: "+(globalObj.round-1);var i=document.createElement("p");i.classList.add("console_pUser-style"),i.textContent=globalObj.userName+" "+e+" "+t+". "+l;var u=document.createElement("p");u.classList.add("console_pComp-style"),u.textContent="Соперник "+a+" "+o+". "+r;var s=document.createElement("p");s.classList.add("console_pImg-style"),s.textContent="***",n.prepend(c,i,u,s),consoleDiv.prepend(n)}var modal=document.querySelector(".fw-js-modal-backdrop"),title=document.querySelector(".fw-modal-title"),content=document.querySelector(".fw-modal-content"),modalClose=document.querySelector(".fw-btn");function won(e){1===e?(title.textContent="YOU WON!",content.style.backgroundImage="url('./img/won.gif')",mwin()):2===e?(title.textContent="YOU LOST",content.style.backgroundImage="url('./img/lose.gif')",mLoose()):3===e&&(title.textContent="DRAW",content.style.backgroundImage="url('./img/lose.gif')",drawFunction())}function showFinalWindow(){modal.classList.toggle("fw-modal-hidden")}function winOrLose(){clearInterval(globalObj.intervalTimer),parseInt(globalObj.lifeUser)<=0&&parseInt(globalObj.lifeComputer)<=0?(showFinalWindow(),won(3)):parseInt(globalObj.lifeUser)<=0?(showFinalWindow(),won(2)):parseInt(globalObj.lifeComputer)<=0&&(showFinalWindow(),won(1))}function activeTwoPageAndHideTreePage(){main.classList.add("hide"),secondPageWrap.classList.remove("hide"),modal.classList.toggle("fw-modal-hidden"),globalObj={lifeUser:100,lifeComputer:100,round:1,intervalTimer:null,userName:globalObj.userName,user:{atack:null,defence:null,damage:null},computer:{atack:null,defence:null,damage:null},userHero:null,compHero:null,arena:null},consoleDiv.innerHTML='<h1 class="makeAChoise"> Make a choise! </h1>',healthRefresh(),form.reset(),displayRound.textContent="ROUND "+globalObj.round,removeOrangeBorderPageTwo(),music.play()}modalClose.addEventListener("click",activeTwoPageAndHideTreePage);var globalObj={lifeUser:100,lifeComputer:100,round:1,userName:null,intervalTimer:null,user:{atack:null,defence:null,damage:null},computer:{atack:null,defence:null,damage:null},userHero:null,compHero:null,arena:null,userCharacter:null,compCharacter:null},firstPageInput=document.querySelector("#firstPage-input"),firstPageButtonStart=document.querySelector("#firstPage-buttonStart"),firstPage=document.querySelector(".firstPage"),secondPageWrap=document.querySelector(".secondPage-wrap"),formStart=document.querySelector(".firstPage-form"),main=document.querySelector(".main"),choiceHero=document.querySelector(".secondPage-hero"),choiceArena=document.querySelector(".secondPage-field"),secondPageLink=document.querySelector(".secondPage-link"),sectionFight=document.querySelector(".section-fight"),userHero=document.querySelector(".userHero"),compHero=document.querySelector(".compHero");function activeStart(){firstPageInput.value.length>0&&(firstPageButtonStart.style.color="orangered",firstPageButtonStart.disabled=!1)}function activePage(e){e.preventDefault(),firstPage.classList.add("hide"),secondPageWrap.classList.remove("hide"),globalObj.userName=firstPageInput.value,formStart.reset()}firstPageInput.addEventListener("input",activeStart),firstPageButtonStart.disabled=!0,formStart.addEventListener("submit",activePage);var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var healthValueP=document.querySelector("#valueP"),healthValueC=document.querySelector("#valueC"),Health=function(){function e(t,a){_classCallCheck(this,e),this.healthValue=t,this.health=a}return _createClass(e,[{key:"addDamage",value:function(e){this.health=e,this.health<=0&&(this.health=0),this.pain(this.health),this.changeColor(this.health)}},{key:"pain",value:function(e){this.healthValue.style.width=e+"%"}},{key:"changeColor",value:function(e){var t=this;e>=60?setTimeout(function(){t.healthValue.style.backgroundImage="linear-gradient(to top, #ffffff 0%, #00db00 25%, #00db00 50%, #00db00 75%, #ffffff 100% )"},1500):e>25&&e<60?setTimeout(function(){t.healthValue.style.backgroundImage="linear-gradient(to top, #ffffff 0%, #FF6800 25%, #FF6800 50%, #FF6800 75%, #ffffff 100% "},1500):setTimeout(function(){t.healthValue.style.backgroundImage="linear-gradient(to top, #ffffff 0%, #F80000 25%, #F80000 50%, #F80000 75%, #ffffff 100% "},1500)}}]),e}(),playerHealth=new Health(healthValueP,globalObj.lifeUser),compHealth=new Health(healthValueC,globalObj.lifeComputer);function healthRefresh(){playerHealth.pain(100),playerHealth.changeColor(100),compHealth.pain(100),compHealth.changeColor(100)}var music=document.querySelector("#play"),mstart=document.querySelector("#music_start"),fight=document.querySelector("#figth-sound"),mwinner=document.querySelector("#winner"),mlooser=document.querySelector("#looser"),soundOn=document.querySelector("#soundOn"),kick=document.querySelector("#kick"),draw=document.querySelector("#draw");function kickFunction(){kick.play()}function audio(){music.play()}function fightStart(){music.pause(),fight.play()}function mwin(){fight.pause(),mwinner.play()}function mLoose(){fight.pause(),mlooser.play()}function drawFunction(){fight.pause(),draw.play()}firstPageButtonStart.addEventListener("click",audio),secondPageLink.addEventListener("click",fightStart);var heroActive=!1,fieldActive=!1,hero=document.querySelectorAll(".hero"),heroWrapper=document.querySelector(".secondPage-hero");function activeHero(e){hero.forEach(function(t){return t===e.target&&(heroActive=!0),!0===heroActive&&!0===fieldActive&&(secondPageLink.style.color="orangered"),t===e.target?t.classList.add("active"):t.classList.remove("active")})}heroWrapper.addEventListener("click",activeHero);var field=document.querySelectorAll(".field"),fieldWrapper=document.querySelector(".secondPage-field");function activeField(e){field.forEach(function(t){return t===e.target&&(fieldActive=!0),!0===heroActive&&!0===fieldActive&&(secondPageLink.style.color="orangered"),t===e.target?t.classList.add("active"):t.classList.remove("active")})}function activePage3(){if(globalObj.arena&&globalObj.userHero){secondPageWrap.classList.add("hide"),main.classList.remove("hide");var e=[{img:"./img/hero/user-colossus.gif",character:"colossus"},{img:"./img/hero/user-mystique.gif",character:"mystique"},{img:"./img/hero/user-redskull.gif",character:"redskull"},{img:"./img/hero/user-starlord.gif",character:"starlord"}],t=Math.floor(Math.random()*e.length);globalObj.compHero=e[t].img,globalObj.compCharacter=e[t].character,sectionFight.style.backgroundImage="url("+globalObj.arena+")",timer(),userHero.style.backgroundImage="url("+globalObj.userHero+")",compHero.style.backgroundImage="url("+globalObj.compHero+")",document.querySelector(".name").textContent=globalObj.userName}else alert("Select hero and arena both")}function selectHero(e){globalObj.userHero=e.target.dataset.url,globalObj.userCharacter=e.target.dataset.character,console.log(globalObj)}function selectArena(e){globalObj.arena=e.target.dataset.url,console.log(globalObj)}function removeOrangeBorderPageTwo(){heroActive=!1,fieldActive=!1,removeOrange()}function removeOrange(){hero.forEach(function(e){return e.classList.remove("active")}),field.forEach(function(e){return e.classList.remove("active")})}fieldWrapper.addEventListener("click",activeField),secondPageLink.addEventListener("click",activePage3),choiceHero.addEventListener("click",selectHero),choiceArena.addEventListener("click",selectArena);var progressBar=document.querySelector(".progrLine-progress"),pointer=document.getElementById("e-pointer"),displayOutput=document.querySelector(".display-remain-time"),displayRound=document.querySelector(".roundName"),startTimer=document.querySelector(".startTimer"),round=1,length=2*Math.PI*100;progressBar.style.strokeDasharray=length;var intervalTimer=void 0,timeLeft=void 0,timeDuration=11;function update(e,t){var a=-length*e/t;progressBar.style.strokeDashoffset=a,pointer.style.transform="rotate("+360*e/t+"deg)"}function timer(){displayRound.textContent="ROUND "+globalObj.round,globalObj.round++,but.disabled=!1,but.style.opacity=1,displayOutput.style.color="white";var e=Date.now()+1e3*timeDuration;displayRound.classList.add("bounceIn"),displayOutput.classList.remove("shake"),globalObj.intervalTimer=setInterval(function(){(timeLeft=Math.round((e-Date.now())/1e3))<=0?(clearInterval(globalObj.intervalTimer),displayOutput.style.color="white",timerEnd()):timeLeft<=5&&timeLeft>0&&(displayOutput.style.color="red",displayRound.classList.remove("bounceIn"),displayOutput.classList.add("shake")),displayTimeLeft(timeLeft)},1e3)}function displayTimeLeft(e){var t=e%60;displayOutput.textContent="00:"+(t<10?"0":"")+t,update(e,timeDuration)}update(timeDuration,timeDuration);var form=document.querySelector("#attack-defense"),but=document.querySelector("#submit"),damage=void 0;function atack(e){var t=document.querySelector('[name="defense"]:checked'),a=document.querySelector('[name="attack"]:checked');e.preventDefault(),globalObj.user.atack=a.value,globalObj.user.defence=t.value;var o=Math.floor(11*Math.random()+10),l=Math.floor(16*Math.random()+5),r=Math.floor(13*Math.random()+8);"head"===globalObj.user.atack?globalObj.user.damage=o:"body"===globalObj.user.atack?globalObj.user.damage=l:"legs"===globalObj.user.atack&&(globalObj.user.damage=r)}function userCompair(){return"head"===globalObj.user.atack&&"head"!==globalObj.computer.defence?(globalObj.lifeComputer-=globalObj.user.damage,move("./img/hero/"+globalObj.userCharacter+"/user-"+globalObj.userCharacter+"_jump.gif")):"body"===globalObj.user.atack&&"body"!==globalObj.computer.defence?(globalObj.lifeComputer-=globalObj.user.damage,move("./img/hero/"+globalObj.userCharacter+"/user-"+globalObj.userCharacter+"_attack.gif")):"legs"===globalObj.user.atack&&"legs"!==globalObj.computer.defence?(globalObj.lifeComputer-=globalObj.user.damage,move("./img/hero/"+globalObj.userCharacter+"/user-"+globalObj.userCharacter+"_attack2.gif")):(globalObj.user.damage=0,globalObj.lifeComputer-=0,compMove("./img/hero/"+globalObj.compCharacter+"/user-"+globalObj.compCharacter+"_block.gif"),move("./img/hero/"+globalObj.userCharacter+"/user-"+globalObj.userCharacter+"_attack.gif"),console.log("Comp")),"head"===globalObj.computer.atack&&"head"!==globalObj.user.defence?(globalObj.lifeUser-=globalObj.computer.damage,compMove("./img/hero/"+globalObj.compCharacter+"/user-"+globalObj.compCharacter+"_jump.gif")):"body"===globalObj.computer.atack&&"body"!==globalObj.user.defence?(globalObj.lifeUser-=globalObj.computer.damage,compMove("./img/hero/"+globalObj.compCharacter+"/user-"+globalObj.compCharacter+"_attack.gif")):"legs"===globalObj.computer.atack&&"legs"!==globalObj.user.defence?(globalObj.lifeUser-=globalObj.computer.damage,compMove("./img/hero/"+globalObj.compCharacter+"/user-"+globalObj.compCharacter+"_attack2.gif")):(globalObj.computer.damage=0,globalObj.lifeUser-=0,move("./img/hero/"+globalObj.userCharacter+"/user-"+globalObj.userCharacter+"_block.gif"),compMove("./img/hero/"+globalObj.compCharacter+"/user-"+globalObj.compCharacter+"_attack.gif"),console.log("User")),console.log(globalObj),globalObj}function makeaChoise(e){e.preventDefault();var t=document.querySelector('[name="defense"]:checked'),a=document.querySelector('[name="attack"]:checked');t&&a?letHit(e):addTextToConsole()}function letHit(e){e.preventDefault(),atack(e),pcAction(),userCompair(),describeFight(),playerHealth.addDamage(globalObj.lifeUser),compHealth.addDamage(globalObj.lifeComputer),globalObj.lifeUser>0&&globalObj.lifeComputer>0?timerStop():setTimeout(winOrLose,1500),form.reset(),globalObj.user.atack=null,globalObj.user.defence=null}function addTextToConsole(){var e=document.createElement("h2");e.textContent="Make a choise!",e.classList.add("makeAChoise"),consoleDiv.prepend(e)}function timerStop(){but.disabled=!0,but.style.opacity=.2,clearInterval(globalObj.intervalTimer),setTimeout(timer,3e3)}function timerEnd(){globalObj.computer.damage=0,globalObj.user.atack=0,globalObj.user.defence=0,pcAction(),userCompair(),describeFight(),playerHealth.addDamage(globalObj.lifeUser),compHealth.addDamage(globalObj.lifeComputer),globalObj.lifeUser>0&&globalObj.lifeComputer>0?timerStop():winOrLose()}but.addEventListener("click",makeaChoise);