From b6454ce541d9dd13692ce6de35013858eb0823ae Mon Sep 17 00:00:00 2001
From: Joe R <joeraz5@verizon.net>
Date: Thu, 14 Nov 2024 17:58:17 -0500
Subject: [PATCH] Add basic hint to Crossword for stuck checking

---
 pysollib/games/crossword.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/pysollib/games/crossword.py b/pysollib/games/crossword.py
index fec31a49..ff7fa7e4 100644
--- a/pysollib/games/crossword.py
+++ b/pysollib/games/crossword.py
@@ -23,6 +23,7 @@
 
 from pysollib.game import Game
 from pysollib.gamedb import GI, GameInfo, registerGame
+from pysollib.hint import AbstractHint
 from pysollib.layout import Layout
 from pysollib.stack import \
         OpenTalonStack, \
@@ -36,6 +37,20 @@ from pysollib.stack import \
 # ************************************************************************
 
 
+class Crossword_Hint(AbstractHint):
+
+    def computeHints(self):
+        game = self.game
+        rows = game.s.rows
+        for i in range(len(rows)):
+            r = rows[i]
+            if r.cards:
+                continue
+            if game.isValidPlay(r.id, game.s.talon.getCard().rank + 1):
+                # TODO: Check a few moves ahead to get better hints.
+                self.addHint(5000, 1, game.s.talon, r)
+
+
 class Crossword_RowStack(ReserveStack):
     def clickHandler(self, event):
         if (not self.cards and self.game.s.talon.cards and
@@ -85,7 +100,7 @@ class Crossword(Game):
     Talon_Class = OpenTalonStack
     RowStack_Class = StackWrapper(Crossword_RowStack, max_move=0)
     FinalCards_Class = StackWrapper(Crossword_FinalCard, max_move=0)
-    Hint_Class = None
+    Hint_Class = Crossword_Hint
 
     #
     # game layout