From 1df1ff6f074528a4ad6d4015c794a1555c1c942f Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Mon, 3 Apr 2023 22:12:41 +0200 Subject: Polishing up Add all files to repo Add sql database Correct urls Add PHP code to repo Update README.md with instructions how to start Move from yarn to pnpm Fix all issues with starting Fix possibility of player changing their dice roll with refreshing the game --- backend/ts/api/getCurrentGameState.ts | 2 +- backend/ts/api/login.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'backend/ts/api') diff --git a/backend/ts/api/getCurrentGameState.ts b/backend/ts/api/getCurrentGameState.ts index 896ccb4..4c87d18 100644 --- a/backend/ts/api/getCurrentGameState.ts +++ b/backend/ts/api/getCurrentGameState.ts @@ -12,7 +12,7 @@ export default async function getCurrentGameState(req: Request, res: Response) { = (await makeQuery("SELECT `gameBoard`, `currentPlayer`, `started`, `data`, `timeTillTurnEnd`, `winner`" + " FROM `fia` WHERE `id` = ?", [req.session.gid]))[0]; - + if (dbRes.started === 0) { res.send(JSON.stringify({ data: dbRes.data })); } else { diff --git a/backend/ts/api/login.ts b/backend/ts/api/login.ts index c01ef75..3b001ce 100644 --- a/backend/ts/api/login.ts +++ b/backend/ts/api/login.ts @@ -19,6 +19,7 @@ export default async function apiLogin(req: Request, res: Response) { let dbRes = (await makeQuery("SELECT * FROM `fia` WHERE `started`= 0 LIMIT 1", [])) as Array, row: fiaTable; + if (dbRes[0] === undefined) { let color = Helpers.getRandomInt(0, 4); row = {} as fiaTable; -- cgit v1.3.1