Skip to content

Commit a9f8e49

Browse files
committed
[bugfix] Fix the wrong highlight of the king in check
1 parent 77f2009 commit a9f8e49

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/apps/chess/components/chess_board.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ def chess_character_display(
517517

518518
# Some data we'll need:
519519
piece_player_side = player_side_from_piece_role(piece_role)
520+
belongs_to_active_player = (
521+
bool(piece_player_side == game_presenter.active_player_side)
522+
if game_presenter
523+
else False
524+
)
520525
is_my_turn = game_presenter.is_my_turn if game_presenter else False
521526
is_playable = is_my_turn and (
522527
(
@@ -558,20 +563,12 @@ def chess_character_display(
558563
# Right, let's do this shall we?
559564
if (
560565
is_king
561-
and is_my_turn
562-
and game_presenter
563-
and game_presenter.solution_index is None
564-
and game_presenter.is_check
565-
):
566-
is_potential_capture = True # let's highlight our king if it's in check
567-
elif (
568-
is_king
569-
and is_my_turn
570566
and game_presenter
571-
and game_presenter.solution_index is not None
567+
and belongs_to_active_player
572568
and game_presenter.is_check
573569
):
574-
is_potential_capture = True # let's highlight checks in "see solution" mode
570+
# let's always highlight a king if it's in check:
571+
is_potential_capture = True
575572

576573
horizontal_translation = (
577574
("left-2" if (is_knight or is_king) else "left-0")

0 commit comments

Comments
 (0)