Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Romain DUPONT
Online Chess
Commits
482a5a43
Commit
482a5a43
authored
Feb 19, 2019
by
Gerson Sunyé
Browse files
Invalid movements are now displayed correctly
parent
6d3a4bd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.ts
View file @
482a5a43
...
...
@@ -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
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment