diff --git a/chess/board.go b/chess/board.go index 1f17f6c..b26c900 100644 --- a/chess/board.go +++ b/chess/board.go @@ -301,6 +301,7 @@ func (b *Board) Move(move string) error { move = strings.Replace(move, "x", "", 1) } + // TODO: parse ambiguous captures for all pieces // TODO: parse promotions // TODO: parse checks e.g. e5+ // TODO: parse checkmates e.g. e5# diff --git a/chess/board_test.go b/chess/board_test.go index 0c01e4d..57fdda6 100644 --- a/chess/board_test.go +++ b/chess/board_test.go @@ -98,12 +98,28 @@ func TestBoardMovePawnInvalid(t *testing.T) { func TestBoardMovePawnCapture(t *testing.T) { b := chess.NewBoard() - b.Move("e4") - b.Move("d5") - b.Move("exd5") + assert.NoError(t, b.Parse("e4 d5 exd5")) assertNoPiece(t, b, "e4") assertPiece(t, b, "d5", chess.Pawn, chess.Light) + + // test ambiguous capture + + b = chess.NewBoard() + + assert.NoError(t, b.Parse("c4 d5 e4 e5 exd5")) + + assertNoPiece(t, b, "e4") + assertPiece(t, b, "d5", chess.Pawn, chess.Light) + assertPiece(t, b, "c4", chess.Pawn, chess.Light) + + b = chess.NewBoard() + + assert.NoError(t, b.Parse("c4 d5 e4 e5 cxd5")) + + assertNoPiece(t, b, "c4") + assertPiece(t, b, "d5", chess.Pawn, chess.Light) + assertPiece(t, b, "e4", chess.Pawn, chess.Light) } func TestBoardMoveKnight(t *testing.T) {