From 04b7eacfcb585c9432c7d39e389c15a72be26c63 Mon Sep 17 00:00:00 2001 From: Joe R Date: Sat, 1 Mar 2025 22:24:17 -0500 Subject: [PATCH] Fix highlight match logic for Nines/Tens/Elevens --- pysollib/games/pyramid.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pysollib/games/pyramid.py b/pysollib/games/pyramid.py index 9de28618..a0342969 100644 --- a/pysollib/games/pyramid.py +++ b/pysollib/games/pyramid.py @@ -583,8 +583,8 @@ class Elevens(Pyramid): self.leaveState(old_state) def shallHighlightMatch(self, stack1, card1, stack2, card2): - # FIXME - return False + return (card1.rank + card2.rank == 9 or + (9 < card1.rank != card2.rank > 9)) class ElevensToo(Elevens): @@ -633,6 +633,11 @@ class SuitElevens(Elevens): def createGame(self): Elevens.createGame(self, rows=3, cols=5) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (Elevens.shallHighlightMatch(self, stack1, card1, + stack2, card2) + and card1.suit == card2.suit) + # ************************************************************************ # * Tens @@ -665,6 +670,10 @@ class Tens(ElevensToo): def createGame(self): Elevens.createGame(self, rows=2, cols=7, maxpiles=13, reserves=4) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank + card2.rank == 8 or + (8 < card1.rank == card2.rank > 8)) + class Nines_RowStack(Elevens_RowStack): ACCEPTED_SUM = 7 @@ -709,6 +718,10 @@ class Nines(Tens): def createGame(self): Elevens.createGame(self, rows=3, cols=3, reserves=4) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank + card2.rank == 7 or + (8 < card1.rank != card2.rank > 8)) + # ************************************************************************ # * The Lucky Number