Skip to content

Commit

Permalink
verbosity of failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Oceankoh committed Jan 20, 2024
1 parent 4dc853b commit 2d57561
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/src/chess/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const chess = new Chess();
function movePiece(square1, square2): string | FailedMove {
const piece = chess.remove(square1);
if (!piece) {
return new FailedMove(`No piece found at ${square1}`);
return new FailedMove(`Tried to move piece at ${square1} to ${square2} but there was no piece found at ${square1}`);
}
chess.put(piece, square2);
const validate = validateFen(chess.fen());
Expand All @@ -68,7 +68,7 @@ function movePiece(square1, square2): string | FailedMove {
function promotePiece(square1, square2, piece): string | FailedMove {
const pawn = chess.remove(square1);
if (!pawn) {
return new FailedMove(`No piece found at ${square1}`);
return new FailedMove(`Tried to promote piece at ${square1}, but there was no piece found at ${square1}`);
}
chess.put({ type: piece, color: pawn.color }, square2);
const validate = validateFen(chess.fen());
Expand Down

0 comments on commit 2d57561

Please sign in to comment.