diff --git a/lib/chess/board.ex b/lib/chess/board.ex index b764522..cb86af5 100644 --- a/lib/chess/board.ex +++ b/lib/chess/board.ex @@ -32,7 +32,7 @@ defmodule Chess.Board do Map.put(board, "#{to_file},#{to_rank}", piece) end - def check?(board, colour) do + def king_in_check?(board, colour) do king = board |> search(%{"type" => "king", "colour" => colour}) diff --git a/test/chess/board_test.exs b/test/chess/board_test.exs index c19f448..f7be08b 100644 --- a/test/chess/board_test.exs +++ b/test/chess/board_test.exs @@ -47,7 +47,7 @@ defmodule Chess.BoardTest do "4,7" => %{"type" => "queen", "colour" => "black"}, } - assert Board.check?(board, "white") + assert Board.king_in_check?(board, "white") end test "recognise when the king is not in check" do @@ -56,7 +56,7 @@ defmodule Chess.BoardTest do "4,7" => %{"type" => "queen", "colour" => "black"}, } - refute Board.check?(board, "white") + refute Board.king_in_check?(board, "white") end test "recognize when the king is in check by a knight" do @@ -65,7 +65,7 @@ defmodule Chess.BoardTest do "3,2" => %{"type" => "knight", "colour" => "black"}, } - assert Board.check?(board, "white") + assert Board.king_in_check?(board, "white") end test "recognize when the king is in check by a pawn" do @@ -74,6 +74,6 @@ defmodule Chess.BoardTest do "3,1" => %{"type" => "pawn", "colour" => "black"}, } - assert Board.check?(board, "white") + assert Board.king_in_check?(board, "white") end end