1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Added Quatorze game.

This commit is contained in:
Joe R 2021-07-09 22:16:00 -04:00
parent c1b7efbbf8
commit 808382a7a1
3 changed files with 72 additions and 13 deletions

View file

@ -0,0 +1,23 @@
<h1>Quatorze</h1>
<p>
Pairing game type. 1 deck. No redeal.
<h3>Object</h3>
<p>
Discard all the cards.
<h3>Rules</h3>
<p>
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.
<p>
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.
<p>
You win when the cards are all discarded.
<h3>Notes</h3>
<p>
<i>Autodrop</i> is disabled for this game.

View file

@ -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)))
)

View file

@ -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))