From 4e2fd7072deac2a84d8c1512c4a79c0edbff369a Mon Sep 17 00:00:00 2001 From: Alec Maier Date: Wed, 4 Sep 2019 20:46:29 -0400 Subject: [PATCH] Changed cron job to clear games based on start time, tried to fix card transparency bug on iphones --- server.js | 5 +++-- static/styles.css | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 3d7444f..2ab468e 100644 --- a/server.js +++ b/server.js @@ -16,10 +16,10 @@ const CronJob = require('cron').CronJob; var activeGames = {}; // cron job for periodically clearing finished games -const job = new CronJob('0 0 */2 * * *', function() { +const job = new CronJob('0 0 */1 * * *', function() { console.log(activeGames); for (const key in activeGames) { - if (activeGames.hasOwnProperty(key) && activeGames[key].state === "ended") { + if (activeGames.hasOwnProperty(key) && (Math.abs((new Date()) - (new Date(activeGames[key].startTime))) / 36e5) >= 2) { delete activeGames[key]; } } @@ -89,6 +89,7 @@ function teamWon(game) { io.on('connection', function(socket) { socket.on('newGame', function(game, onSuccess) { activeGames[game.accessCode] = game; + activeGames[game.accessCode].startTime = (new Date()).toJSON(); console.log("Game created at " + (new Date().toDateString()) + " " + (new Date()).toTimeString()); onSuccess(); }); diff --git a/static/styles.css b/static/styles.css index 13948d4..5de511b 100644 --- a/static/styles.css +++ b/static/styles.css @@ -494,7 +494,7 @@ label { #game-card { - background-color: #f0f0f0; + background-color: transparent; display: flex; flex-direction: column; cursor: pointer;