From 808382a7a10f747f4ae4cf18dc13bd4059af22ad Mon Sep 17 00:00:00 2001 From: Joe R Date: Fri, 9 Jul 2021 22:16:00 -0400 Subject: [PATCH] Added Quatorze game. --- html-src/rules/quatorze.html | 23 ++++++++++++++++ pysollib/gamedb.py | 9 +++--- pysollib/games/montecarlo.py | 53 ++++++++++++++++++++++++++++++------ 3 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 html-src/rules/quatorze.html diff --git a/html-src/rules/quatorze.html b/html-src/rules/quatorze.html new file mode 100644 index 00000000..4ec30846 --- /dev/null +++ b/html-src/rules/quatorze.html @@ -0,0 +1,23 @@ +

Quatorze

+

+Pairing game type. 1 deck. No redeal. + +

Object

+

+Discard all the cards. + +

Rules

+

+The object is to use up all the cards from the tableau by +discarding pairs of cards with ranks that total 14 (Jacks are 11, +Queens are 12, and Kings are 13). You can only discard pairs if +the cards are in the same row or column. +

+After removing a pair of cards, cards are dealt to fill in the gaps. +Once the stock is empty, the cards are shifted up to fill in. +

+You win when the cards are all discarded. + +

Notes

+

+Autodrop is disabled for this game. diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index 549b5b80..fc81a40e 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -279,15 +279,14 @@ class GI: # )), # Gnome AisleRiot 2.2.0 (we have 62 out of 70 games) # still missing: - # Helsinki, - # Isabel, Labyrinth, Quatorze, Thieves, - # Treize, Valentine, Yeld. + # Helsinki, Isabel, Labyrinth, Thieves, + # Treize, Valentine, Yield. ("Gnome AisleRiot", ( 1, 2, 8, 9, 11, 12, 19, 24, 27, 29, 31, 33, 34, 35, 36, 40, 41, 42, 43, 45, 48, 58, 59, 67, 89, 91, 92, 93, 94, 95, 96, 100, 105, 111, 112, 113, 130, 139, 144, 146, 147, 148, 200, 201, 206, 224, 225, 229, 230, 233, 257, 258, 280, 281, 282, - 283, 284, 551, 552, 553, 674, 737, + 283, 284, 551, 552, 553, 674, 737, 810, )), # KDE Patience 0.7.3 from KDE 1.1.2 (we have 6 out of 9 games) @@ -405,7 +404,7 @@ class GI: ('fc-2.0', tuple(range(11011, 11014)) + tuple(range(759, 767))), ('fc-2.1', tuple(range(767, 774))), ('fc-2.8', (343001,)), - ('fc-2.12', tuple(range(774, 810)) + (16681,) + + ('fc-2.12', tuple(range(774, 811)) + (16681,) + tuple(range(22217, 22219))) ) diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index 1dcb600f..e8fb5a06 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -112,6 +112,7 @@ class MonteCarlo(Game): Hint_Class = MonteCarlo_Hint FILL_STACKS_AFTER_DROP = False + FILL_STACKS_BEFORE_SHIFT = False # # game layout @@ -173,15 +174,10 @@ class MonteCarlo(Game): return diff in (-6, -5, -4, -1, 1, 4, 5, 6) def fillEmptyStacks(self): - free, n = 0, 0 + n = 0 self.startDealSample() - for r in self.s.rows: - assert len(r.cards) <= 1 - if not r.cards: - free += 1 - elif free > 0: - to_stack = self.allstacks[r.id - free] - self.moveMove(1, r, to_stack, frames=4, shadow=0) + free = self.shiftCards() + remcards = free > len(self.s.talon.cards) > 0 if free > 0: for r in self.s.rows: if not r.cards: @@ -190,9 +186,23 @@ class MonteCarlo(Game): self.flipMove(self.s.talon) self.moveMove(1, self.s.talon, r) n += 1 + if remcards and self.FILL_STACKS_BEFORE_SHIFT: + self.shiftCards() self.stopSamples() return n + free + def shiftCards(self): + free = 0 + for r in self.s.rows: + assert len(r.cards) <= 1 + if not r.cards: + free += 1 + elif free > 0 and (not self.FILL_STACKS_BEFORE_SHIFT + or not self.s.talon.cards): + to_stack = self.allstacks[r.id - free] + self.moveMove(1, r, to_stack, frames=4, shadow=0) + return free + class MonteCarlo2Decks(MonteCarlo): pass @@ -261,6 +271,31 @@ class SimpleCarlo(MonteCarlo): return 0 <= stack1.id <= 24 and 0 <= stack2.id <= 24 +# ************************************************************************ +# * Quatorze +# ************************************************************************ + +class Quatorze_RowStack(MonteCarlo_RowStack): + def acceptsCards(self, from_stack, cards): + if not OpenStack.acceptsCards(self, from_stack, cards): + return False + # check the rank + if self.cards[-1].rank + cards[0].rank != 12: + return False + # now look if the stacks are neighbours + return self.game.isNeighbour(from_stack, self) + + +class Quatorze(MonteCarlo): + RowStack_Class = Quatorze_RowStack + FILL_STACKS_AFTER_DROP = True + FILL_STACKS_BEFORE_SHIFT = True + + def isNeighbour(self, stack1, stack2): + return (stack1.id // 5 == stack2.id // 5 or + stack1.id % 5 == stack2.id % 5) + + # ************************************************************************ # * Simple Pairs # ************************************************************************ @@ -944,3 +979,5 @@ registerGame(GameInfo(727, RightAndLeft, "Right and Left", registerGame(GameInfo(801, DoubleNestor, "Double Nestor", GI.GT_PAIRING_TYPE | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_LUCK)) +registerGame(GameInfo(810, Quatorze, "Quatorze", + GI.GT_PAIRING_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))