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 { ...@@ -19,6 +19,7 @@ class HttpServer {
public onStart(): void { public onStart(): void {
let chessboard: Chessboard = createInitialChessboard(); let chessboard: Chessboard = createInitialChessboard();
let app: express.Application = express(); let app: express.Application = express();
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(PUBLIC_DIR)); app.use(express.static(PUBLIC_DIR));
...@@ -29,7 +30,7 @@ class HttpServer { ...@@ -29,7 +30,7 @@ class HttpServer {
}); });
app.get('/', (req: express.Request, res: express.Response) => { 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) => { app.get("/status.js", (req: express.Request, res: express.Response) => {
...@@ -38,9 +39,9 @@ class HttpServer { ...@@ -38,9 +39,9 @@ class HttpServer {
app.post("/", (req: express.Request, res: express.Response) => { app.post("/", (req: express.Request, res: express.Response) => {
let unparsedMove: string = req.body.move; let unparsedMove: string = req.body.move;
chessboard = processMove(chessboard, unparsedMove); let didPerfom: boolean = processMove(chessboard, unparsedMove);
//res.redirect("/"); let message: string = didPerfom ? "" : "Invalid movement!"
res.render('index', {error: null}); 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