blob: d3363fd2dc31a725f0eb9bdaff3279a7f474f02a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { getGame } from "../../database/games.js";
function makePageData(user, game) {
return {
title: "Jouer",
user: user,
data: game,
};
}
export function gameId_get(req, res) {
const game = JSON.parse(getGame(req.params.gameId).data);
if (game) {
if (game.player1.id === req.session.user.id) {
game.letters = game.player1.letters;
delete game.player2.letters;
} else {
game.letters = game.player2.letters;
delete game.player1.letters;
}
return res.render("game", makePageData(req.session.user, game));
}
return res.redirect("/games");
}
|