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

Added Following game.

This commit is contained in:
Joe R 2021-08-02 18:46:28 -04:00
parent 69ddbe2b37
commit e64a85ba36
5 changed files with 80 additions and 9 deletions

View file

@ -0,0 +1,25 @@
<h1>Following</h1>
<p>
Forty Thieves type. 1 deck. 1 redeal.
<h3>Object</h3>
<p>
Move all cards to the foundations.
<h3>Rules</h3>
<p>
Six cards are dealt out to form the initial tableau. Cards may be
moved to foundations, which are built up in rank, in a specific
sequence of suits, in the following order:
<ul>
<li>Hearts</li>
<li>Clubs</li>
<li>Diamonds</li>
<li>Spades</li>
</ul>
<p>
Tableau piles are built down by rank, following the same sequence
of suits as the foundations. Any sequence of cards in the tableau
can be moved. When no cards are left to play, cards may be dealt
one at a time from the stock. One redeal is allowed, so you can go
through the stock twice.

View file

@ -423,7 +423,7 @@ class GI:
('fc-2.8', (343001,)),
('fc-2.12', tuple(range(774, 811)) + (16681,) +
tuple(range(22217, 22219))),
('fc-2.14', tuple(range(811, 815)))
('fc-2.14', tuple(range(811, 816)))
)
# deprecated - the correct way is to or a GI.GT_XXX flag

View file

@ -42,8 +42,8 @@ from pysollib.stack import \
UD_AC_RowStack, \
WasteStack, \
WasteTalonStack
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, KING, NO_RANK, \
UNLIMITED_MOVES, UNLIMITED_REDEALS
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, CLUB, DIAMOND,\
HEART, KING, NO_RANK, SPADE, UNLIMITED_MOVES, UNLIMITED_REDEALS
class FortyThieves_Hint(CautiousDefaultHint):
@ -1236,6 +1236,47 @@ class Foothold(FortyThieves):
shallHighlightMatch = Game._shallHighlightMatch_AC
# ************************************************************************
# * Following
# ************************************************************************
class Following_RowStack(RK_RowStack):
def acceptsCards(self, from_stack, cards):
if self.cards and not self.game.inSuitSequence(self.cards[-1],
cards[0]):
return False
return RK_RowStack.acceptsCards(self, from_stack, cards)
class Following_Foundation(AC_FoundationStack):
def acceptsCards(self, from_stack, cards):
if self.cards and not self.game.inSuitSequence(self.cards[-1],
cards[0]):
return False
return AC_FoundationStack.acceptsCards(self, from_stack, cards)
class Following(FortyThieves):
RowStack_Class = Following_RowStack
Foundation_Class = Following_Foundation
DEAL = (0, 1)
ROW_MAX_MOVE = UNLIMITED_MOVES
def createGame(self):
FortyThieves.createGame(self, max_rounds=2, rows=6, XCARDS=1)
def inSuitSequence(self, card1, card2):
if card1.suit == SPADE and card2.suit == HEART:
return True
if card1.suit == HEART and card2.suit == CLUB:
return True
if card1.suit == CLUB and card2.suit == DIAMOND:
return True
if card1.suit == DIAMOND and card2.suit == SPADE:
return True
return False
# register the game
registerGame(GameInfo(13, FortyThieves, "Forty Thieves",
GI.GT_FORTY_THIEVES, 2, 0, GI.SL_MOSTLY_SKILL,
@ -1369,3 +1410,5 @@ registerGame(GameInfo(775, SixtyThieves, "Sixty Thieves",
GI.GT_FORTY_THIEVES, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(776, EightyThieves, "Eighty Thieves",
GI.GT_FORTY_THIEVES, 4, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(815, Following, "Following",
GI.GT_FORTY_THIEVES, 1, 1, GI.SL_BALANCED))

View file

@ -49,8 +49,8 @@ from pysollib.stack import \
WasteStack, \
WasteTalonStack, \
isSameSuitSequence
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, KING, NO_RANK, RANKS, \
SUITS, \
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, DIAMOND, KING, NO_RANK,\
RANKS, SUITS, \
UNLIMITED_REDEALS
@ -620,9 +620,6 @@ class Uintah(Game):
# * Diamond Mine
# ************************************************************************
DIAMOND = 3
class DiamondMine_RowStack(RK_RowStack):
def acceptsCards(self, from_stack, cards):
if not RK_RowStack.acceptsCards(self, from_stack, cards):

View file

@ -46,6 +46,12 @@ SUITS = (_("Club"), _("Spade"), _("Heart"), _("Diamond"))
SUITS_PL = (_("Clubs"), _("Spades"), _("Hearts"), _("Diamonds"))
COLORS = (_("black"), _("red"))
# Specific suits
CLUB = 0
SPADE = 1
HEART = 2
DIAMOND = 3
# Card ranks are 0-12. We also define symbolic names for the picture cards.
RANKS = (_("Ace"), "2", "3", "4", "5", "6", "7", "8", "9", "10",
_("Jack"), _("Queen"), _("King"))