';Dom.add(closebox,box);let msgbox = Dom.make('div');msgbox.innerHTML = s;Dom.add(msgbox,box);let scover = Dom.make('div');scover.id = 'alertboxscreen';scover.style.display='block';scover.style.position='absolute';scover.style.zIndex='98';scover.style.left='0px';scover.style.top='0px';scover.style.width='100%';scover.style.height='100%';scover.style.backgroundColor='rgba(0,0,0,.25)';scover.onclick=removeAlertBox;Dom.add(scover,d.body);let divwidth = box.offsetWidth;let divheight = box.offsetHeight;let topposition = parseInt(((viewheight-divheight)/2)+scrolltop);let leftposition = parseInt(((viewwidth-divwidth)/2)+scrollleft);if(topposition<0) topposition = 0;if(leftposition<0) leftposition = 0;box.style.top = topposition + "px";box.style.left = leftposition + "px";}/*THE GAME */var ssmall = false;var w = d.documentElement.clientWidth || window.innerWidth;ssmall = (w <= 359) ? true : false;var m = ssmall ? 7 : 8;var n = m;var boxes = [], turn = true, you = 0, comp = 0, full = false;var myColor = '#ED3237';var yourColor = '#1E8CE6';function buildBoard(){boxes = [];turn = true;you = 0;comp = 0;$('player2').innerText = 'Tu : ' + you;$('player1').innerText = 'Yo : ' + comp;Dom.empty('gameCont');var dotZindex = (m*n) + 10;var hlineZindex = dotZindex-1;var lineZindex = dotZindex-2;var offset = 40;var sx= sx = window.innerWidth/2 - (m*offset)/2,sy = offset*2.5;var c = 0;for(var j=0; j= 0) var a = addValue(id1);if(id2 >= 0) var b = addValue(id2);this.classList.add('line-active');this.dataset.active = 'true';if(a === false && b === false) {computer();}}};}}function acquire(id){var color, bg;if(turn){color = yourColor;bg = 'userColor';you++;}else {color = myColor;bg = 'compColor';comp++;}$('hitSound').play();d.querySelector('[data-id="'+id+'"]').className = bg;$('player2').innerText = 'Tu : ' + you;$('player1').innerText = 'Yo : ' + comp;full = true;for (var i=0; i 0){rnd = random(0, arr3.length-1);computerSelect(arr3[rnd]);}/*better case*/else if(arr1.length > 0){rnd = random(0, arr1.length-1);computerSelect(arr1[rnd]);}/*normal case, will never enter, only affects first move*/else if(arr0.length > 0){rnd = random(0, arr0.length-1);computerSelect(arr0[rnd]);}/*worst case*/else if(arr2.length > 0){rnd = random(0, arr2.length-1);computerSelect(arr2[rnd]);}$('gameCont').style.cursor = 'auto';}, 300);}function computerSelect(id) {/*console.log("Box " + id);*/var allTags = [];allTags.push.apply(allTags, d.querySelectorAll('[data-line1="'+id+'"]'));allTags.push.apply(allTags, d.querySelectorAll('[data-line2="'+id+'"]'));for (var h=0;h= 0)var a = addValue(id1);if(id2 >= 0)var b = addValue(id2);allTags[h].classList.add('line-active');allTags[h].dataset.active = 'true';if(a === true || b === true){computer();}else {turn = true;$('turn').innerText = 'Tu Turno';$('turn').style.color = yourColor;}}}}}function random(min, max){ return Math.floor(Math.random() * (max - min + 1)) + min;}function endGame(){turn = false;$('intro').play();var winner = you>comp ? 'Tu ganas' : 'Yo gano';var again = '';alertBox(winner + again);}buildBoard();