From 5bd7b5ab0dc58ef897d909ea5b8116f4e9ca75c4 Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 5 Apr 2017 23:23:37 +0300 Subject: [PATCH] a few oopsies --- client/index.js | 1 + package.json | 6 +++--- server.js | 8 +++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/index.js b/client/index.js index a7df8c3..069fd3c 100644 --- a/client/index.js +++ b/client/index.js @@ -132,6 +132,7 @@ let column = GameDrawer.gridX - 1 if (GameDrawer.possible(column)) { io.emit('place_at', {column: column, gameId: Connect4.Game.gameId}) + Connect4.Game.myTurn = false } } }, diff --git a/package.json b/package.json index fce2a18..ecda203 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "battleship.js", + "name": "connect_four.js", "version": "0.0.0", - "description": "Battleship game in the browser", + "description": "Connect Four game in the browser", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ - "battleship", + "connectfour", "game", "html5" ], diff --git a/server.js b/server.js index f5cab21..4d325bf 100644 --- a/server.js +++ b/server.js @@ -236,7 +236,6 @@ function detectWin (color, game) { for (let i = 0; i < 4; i++) { let pAt = getPiece(game, parseInt(c) + i, piece.y) if (pAt && pAt.color === color) { - console.log(pAt) matches += 1 } else { matches = 0 @@ -423,7 +422,9 @@ io.on('connection', (socket) => { clients[opponent].socket.emit('place', {column: data.column, color: playerInGame}) game.places[data.column].push({color: playerInGame, y: 8 - game.places[data.column].length}) - console.log(game.places[data.column]) + + clients[me].socket.emit('turn', false) + clients[opponent].socket.emit('turn', true) if (detectWin(playerInGame, game)) { endGame(data.gameId, me, opponent, 1) @@ -434,9 +435,6 @@ io.on('connection', (socket) => { endGame(data.gameId, me, opponent, 2) return } - - clients[me].socket.emit('turn', false) - clients[opponent].socket.emit('turn', true) }) socket.on('disconnect', () => {