This commit is contained in:
gnieark 2016-06-07 23:22:18 +02:00
parent c7eeb61153
commit efde0e7f08

View File

@ -82,10 +82,10 @@ function playingAT(col){
//find the first line empty
var i=0;
for(i = 0; i < 6 , grid[i][col] !== ""; i++){
for(i = 0; i < 6 , board[i][col] !== ""; i++){
//nothing juste a counter
}
grid[i][col]=symbol;
board[i][col]=symbol;
document.getElementById('td' + col + '_' + i).innerHTML = symbol;
addLog('player ' + currentPlayer + ', symbol ' + symbol + ' played col ' + col);
@ -100,10 +100,10 @@ function playingAT(col){
//horizontaly
var line="";
for (var k=0; k < 7; k++){
if(grid[y][k] == ""){
if(board[y][k] == ""){
line += " ";
}else{
line += grid[y][k];
line += board[y][k];
}
}
if (line.indexOf(searchValue) > -1){
@ -114,10 +114,10 @@ function playingAT(col){
//verticaly
var line="";
for (var k=0; k < 6; k++){
if(grid[k][x] == ""){
if(board[k][x] == ""){
line += " ";
}else{
line += grid[k][x];
line += board[k][x];
}
}
if (line.indexOf(searchValue) > -1){
@ -151,10 +151,10 @@ function playingAT(col){
var line="";
var lx , ly;
for (lx = kx, ly = ky; (lx < 7) && (ly > -1); lx++ , ly-- ){
if( grid[ly][lx] == ""){
if( board[ly][lx] == ""){
line += " ";
}else{
line += grid[ly][lx];
line += board[ly][lx];
}
}
@ -181,10 +181,10 @@ function playingAT(col){
var line="";
var lx , ly;
for (lx = kx , ly = ky ; (lx < 7) && (ly < 6) ; lx++ , ly++){
if( grid[ly][lx] == ""){
if( board[ly][lx] == ""){
line += " ";
}else{
line += grid[ly][lx];
line += board[ly][lx];
}
}
@ -215,7 +215,7 @@ function play(player){
"action" : "play-turn",
"game" : "connectFour",
"players" : 2,
"board" : grid,
"board" : board,
"you" : symbol,
"player-index" : player-1
};
@ -255,8 +255,8 @@ function startGame(){
while (document.getElementById("fightResult").firstChild) {
document.getElementById("fightResult").removeChild(document.getElementById("fightResult").firstChild);
}
//create grid
var table=createElem('table',{'class':'battleGrid', 'id': 'grid'});
//create board
var table=createElem('table',{'class':'battleGrid', 'id': 'board'});
for (var i=6; i > -1; i--){
var tr=createElem('tr');
for (var j=0;j<7; j++){
@ -277,7 +277,7 @@ function startGame(){
newTr.appendChild(newTd);
}
document.getElementById('grid').appendChild(newTr);
document.getElementById('board').appendChild(newTr);
board=[["","","","","","",""],
["","","","","","",""],