Comparing version 1.0.0-beta.3 to 1.0.0-beta.4
@@ -62,2 +62,4 @@ /** | ||
lan: string; | ||
before: string; | ||
after: string; | ||
}; | ||
@@ -110,2 +112,9 @@ export declare const SQUARES: Square[]; | ||
}): string[]; | ||
moves({ piece }: { | ||
piece: PieceSymbol; | ||
}): string[]; | ||
moves({ square, piece }: { | ||
square: Square; | ||
piece: PieceSymbol; | ||
}): string[]; | ||
moves({ verbose, square }: { | ||
@@ -123,2 +132,33 @@ verbose: true; | ||
}): string[] | Move[]; | ||
moves({ verbose, piece }: { | ||
verbose: true; | ||
piece?: PieceSymbol; | ||
}): Move[]; | ||
moves({ verbose, piece }: { | ||
verbose: false; | ||
piece?: PieceSymbol; | ||
}): string[]; | ||
moves({ verbose, piece, }: { | ||
verbose?: boolean; | ||
piece?: PieceSymbol; | ||
}): string[] | Move[]; | ||
moves({ verbose, square, piece, }: { | ||
verbose: true; | ||
square?: Square; | ||
piece?: PieceSymbol; | ||
}): Move[]; | ||
moves({ verbose, square, piece, }: { | ||
verbose: false; | ||
square?: Square; | ||
piece?: PieceSymbol; | ||
}): string[]; | ||
moves({ verbose, square, piece, }: { | ||
verbose?: boolean; | ||
square?: Square; | ||
piece?: PieceSymbol; | ||
}): string[] | Move[]; | ||
moves({ square, piece }: { | ||
square?: Square; | ||
piece?: PieceSymbol; | ||
}): Move[]; | ||
_moves({ legal, piece, square, }?: { | ||
@@ -164,13 +204,9 @@ legal?: boolean; | ||
verbose: true; | ||
}): (Move & { | ||
fen: string; | ||
})[]; | ||
}): Move[]; | ||
history({ verbose }: { | ||
verbose: false; | ||
}): string[]; | ||
history({ verbose, }: { | ||
history({ verbose }: { | ||
verbose: boolean; | ||
}): string[] | (Move & { | ||
fen: string; | ||
})[]; | ||
}): string[] | Move[]; | ||
private _pruneComments; | ||
@@ -177,0 +213,0 @@ getComment(): string; |
{ | ||
"name": "chess.js", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-beta.4", | ||
"license": "BSD-2-Clause", | ||
@@ -5,0 +5,0 @@ "main": "dist/chess.js", |
@@ -301,3 +301,4 @@ # chess.js | ||
// { | ||
// fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', | ||
// before: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', | ||
// after: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1', | ||
// color: 'w', | ||
@@ -312,3 +313,4 @@ // piece: 'p', | ||
// { | ||
// fen: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1', | ||
// before: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1', | ||
// after: 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2', | ||
// color: 'b', | ||
@@ -323,3 +325,4 @@ // piece: 'p', | ||
// { | ||
// fen: 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2', | ||
// before: 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2', | ||
// after: 'rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR b KQkq - 0 2', | ||
// color: 'w', | ||
@@ -334,3 +337,4 @@ // piece: 'p', | ||
// { | ||
// fen: 'rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR b KQkq - 0 2', | ||
// before: 'rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR b KQkq - 0 2', | ||
// after: 'rnbqkbnr/pppp1ppp/8/8/4Pp2/8/PPPP2PP/RNBQKBNR w KQkq - 0 3', | ||
// color: 'b', | ||
@@ -593,3 +597,3 @@ // piece: 'p', | ||
#### .move() - Move Object | ||
#### .move() - Object Notation | ||
@@ -634,6 +638,6 @@ A move object contains `to`, `from` and, `promotion` (only when necessary) | ||
### .moves([ options ]) | ||
### .moves({ piece?: Piece, square?: Square, verbose?: Boolean }?) | ||
Returns a list of legal moves from the current position. This function takes an | ||
optional parameter which can be used to generate detailed move objects or to | ||
optional object which can be used to generate detailed move objects or to | ||
restrict the move generator to specific squares or pieces. | ||
@@ -655,3 +659,6 @@ | ||
// -> [{ color: 'w', from: 'a2', to: 'a3', | ||
// flags: 'n', piece: 'p', san 'a3' | ||
// flags: 'n', piece: 'p', | ||
// san 'a3', 'lan', 'a2a3', | ||
// before: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' | ||
// after: 'rnbqkbnr/pppppppp/8/8/8/P7/1PPPPPPP/RNBQKBNR b KQkq - 0 1' | ||
// # a `captured` field is included when the move is a capture | ||
@@ -664,3 +671,3 @@ // # a `promotion` field is included when the move is a promotion | ||
#### Move Objects (e.g. { verbose: true }) | ||
#### Move Objects (e.g. when { verbose: true }) | ||
@@ -676,4 +683,8 @@ The `color` field indicates the color of the moving piece (`w` or `b`). | ||
The `san` field is the move in Standard Algebraic Notation (SAN). | ||
The `san` field is the move in Standard Algebraic Notation (SAN). The `lan` | ||
field is the move in Long Algebraic Notation (LAN). | ||
The `before` and `after` keys contain the FEN of the position before and after | ||
the move. | ||
The `flags` field contains one or more of the string values: | ||
@@ -813,3 +824,14 @@ | ||
chess.undo() | ||
// -> { color: 'w', from: 'e2', to: 'e4', flags: 'b', piece: 'p', san: 'e4' } | ||
// { | ||
// color: 'w', | ||
// piece: 'p', | ||
// from: 'e2', | ||
// to: 'e4', | ||
// san: 'e4', | ||
// flags: 'b', | ||
// lan: 'e2e4', | ||
// before: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', | ||
// after: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1' | ||
// } | ||
chess.fen() | ||
@@ -816,0 +838,0 @@ // -> 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' |
@@ -90,2 +90,4 @@ /** | ||
lan: string | ||
before: string | ||
after: string | ||
} | ||
@@ -964,2 +966,6 @@ | ||
moves({ square }: { square: Square }): string[] | ||
moves({ piece }: { piece: PieceSymbol }): string[] | ||
moves({ square, piece }: { square: Square; piece: PieceSymbol }): string[] | ||
moves({ verbose, square }: { verbose: true; square?: Square }): Move[] | ||
@@ -974,7 +980,49 @@ moves({ verbose, square }: { verbose: false; square?: Square }): string[] | ||
}): string[] | Move[] | ||
moves({ verbose, piece }: { verbose: true; piece?: PieceSymbol }): Move[] | ||
moves({ verbose, piece }: { verbose: false; piece?: PieceSymbol }): string[] | ||
moves({ | ||
verbose, | ||
piece, | ||
}: { | ||
verbose?: boolean | ||
piece?: PieceSymbol | ||
}): string[] | Move[] | ||
moves({ | ||
verbose, | ||
square, | ||
piece, | ||
}: { | ||
verbose: true | ||
square?: Square | ||
piece?: PieceSymbol | ||
}): Move[] | ||
moves({ | ||
verbose, | ||
square, | ||
piece, | ||
}: { | ||
verbose: false | ||
square?: Square | ||
piece?: PieceSymbol | ||
}): string[] | ||
moves({ | ||
verbose, | ||
square, | ||
piece, | ||
}: { | ||
verbose?: boolean | ||
square?: Square | ||
piece?: PieceSymbol | ||
}): string[] | Move[] | ||
moves({ square, piece }: { square?: Square; piece?: PieceSymbol }): Move[] | ||
moves({ | ||
verbose = false, | ||
square = undefined, | ||
}: { verbose?: boolean; square?: Square } = {}) { | ||
const moves = this._moves({ square }) | ||
piece = undefined, | ||
}: { verbose?: boolean; square?: Square; piece?: PieceSymbol } = {}) { | ||
const moves = this._moves({ square, piece }) | ||
@@ -2035,4 +2083,11 @@ if (verbose) { | ||
lan: fromAlgebraic + toAlgebraic, | ||
before: this.fen(), | ||
after: '', | ||
} | ||
// generate the FEN for the 'after' key | ||
this._makeMove(uglyMove) | ||
move.after = this.fen() | ||
this._undoMove() | ||
if (captured) { | ||
@@ -2087,9 +2142,5 @@ move.captured = captured | ||
history(): string[] | ||
history({ verbose }: { verbose: true }): (Move & { fen: string })[] | ||
history({ verbose }: { verbose: true }): Move[] | ||
history({ verbose }: { verbose: false }): string[] | ||
history({ | ||
verbose, | ||
}: { | ||
verbose: boolean | ||
}): string[] | (Move & { fen: string })[] | ||
history({ verbose }: { verbose: boolean }): string[] | Move[] | ||
history({ verbose = false }: { verbose?: boolean } = {}) { | ||
@@ -2110,3 +2161,3 @@ const reversedHistory = [] | ||
if (verbose) { | ||
moveHistory.push({ fen: this.fen(), ...this._makePretty(move) }) | ||
moveHistory.push(this._makePretty(move)) | ||
} else { | ||
@@ -2113,0 +2164,0 @@ moveHistory.push(this._moveToSan(move, this._moves())) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215548
3953
851