From 7a574f73f9f06d95c4f5d256d55c155cf5923356 Mon Sep 17 00:00:00 2001 From: Simponic Date: Fri, 27 Jan 2023 16:04:34 -0700 Subject: [PATCH] Don't allow promotion unless player is same color --- lib/chessh/ssh/client/game/game.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex index 6d107e6..e863ed9 100644 --- a/lib/chessh/ssh/client/game/game.ex +++ b/lib/chessh/ssh/client/game/game.ex @@ -185,7 +185,8 @@ defmodule Chessh.SSH.Client.Game do cursor: %{x: cursor_x, y: cursor_y} = cursor, client_pid: client_pid, flipped: flipped, - binbo_pid: binbo_pid + binbo_pid: binbo_pid, + color: color } = state ) do new_cursor = @@ -237,12 +238,12 @@ defmodule Chessh.SSH.Client.Game do 1 -> # Light pawn {y, _} = maybe_flipped_to - y == 0 + y == 0 && color == :light 17 -> # Dark pawn {y, _} = maybe_flipped_to - y == Renderer.chess_board_height() - 1 + y == Renderer.chess_board_height() - 1 && color == :dark _ -> false