From 3121f9f60886b291103bfb10b26803196b7e4e6b Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 31 Dec 2022 18:13:35 +0100 Subject: Refactored game creation --- controllers/games/root.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'controllers') diff --git a/controllers/games/root.js b/controllers/games/root.js index 7406815..0483f55 100644 --- a/controllers/games/root.js +++ b/controllers/games/root.js @@ -2,7 +2,7 @@ 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"; +import { emptyBoard, Bag } from "../../utils/board.js"; function makePageData(user) { return { @@ -26,7 +26,7 @@ export function root_get(req, res) { } function makeNewGameData(name, player1, player2) { - let bag = makeLettersBag(); + let bag = new Bag(); return { board: emptyBoard, name: name, @@ -34,13 +34,13 @@ function makeNewGameData(name, player1, player2) { id: player1.id, username: player1.username, score: 0, - letters: pickLetters(bag, 7), + letters: bag.pick(7), }, player2: { id: player2.id, username: player2.username, score: 0, - letters: pickLetters(bag, 7), + letters: bag.pick(7), }, }; } -- cgit v1.2.3