From 038c877aed55cffdb4401a4c7e7b15b113798145 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 22 Nov 2022 22:55:36 +0100 Subject: Implemented game creation --- controllers/games/root.js | 69 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 8 deletions(-) (limited to 'controllers/games/root.js') diff --git a/controllers/games/root.js b/controllers/games/root.js index ece7b74..7406815 100644 --- a/controllers/games/root.js +++ b/controllers/games/root.js @@ -1,13 +1,66 @@ -import { listGames } from "../../database/games.js"; +import { validationResult } from "express-validator"; + +import { getUserByUsername } from "../../database/users.js"; +import { listGames, newGame } from "../../database/games.js"; +import { emptyBoard, makeLettersBag, pickLetters, } from "../../utils/board.js"; + +function makePageData(user) { + return { + title: "Parties", + user: user, + games: listGames(user.id), + formdata: { + name: "", + username: "", + }, + errors: {}, + }; +} export function root_get(req, res) { - const data = { - title: "Liste des parties", - user: req.session.user, - games: listGames(req.session.user.id), + let page = makePageData(req.session.user); + for (let i=0; i