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
c2200be9
Commit
c2200be9
authored
Feb 19, 2019
by
Erwan Bousse
Browse files
move-validation: add return types
parent
9b59b967
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/move-validation.ts
View file @
c2200be9
...
...
@@ -2,7 +2,7 @@ import { Chessboard, isEmpty, Square, squareAtPosition } from "./chessboard";
import
{
Move
}
from
"
./movements
"
;
import
{
equals
,
left
,
right
,
bottom
,
top
}
from
"
./position
"
;
export
function
blackPawnMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackPawnMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Manage special 'En passant' move.
if
(
equals
(
move
.
to
!
,
top
(
move
.
from
!
)))
{
...
...
@@ -24,35 +24,35 @@ export function blackPawnMove(board : Chessboard, move : Move) {
}
export
function
blackKingMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackKingMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
blackQueenMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackQueenMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
blackRoockMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackRoockMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
blackBishopMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackBishopMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
blackKnightMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
blackKnightMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
whitePawnMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whitePawnMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Manage special 'En passant' move.
if
(
equals
(
move
.
to
!
,
bottom
(
move
.
from
!
)))
{
if
(
equals
(
move
.
to
!
,
bottom
(
move
.
from
!
)))
{
return
isEmpty
(
board
,
move
.
to
!
);
}
...
...
@@ -68,27 +68,27 @@ export function whitePawnMove(board : Chessboard, move : Move) {
return
false
;
}
export
function
whiteKingMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whiteKingMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
whiteQueenMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whiteQueenMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
whiteRoockMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whiteRoockMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
whiteBishopMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whiteBishopMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
export
function
whiteKnightMove
(
board
:
Chessboard
,
move
:
Move
)
{
export
function
whiteKnightMove
(
board
:
Chessboard
,
move
:
Move
)
:
boolean
{
// #TODO: Implement this function
return
true
;
}
\ No newline at end of file
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