diff --git a/python_pkg/keyboard_coop/main.py b/python_pkg/keyboard_coop/main.py index 4a993b3..9aea578 100644 --- a/python_pkg/keyboard_coop/main.py +++ b/python_pkg/keyboard_coop/main.py @@ -26,7 +26,6 @@ SCREEN_HEIGHT = 768 BACKGROUND_COLOR = (30, 30, 40) KEYBOARD_COLOR = (60, 60, 70) KEY_COLOR = (80, 80, 90) -KEY_HOVER_COLOR = (100, 100, 110) KEY_SELECTED_COLOR = (150, 150, 200) KEY_AVAILABLE_COLOR = (100, 150, 100) TEXT_COLOR = (255, 255, 255) @@ -346,10 +345,6 @@ class KeyboardCoopGame: f"Player {self.state.current_player + 1}: Choose an adjacent letter!" ) - # If no valid moves available, force word submission - if not self.keyboard.available_letters: - self._submit_word() - def _submit_word(self) -> None: """Submit the current word and check if it's valid.""" if len(self.state.current_word) >= MIN_WORD_LENGTH and self._is_valid_word( @@ -387,19 +382,12 @@ class KeyboardCoopGame: def _draw_keyboard(self) -> None: """Draw the virtual keyboard.""" - mouse_pos = pygame.mouse.get_pos() - for letter, rect in self.keyboard.positions.items(): # Determine key color if letter in self.state.selected_letters: color = KEY_SELECTED_COLOR elif letter in self.keyboard.available_letters: color = KEY_AVAILABLE_COLOR - elif ( - rect.collidepoint(mouse_pos) - and letter in self.keyboard.available_letters - ): - color = KEY_HOVER_COLOR else: color = KEY_COLOR diff --git a/python_pkg/keyboard_coop/tests/test_main.py b/python_pkg/keyboard_coop/tests/test_main.py index 8f3b840..24d78fb 100644 --- a/python_pkg/keyboard_coop/tests/test_main.py +++ b/python_pkg/keyboard_coop/tests/test_main.py @@ -760,15 +760,14 @@ class TestDrawKeyboard: colors_used = [call[0][1] for call in calls] assert KEY_SELECTED_COLOR in colors_used - def test_draw_keyboard_hover_color(self) -> None: - """Test hover color when mouse is over available key.""" + def test_draw_keyboard_unavailable_key_color(self) -> None: + """Test unavailable keys get default key color.""" mock_pg = MagicMock() mock_pg.draw = MagicMock() - # Mouse is at position that collides with the key - mock_pg.mouse.get_pos.return_value = (100, 100) with patch.dict("sys.modules", {"pygame": mock_pg}): from python_pkg.keyboard_coop.main import ( + KEY_COLOR, FontSet, GameState, KeyboardCoopGame, @@ -785,18 +784,18 @@ class TestDrawKeyboard: ) mock_rect_a = MagicMock() - # Mouse collides with this rect - mock_rect_a.collidepoint.return_value = True mock_rect_a.center = (100, 100) game.keyboard.positions = {"a": mock_rect_a} - # Key is available (required for hover color) - game.keyboard.available_letters = {"a"} + # Key is NOT available - should get KEY_COLOR + game.keyboard.available_letters = set() game._draw_keyboard() - # draw.rect should have been called - assert mock_pg.draw.rect.call_count >= 2 + # Check that KEY_COLOR was used for unavailable key + calls = mock_pg.draw.rect.call_args_list + colors_used = [call[0][1] for call in calls] + assert KEY_COLOR in colors_used class TestDrawUI: