added draw
This commit is contained in:
parent
f07bceb019
commit
e6e8aac616
1 changed files with 14 additions and 1 deletions
|
@ -56,7 +56,9 @@ function move(player_id, args) {
|
|||
GGS.sendCommand(p1_id, "loser", "You lose!");
|
||||
GGS.sendCommand(p2_id, "winner", "You win!");
|
||||
}
|
||||
}
|
||||
} else if(allFieldsFull(gameBoard)) {
|
||||
GGS.sendCommandToAll("draw", "It was a dwaw!");
|
||||
}allFieldsFull(gameBoard)
|
||||
|
||||
if (nextPlayer == 1) {
|
||||
GGS.localStorage.setItem("next_player", 2);
|
||||
|
@ -121,6 +123,17 @@ function checkIfWon(gameBoard) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function allFieldsFull(gameBoard) {
|
||||
for (var i=0; i < ROWS; i++) {
|
||||
for(var j=0; j < ROWS; j++) {
|
||||
if (gameBoard[i][j] == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function newGame() {
|
||||
// Initiate game with empty rows and columns
|
||||
var gameBoard = [];
|
||||
|
|
Reference in a new issue