diff options
author | Your Name <[email protected]> | 2022-04-29 18:11:05 -0500 |
---|---|---|
committer | Your Name <[email protected]> | 2022-04-29 18:11:05 -0500 |
commit | f170801d9377e560d75ce65b08188fa3948640c8 (patch) | |
tree | 1d4f596a84ceba2409e2c3eefe9d48c917e18357 | |
parent | 5b4c10e57049ae106d3e79262d1b000499c9c72f (diff) |
Update index.html
-rw-r--r-- | index.html | 40 |
1 files changed, 23 insertions, 17 deletions
@@ -99,7 +99,7 @@ body::-webkit-scrollbar { //board var boardMain = [ - ['',{'piece':'bridger','icon':'br+','loc':{'z':0}},{'piece':'rook','icon':'r','loc':{'z':0}},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}], + ['',{},{},{},{'piece':'bridger','icon':'br+','loc':{'z':0}},{},{},{'piece':'bridger','icon':'br+','loc':{'z':0}},{},{},{},{},{},{},{},{},{},{},{},{},{}], [{},{},{},{},{},{},{},{},{}], [{},{},{},{},{},{},{},{},{}], [{},{},{},{},{},{},{},{},{}], @@ -153,36 +153,42 @@ body::-webkit-scrollbar { function deltemp(){ for(let x in boardMain){ for(let y in boardMain[x]){ - if(boardMain[x][y].type=='temp'){ - console.log(boardMain[x][y]) + + if(boardMain[x][y]!=null&&boardMain[x][y].type=='temp'){ + //console.log('deleted') + //console.log(boardMain[x][y]) boardMain[x][y]='' + console.log('del') } } } - loadb() + //loadb() } //del temp //move function move(fromR,fromC,toR,toC,z,toz){ - + console.log('move') if(z==1){ //boardOver } else if(z==-1) { //boardUnder } else { - console.log(boardMain[toR][toC]) - console.log(boardMain[fromR][fromC]) + if(Object.keys(boardMain[fromR][fromC]).length!=0){ + boardMain[toR][toC]=boardMain[fromR][fromC] - deltemp() + //deltemp() boardMain[fromR][fromC]={} - + deltemp() loadb() + //del temp + } } + } //move @@ -197,7 +203,7 @@ body::-webkit-scrollbar { } let elem = document.getElementById(row+''+col) - elem.addEventListener('click', function(){ loadb();deltemp() } ) + elem.addEventListener('click', function(){ deltemp();loadb(); } ) let piece = board[row][col] switch(piece.piece){ @@ -351,25 +357,25 @@ lengths.indexOf(Math.max(...lengths)); if(JSON.stringify(board[r][c])==JSON.stringify({})) { if(primary){ - bod+=('<td id="'+r+c+'" style="user-select: none;height: 50px;width: 50px;background-color: '+board1+';"></td>') + bod+=('<td id="'+r+""+c+'" style="user-select: none;height: 50px;width: 50px;background-color: '+board1+';"></td>') }else{ - bod+=('<td id="'+r+c+'" style="user-select: none;height: 50px;width: 50px;background-color: '+board2+';"></td>') + bod+=('<td id="'+r+""+c+'" style="user-select: none;height: 50px;width: 50px;background-color: '+board2+';"></td>') } } else if(board[r][c]==''){ - bod+=('<td id="'+r+c+'" style="opacity:0;user-select: none;height: 50px;width: 50px;"></td>') + bod+=('<td id="'+r+""+c+'" style="opacity:0;user-select: none;height: 50px;width: 50px;"></td>') }else if(board[r][c].type=='temp'){ if(board[r][c].life==0){ - bod+=('<td id="'+r+c+'" style="opacity:0;user-select: none;height: 50px;width: 50px;"></td>') + bod+=('<td id="'+r+""+c+'" style="opacity:0;user-select: none;height: 50px;width: 50px;"></td>') board[r][c]='' } else { board[r][c].life-=1 - bod+=('<td id="'+r+c+'" style="user-select: none;height: 50px;width: 50px;background-color:red;"></td>') + bod+=('<td id="'+r+""+c+'" style="user-select: none;height: 50px;width: 50px;background-color:red;"></td>') } }else{ if(primary){ - bod+=('<td onclick="showmoves('+r+','+c+','+board[r][c].loc.z+')" id="'+r+c+'"style="user-select: none;height: 50px;width: 50px;color:white;background-color: '+board1+';">'+board[r][c].icon+'</td>') + bod+=('<td onclick="showmoves('+r+','+c+','+board[r][c].loc.z+')" id="'+r+""+c+'"style="user-select: none;height: 50px;width: 50px;color:white;background-color: '+board1+';">'+board[r][c].icon+'</td>') }else{ - bod+=('<td onclick="showmoves('+r+','+c+','+board[r][c].loc.z+')" id="'+r+c+'" style="user-select: none;height: 50px;width: 50px;color:white;background-color: '+board2+';">'+board[r][c].icon+'</td>') + bod+=('<td onclick="showmoves('+r+','+c+','+board[r][c].loc.z+')" id="'+r+""+c+'" style="user-select: none;height: 50px;width: 50px;color:white;background-color: '+board2+';">'+board[r][c].icon+'</td>') } } //primary=!primary |