From b59efaee5a5bddb3996f77284b32d7c25aa4da7e Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Mon, 23 Jan 2023 16:13:36 -0500 Subject: [PATCH] erm --- src/routes/game/start.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/routes/game/start.js b/src/routes/game/start.js index bd1cabb..f47a63b 100644 --- a/src/routes/game/start.js +++ b/src/routes/game/start.js @@ -3,12 +3,22 @@ const app = express.Router() const GameJob = require("../../lib/classes/GameJob.js") +function getGameById(id) { + let game + + global.games.forEach((value, key) => { + if (value.placeId == id) game = value + }) + + return game +} + app.get("/:id", async (request, response) => { - const game = global.games.get(request.params.token) + const game = global.games.get(getGameById(request.params.id).id) if (game) return response.status(400).json({ error: "Game is running" }) const job = new GameJob() - job.StartGame(request.params.id).catch((_) => _) + const result = await job.StartGame(request.params.id).catch((_) => _) global.games.set(job.id, job) job.proc.once("exit", () => {