Commit 482a5a43 authored by Gerson Sunyé's avatar Gerson Sunyé
Browse files

Invalid movements are now displayed correctly

parent 6d3a4bd9
......@@ -19,6 +19,7 @@ class HttpServer {
public onStart(): void {
let chessboard: Chessboard = createInitialChessboard();
let app: express.Application = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(PUBLIC_DIR));
......@@ -29,7 +30,7 @@ class HttpServer {
});
app.get('/', (req: express.Request, res: express.Response) => {
res.render('index', {error: "Erreur"});
res.render('index', {error: null});
})
app.get("/status.js", (req: express.Request, res: express.Response) => {
......@@ -38,9 +39,9 @@ class HttpServer {
app.post("/", (req: express.Request, res: express.Response) => {
let unparsedMove: string = req.body.move;
chessboard = processMove(chessboard, unparsedMove);
//res.redirect("/");
res.render('index', {error: null});
let didPerfom: boolean = processMove(chessboard, unparsedMove);
let message: string = didPerfom ? "" : "Invalid movement!"
res.render('index', {error: message});
});
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment