@@ -4,12 +4,12 @@ import { isRole, PromotionChar, PromotionRole, roleToSan, setFenTurn } from './u
4
4
5
5
export interface ChessCtrl {
6
6
dests ( opts ?: { illegal ?: boolean } ) : Partial < Record < Key , Key [ ] > > ;
7
- color ( c : 'black' | 'white' ) : void ;
8
- color ( ) : 'black' | 'white' ;
7
+ color ( c : Color ) : void ;
8
+ color ( ) : Color ;
9
9
fen ( ) : string ;
10
10
move ( orig : Key , dest : Key , prom ?: PromotionRole | PromotionChar | '' ) : Move | null ;
11
11
occupation ( ) : Partial < Record < Key , Piece > > ;
12
- kingKey ( color : 'black' | 'white' ) : Key | undefined ;
12
+ kingKey ( color : Color ) : Key | undefined ;
13
13
findCapture ( ) : CgMove ;
14
14
findUnprotectedCapture ( ) : CgMove | undefined ;
15
15
checks ( ) : CgMove [ ] | null ;
@@ -46,7 +46,7 @@ export default function (fen: string, appleKeys: Key[]): ChessCtrl {
46
46
return chess . turn ( ) == 'w' ? 'white' : 'black' ;
47
47
}
48
48
49
- function setColor ( c : 'black' | 'white' ) {
49
+ function setColor ( c : Color ) {
50
50
const turn = c === 'white' ? 'w' : 'b' ;
51
51
let newFen = setFenTurn ( chess . fen ( ) , turn ) ;
52
52
chess . load ( newFen ) ;
@@ -73,9 +73,9 @@ export default function (fen: string, appleKeys: Key[]): ChessCtrl {
73
73
} ) ;
74
74
} ;
75
75
76
- function color ( ) : 'black' | 'white' ;
77
- function color ( c : 'black' | 'white' ) : void ;
78
- function color ( c ?: 'black' | 'white' ) {
76
+ function color ( ) : Color ;
77
+ function color ( c : Color ) : void ;
78
+ function color ( c ?: Color ) {
79
79
if ( c ) return setColor ( c ) ;
80
80
else return getColor ( ) ;
81
81
}
@@ -113,7 +113,7 @@ export default function (fen: string, appleKeys: Key[]): ChessCtrl {
113
113
} ) ;
114
114
return map ;
115
115
} ,
116
- kingKey : function ( color : 'black' | 'white' ) {
116
+ kingKey : function ( color : Color ) {
117
117
for ( const i in chess . SQUARES ) {
118
118
const p = chess . get ( chess . SQUARES [ i ] ) ;
119
119
if ( p && p . type === 'k' && p . color === ( color === 'white' ? 'w' : 'b' ) ) return chess . SQUARES [ i ] ;
0 commit comments