Skip to content

Commit

Permalink
Added Tens game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Sep 5, 2023
1 parent df95421 commit 8a1940b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
24 changes: 24 additions & 0 deletions html-src/rules/tens.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h1>Tens</h1>
<p>
Pairing game type. 1 deck. No redeal.

<h3>Object</h3>
<p>
Move all cards to the single foundation.

<h3>Rules</h3>
<p>
Thirteen cards are dealt to the tableau. Pairs of cards that total
ten can be moved to the foundation, and the spaces are filled from
the talon.
<p>
Tens and picture cards are removed in a set of four of a kind. These
can be discarded by moving them to the four reserves (all four cards must
be moved to the reserve and discarded at the same time).
<p>
The game is won if all cards have been discarded.

<h3>Notes</h3>
<p>

<i>Autodrop</i> is disabled for this game.
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def _callback(gi, gt=game_type):
('fc-2.20', tuple(range(855, 897))),
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
tuple(range(13160, 13163)) + (16682,)),
('dev', tuple(range(906, 916)) + tuple(range(11017, 11020)) +
('dev', tuple(range(906, 917)) + tuple(range(11017, 11020)) +
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
)

Expand Down
41 changes: 40 additions & 1 deletion pysollib/games/pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ def fillStack(self, stack):

# ************************************************************************
# * Elevens
# * Elevens Too
# * Suit Elevens
# ************************************************************************

Expand Down Expand Up @@ -532,7 +533,7 @@ class Elevens(Pyramid):
RowStack_Class = Elevens_RowStack
Reserve_Class = Elevens_Reserve

def createGame(self, rows=3, cols=3, reserves=3, texts=False):
def createGame(self, rows=3, cols=3, reserves=3, maxpiles=-1, texts=False):

layout, s = Layout(self), self.s

Expand All @@ -553,10 +554,14 @@ def createGame(self, rows=3, cols=3, reserves=3, texts=False):
max_move=0, max_cards=52))
layout.createText(s.foundations[0], 'n')
y = layout.YM
piles = 0
for i in range(rows):
x = layout.XM
for j in range(cols):
if 0 < maxpiles <= piles:
break
s.rows.append(self.RowStack_Class(x, y, self, max_accept=1))
piles += 1
x += layout.XS
y += layout.YS
x, y = layout.XM, self.height-layout.YS
Expand Down Expand Up @@ -648,6 +653,37 @@ def createGame(self):
Elevens.createGame(self, rows=3, cols=5)


# ************************************************************************
# * Tens
# ************************************************************************

class Tens_RowStack(Elevens_RowStack):
ACCEPTED_SUM = 8


class Tens_Reserve(ReserveStack):
ACCEPTED_CARDS = (9, JACK, QUEEN, KING)

def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return False
c = cards[0]
if c.rank not in self.ACCEPTED_CARDS:
return False
for s in self.game.s.reserves:
if s.cards and s.cards[0].rank != c.rank:
return False
return True


class Tens(ElevensToo):
RowStack_Class = Tens_RowStack
Reserve_Class = Tens_Reserve

def createGame(self):
Elevens.createGame(self, rows=2, cols=7, maxpiles=13, reserves=4)


# ************************************************************************
# * Fifteens
# ************************************************************************
Expand Down Expand Up @@ -1513,3 +1549,6 @@ def fillStack(self, stack):
registerGame(GameInfo(854, Neptune, "Neptune",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_BALANCED,
altnames=('Mixtures',)))
registerGame(GameInfo(916, Tens, "Tens",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK,
altnames=('Take Ten',)))

0 comments on commit 8a1940b

Please sign in to comment.