1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Rename function

This commit is contained in:
Daniel Barber 2018-03-23 12:02:11 -04:00
parent 320cb03b1f
commit 048db4c71c
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ defmodule Chess.Board do
Map.put(board, "#{to_file},#{to_rank}", piece) Map.put(board, "#{to_file},#{to_rank}", piece)
end end
def check?(board, colour) do def king_in_check?(board, colour) do
king = king =
board board
|> search(%{"type" => "king", "colour" => colour}) |> search(%{"type" => "king", "colour" => colour})

View File

@ -47,7 +47,7 @@ defmodule Chess.BoardTest do
"4,7" => %{"type" => "queen", "colour" => "black"}, "4,7" => %{"type" => "queen", "colour" => "black"},
} }
assert Board.check?(board, "white") assert Board.king_in_check?(board, "white")
end end
test "recognise when the king is not in check" do test "recognise when the king is not in check" do
@ -56,7 +56,7 @@ defmodule Chess.BoardTest do
"4,7" => %{"type" => "queen", "colour" => "black"}, "4,7" => %{"type" => "queen", "colour" => "black"},
} }
refute Board.check?(board, "white") refute Board.king_in_check?(board, "white")
end end
test "recognize when the king is in check by a knight" do 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"}, "3,2" => %{"type" => "knight", "colour" => "black"},
} }
assert Board.check?(board, "white") assert Board.king_in_check?(board, "white")
end end
test "recognize when the king is in check by a pawn" do 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"}, "3,1" => %{"type" => "pawn", "colour" => "black"},
} }
assert Board.check?(board, "white") assert Board.king_in_check?(board, "white")
end end
end end