Skip to content

Commit a8a5b83

Browse files
chore(add return types to improve code clarity) : DONE
1 parent bfd9bf4 commit a8a5b83

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: src/chess.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -988,40 +988,40 @@ export class Chess {
988988
}
989989
}
990990

991-
attackers(square: Square, attackedBy?: Color) {
991+
attackers(square: Square, attackedBy?: Color): Square[] {
992992
if (!attackedBy) {
993993
return this._attacked(this._turn, Ox88[square], true)
994994
} else {
995995
return this._attacked(attackedBy, Ox88[square], true)
996996
}
997997
}
998998

999-
private _isKingAttacked(color: Color) {
999+
private _isKingAttacked(color: Color): boolean {
10001000
const square = this._kings[color]
10011001
return square === -1 ? false : this._attacked(swapColor(color), square)
10021002
}
10031003

1004-
isAttacked(square: Square, attackedBy: Color) {
1004+
isAttacked(square: Square, attackedBy: Color): boolean {
10051005
return this._attacked(attackedBy, Ox88[square])
10061006
}
10071007

1008-
isCheck() {
1008+
isCheck(): boolean {
10091009
return this._isKingAttacked(this._turn)
10101010
}
10111011

1012-
inCheck() {
1012+
inCheck(): boolean {
10131013
return this.isCheck()
10141014
}
10151015

1016-
isCheckmate() {
1016+
isCheckmate(): boolean {
10171017
return this.isCheck() && this._moves().length === 0
10181018
}
10191019

1020-
isStalemate() {
1020+
isStalemate(): boolean {
10211021
return !this.isCheck() && this._moves().length === 0
10221022
}
10231023

1024-
isInsufficientMaterial() {
1024+
isInsufficientMaterial(): boolean {
10251025
/*
10261026
* k.b. vs k.b. (of opposite colors) with mate in 1:
10271027
* 8/8/8/8/1b6/8/B1k5/K7 b - - 0 1

0 commit comments

Comments
 (0)