Don't allow promotion unless player is same color

This commit is contained in:
Elizabeth Hunt 2023-01-27 16:04:34 -07:00
parent 5220ac5823
commit 7a574f73f9
Signed by: simponic
GPG Key ID: 52B3774857EB24B1

View File

@ -185,7 +185,8 @@ defmodule Chessh.SSH.Client.Game do
cursor: %{x: cursor_x, y: cursor_y} = cursor, cursor: %{x: cursor_x, y: cursor_y} = cursor,
client_pid: client_pid, client_pid: client_pid,
flipped: flipped, flipped: flipped,
binbo_pid: binbo_pid binbo_pid: binbo_pid,
color: color
} = state } = state
) do ) do
new_cursor = new_cursor =
@ -237,12 +238,12 @@ defmodule Chessh.SSH.Client.Game do
1 -> 1 ->
# Light pawn # Light pawn
{y, _} = maybe_flipped_to {y, _} = maybe_flipped_to
y == 0 y == 0 && color == :light
17 -> 17 ->
# Dark pawn # Dark pawn
{y, _} = maybe_flipped_to {y, _} = maybe_flipped_to
y == Renderer.chess_board_height() - 1 y == Renderer.chess_board_height() - 1 && color == :dark
_ -> _ ->
false false