summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorJulien Dessaux2022-12-31 18:13:35 +0100
committerJulien Dessaux2022-12-31 18:13:35 +0100
commit3121f9f60886b291103bfb10b26803196b7e4e6b (patch)
tree5cc4f3566b3c4a3c29700fbf861f1a5795985b37 /controllers
parentFixed game creation (diff)
downloadjeux-de-mots-3121f9f60886b291103bfb10b26803196b7e4e6b.tar.gz
jeux-de-mots-3121f9f60886b291103bfb10b26803196b7e4e6b.tar.bz2
jeux-de-mots-3121f9f60886b291103bfb10b26803196b7e4e6b.zip
Refactored game creation
Diffstat (limited to '')
-rw-r--r--controllers/games/root.js8
1 files changed, 4 insertions, 4 deletions
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),
},
};
}