This commit is contained in:
I-Have-An-Issue 2023-01-23 16:13:36 -05:00
parent 9cb8bd7b70
commit b59efaee5a
No known key found for this signature in database
GPG Key ID: E55435DEA0825091
1 changed files with 12 additions and 2 deletions

View File

@ -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", () => {