diff --git a/index.js b/index.js index 77fc8e8..1d4080a 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,6 @@ const io = new Server(server); const redis = createClient(); redis.on('error', err => console.log('Redis Client Error', err)); await redis.connect(); -// redis.flushDb(); const GInfo = new bships.GameInfo(redis, io); @@ -325,6 +324,7 @@ io.on('connection', async (socket) => { const playerGame = await GInfo.getPlayerGameData(socket); if (playerGame !== null) { AFKEnd(playerGame.id); + await GInfo.resetTimer(playerGame.id); } }); } diff --git a/utils/battleships.js b/utils/battleships.js index 5f4fbb9..136ca2a 100644 --- a/utils/battleships.js +++ b/utils/battleships.js @@ -217,8 +217,7 @@ export function checkHit(ships, posX, posY) { break; } - let l = !ship.type ? ship.type + 1 : ship.type + 2; - for (let i = 0; i < l; i++) { + for (let i = 0; i <= ship.type; i++) { let x = clamp(ship.posX + multips[0] * i, 0, 9); let y = clamp(ship.posY + multips[1] * i, 0, 9); @@ -265,7 +264,7 @@ export function validateShipPosition(ships, type, posX, posY, rot) { break; } - for (let i = 0; i < ship.type + 1; i++) { + for (let i = 0; i <= ship.type; i++) { boardRender[ship.posX + multips[0] * i][ship.posY + multips[1] * i] = true; } });