';document.write(s);my.clrs=[["Blue",'#0000FF'],["Orange",'#FFA500'],["Slate Blue",'#6A5ACD'],["Green",'#00cc00'],["Lime",'#00FF00'],["Teal",'#008080'],["Gold",'#ffd700'],["Med Purple",'#aa00aa'],["Navy",'#000080'],["Purple",'#800080'],["Dark SeaGreen",'#8FBC8F']];my.clrNum=0;document.getElementById("bdSzs").selectedIndex=optGet('bdSzN')
document.getElementById("modes").selectedIndex=optGet('modeN')
gameNew()}
function gameNew(){let myNode=document.getElementById("board");while(myNode.firstChild){myNode.removeChild(myNode.firstChild);}
my.qTiles=[]
for(let i=0;i{if(tile.xn>0&&tile.yn>0&&tile.xn{if(tile.emptyQ){let nbors=nborsGet(tile)
if(nbors.length>0){let val=nborsCalc(nbors)
queue.push(val)}}})
console.log('queue',queue)
return queue}
function nborsCalc(nbors){switch(my.mode.op){case 'add':let sum=nbors.reduce((tot,nbor)=>{return nbor.emptyQ?tot:tot+nbor.val},0)
return unitsGet(sum)
break
case 'mult':let prod=nbors.reduce((tot,nbor)=>{return nbor.emptyQ?tot:tot*nbor.val},1)
return unitsGet(prod)
break
default:return 0}}
function queueFill(){console.log('queueMake')
let queue=queueVals()
shuffleArray(queue)
for(let i=0;i{if(i{if(!nbor.emptyQ)emptyN++;nbor.empty();})
let score=my.scoreMults[emptyN]
me.wow(score)
my.score+=score
document.getElementById('score').innerHTML=my.score
let count=my.tiles.reduce((tot,tile)=>{return tot+(tile.emptyQ?0:1)},0)
console.log('left to do: ',count)
if(count<=0){success()
return}}else{soundPlay('sndDrop')}
if(my.moveN<=0){movesDone()
return}
queueShift()}
function bdFull(){my.activeQ=false
console.log('board full')
soundPlay('sndDraw')
document.getElementById('optMsg').innerHTML='End of Game: Board is Full!'
optPop()}
function movesDone(){my.activeQ=false
console.log('moves over')
soundPlay('sndDraw')
let s=''
s+="Game Over"
s+=' '
s+='
'
s+="Your score is "+my.score+''
s+='
'
s+=' '
s+="New Game?"
document.getElementById('optMsg').innerHTML=s
optPop()}
function success(){my.activeQ=false
console.log('success')
my.tiles.map(tile=>{tile.empty()})
soundPlay('sndWin')
let s=''
s+="Well done, you cleared the board!"
s+=' '
s+="Bonus 20"
my.score+=20
document.getElementById('score').innerHTML=my.score
s+=' '
s+='
'
s+="Your score is "+my.score+''
s+='
'
s+=' '
s+="New Game?"
document.getElementById('optMsg').innerHTML=s
optPop()}
function unitsGet(num){return num%10}
function nborsGet(tile){let nbors=[]
let xn=tile.xn
let yn=tile.yn
let rels=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1],]
rels.map(rel=>{let xrel=xn+rel[0]
if(xrel>=0&&xrel=0&&yrel';s+=prompt;for(let i=0;i';s+='';}
s+='';return s;}
let seed=+new Date();function random(){let x=Math.sin(seed++)*10000;return x-Math.floor(x);}
function getRandomArbitrary(min,max){return Math.random()*(max-min)+min;}
function getRandomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min;}
function optPopHTML(){let s='';s+='
';return s;}
function optPop(){let pop=document.getElementById('optpop');pop.style.transitionDuration="0.3s";pop.style.opacity=1;pop.style.zIndex=12;pop.style.left=(w-400)/2+'px';}
function optYes(){let pop=document.getElementById('optpop');pop.style.opacity=0;pop.style.zIndex=1;pop.style.left='-999px';gameNew()}
function optNo(){let pop=document.getElementById('optpop');pop.style.opacity=0;pop.style.zIndex=1;pop.style.left='-999px';}
function optGet(name){var val=localStorage.getItem(`MathErase.${name}`)
if(val==null)val=my.opts[name]
return val}
function optSet(name,val){localStorage.setItem(`MathErase.${name}`,val)
my.opts[name]=val}
function getDropdownHTML(opts,funcName,id,chkNo){let s='';s+='';return s;}
function soundBtnHTML(){let onClr='blue'
let offClr='#bbb'
let s=''
s+=''
s+='