From 72386af5e6dad664d45659055d7e8b758774325d Mon Sep 17 00:00:00 2001 From: Joe R Date: Mon, 10 Mar 2025 22:02:24 -0400 Subject: [PATCH] Configure highlight matching for more games --- pysollib/games/montecarlo.py | 11 +++++++++++ pysollib/games/pyramid.py | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index 5d4c1f3a..97e18a2c 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -299,6 +299,9 @@ class Quatorze(MonteCarlo): return (stack1.id // 5 == stack2.id // 5 or stack1.id % 5 == stack2.id % 5) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return card1.rank + card2.rank == 12 + # ************************************************************************ # * Simple Pairs @@ -364,6 +367,10 @@ class BlockTen(SimplePairs): def isGameWon(self): return len(self.s.foundations[0].cards) == 48 + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank + card2.rank == 8 or + (9 < card1.rank == card2.rank > 9)) + class SimpleTens(BlockTen): def isGameWon(self): @@ -1108,6 +1115,10 @@ class AcesSquare(MonteCarlo): return (stack1.id // 4 == stack2.id // 4 or stack1.id % 4 == stack2.id % 4) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.suit == card2.suit and + card1.rank != card2.rank != 0) + # register the game registerGame(GameInfo(89, MonteCarlo, "Monte Carlo", diff --git a/pysollib/games/pyramid.py b/pysollib/games/pyramid.py index a0342969..31834f14 100644 --- a/pysollib/games/pyramid.py +++ b/pysollib/games/pyramid.py @@ -861,6 +861,9 @@ class Fifteens(Elevens): self._dropReserve() self.leaveState(old_state) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return card1.rank + card2.rank == 13 + # ************************************************************************ # * Eighteens @@ -953,6 +956,9 @@ class Eighteens(Fifteens): self._dropReserve() self.leaveState(old_state) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return False # How? + # ************************************************************************ # * Neptune @@ -982,6 +988,10 @@ class Neptune(Thirteens): def isGameWon(self): return len(self.s.talon.cards) == 0 + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank == card2.rank - 1 or + card1.rank == card2.rank + 1) + # ************************************************************************ # * Eight Cards @@ -1074,6 +1084,9 @@ class EightCards(Thirteens): # save vars (for undo/redo) return [self.draws] + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return card1.rank + card2.rank == 9 + # ************************************************************************ # * Triple Alliance @@ -1402,6 +1415,10 @@ class ElevenTriangle(Apophis): INVERT = True MAX_ROUNDS = 1 + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank + card2.rank == 9 or + (9 < card1.rank == card2.rank > 9)) + # ************************************************************************ # * Cheops @@ -1828,6 +1845,9 @@ class Hurricane(Pyramid): self.s.talon.moveMove(1, stack) self.leaveState(old_state) + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return card1.rank + card2.rank == 12 + # ************************************************************************ # * Ides of March @@ -1860,6 +1880,10 @@ class IdesOfMarch(Hurricane): RowStack_Class = IdesOfMarch_RowStack Reserve_Class = IdesOfMarch_Reserve + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return (card1.rank + card2.rank == 13 or + card1.rank + card2.rank == 0) + # register the game registerGame(GameInfo(38, Pyramid, "Pyramid",