Skip to content

Commit

Permalink
Added Deuces and Queens game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Aug 23, 2023
1 parent d00762b commit d6b6eb6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 22 deletions.
19 changes: 19 additions & 0 deletions html-src/rules/deucesandqueens.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Deuces and Queens</h1>
<p>
Two-Deck game type. 2 decks. No redeal.

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

<h3>Quick Description</h3>
<p>
Like <a href="acesandkings.html">Aces and Kings</a>, but with
three reserves, and one set of foundations builds up from two to ace,
and the other builds down from queen to king, both wrapping between
king and ace as necessary.
<p>
Additionally, building on the tableau piles is allowed. Tableau
piles are built up or down by rank, regardless of suit, also wrapping
between king and ace as necessary. But once the talon is empty, empty
tableau piles can no longer be filled.
31 changes: 15 additions & 16 deletions pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,18 @@ def _callback(gi, gt=game_type):
# Ace of Hearts, Agnes Three, Antares, Avenue, Baker's Fan,
# Baker's Spider, Bedeviled, Binding, Black Holes,
# Black Spider, California, Cascade, Club, Color Cell,
# Cornelius, Desert Fox, Deuces and Queens, Double Antares,
# Double Antarctica, Double Arctica, Double Baker's Spider,
# Double Cascade, Double Line 8, Double Majesty,
# Double Spidercells, Doublet Cell 5, Doubt, Dream Fan,
# Dumfries Cell, Falcon Wing, Fan Nine, Fanny 6, Four By Ten,
# FreeCell AK, Gaps Alter, Gaps Diff, George V,
# Grandmother's Clock, In a Frame, Inverted FreeCell, Kings,
# Klondike FreeCell, La Cabane, La Double Entente,
# Little Gazette, Magic FreeCell, Mini Gaps, Montreal,
# Napoleon at Iena, Napoleon at Waterloo, Napoleon's Guards,
# Nationale, Oasis, Opera, Ordered Suits, Osmotic FreeCell,
# Pair FreeCell, Pairs 2, Petal, Reserved Thirteens,
# Sea Spider, Sept Piles 0, Short Solitaire,
# Cornelius, Desert Fox, Double Antares, Double Antarctica,
# Double Arctica, Double Baker's Spider, Double Cascade,
# Double Line 8, Double Majesty, Double Spidercells,
# Doublet Cell 5, Doubt, Dream Fan, Dumfries Cell, Falcon Wing,
# Fan Nine, Fanny 6, Four By Ten, FreeCell AK, Gaps Alter,
# Gaps Diff, George V, Grandmother's Clock, In a Frame,
# Inverted FreeCell, Kings, Klondike FreeCell, La Cabane,
# La Double Entente, Little Gazette, Magic FreeCell, Mini Gaps,
# Montreal, Napoleon at Iena, Napoleon at Waterloo,
# Napoleon's Guards, Nationale, Oasis, Opera, Ordered Suits,
# Osmotic FreeCell, Pair FreeCell, Pairs 2, Petal,
# Reserved Thirteens, Sea Spider, Sept Piles 0, Short Solitaire,
# Simple Alternations, Smart Osmosis, Step By Step,
# Stripped FreeCell, Tarantula, Triple Dispute, Trusty Twenty,
# Two Ways 3, Up Or Down, Versailles, Vertical FreeCell,
Expand All @@ -438,7 +437,7 @@ def _callback(gi, gt=game_type):
405, 415, 416, 425, 451, 453, 461, 464, 466, 467, 476, 480,
484, 511, 512, 513, 516, 561, 610, 625, 629, 631, 638, 641,
647, 650, 655, 678, 684, 734, 751, 784, 825, 829, 834, 837,
844, 862, 867, 880, 889, 901,
844, 862, 867, 880, 889, 901, 911,
)),

# xpat2 1.06 (we have 14 out of 16 games)
Expand Down Expand Up @@ -482,7 +481,7 @@ def _callback(gi, gt=game_type):
("Peter Voke", (876,)),
("Thomas Warfield", (189, 264, 300, 320, 336, 337, 359,
415, 427, 458, 495, 496, 497, 508,
800, 814, 820, 825, 889,)),
800, 814, 820, 825, 889, 911,)),
("Mary Whitmore Jones", (421, 624,)),
)

Expand Down Expand Up @@ -566,7 +565,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, 911)) + tuple(range(11017, 11020))),
('dev', tuple(range(906, 912)) + tuple(range(11017, 11020))),
)

# deprecated - the correct way is to or a GI.GT_XXX flag
Expand Down
41 changes: 35 additions & 6 deletions pysollib/games/acesandkings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
BasicRowStack, \
OpenStack, \
RK_FoundationStack, \
StackWrapper, \
UD_RK_RowStack, \
WasteStack, \
WasteTalonStack
from pysollib.util import ACE, KING, RANKS
from pysollib.util import ACE, KING, NO_RANK, QUEEN, RANKS, \
UNLIMITED_ACCEPTS, \
UNLIMITED_CARDS


# ************************************************************************
Expand All @@ -40,11 +44,14 @@

class AcesAndKings(Game):
RowStack_Class = BasicRowStack
Foundation_Class = RK_FoundationStack

NUM_RESERVES = 2
NUM_TABLEAU = 4
FOUNDATION_SETS = ((ACE, KING),)

PLAYCARDS = 0

#
# game layout
#
Expand All @@ -54,7 +61,8 @@ def createGame(self, max_rounds=1, num_deal=1):

# set window
self.setSize(l.XM + (8.5 * l.XS), l.YM +
((2 + len(self.FOUNDATION_SETS)) * l.YS))
((2 + len(self.FOUNDATION_SETS)) * l.YS) +
(self.PLAYCARDS * l.YOFFSET))

# create stacks
x, y = 2 * l.XM, l.YM
Expand All @@ -76,8 +84,10 @@ def createGame(self, max_rounds=1, num_deal=1):

for i in self.FOUNDATION_SETS:
for j in range(4):
stack = RK_FoundationStack(x, y, self, suit=j, base_rank=i[0],
dir=1, max_cards=(13 - i[0]))
stack = self.Foundation_Class(x, y, self, suit=j,
base_rank=i[0], dir=1,
max_cards=(13 - i[0]),
mod=13)
stack.getBottomImage = stack._getReserveBottomImage
if self.preview <= 1:
stack.texts.misc = MfxCanvasText(self.canvas,
Expand All @@ -91,8 +101,10 @@ def createGame(self, max_rounds=1, num_deal=1):
x = x + l.XS
x = x + (l.XS / 2)
for j in range(4):
stack = RK_FoundationStack(x, y, self, suit=j, base_rank=i[1],
dir=-1, max_cards=(i[1] + 1))
stack = self.Foundation_Class(x, y, self, suit=j,
base_rank=i[1], dir=-1,
max_cards=(i[1] + 1),
mod=13)
stack.getBottomImage = stack._getReserveBottomImage
if self.preview <= 1:
stack.texts.misc = MfxCanvasText(self.canvas,
Expand Down Expand Up @@ -161,10 +173,27 @@ class RacingAces(AcesAndKings):
FOUNDATION_SETS = ((ACE, KING), (6, 5))


# ************************************************************************
# * Deuces and Queens
# ************************************************************************

class DeucesAndQueens(AcesAndKings):
RowStack_Class = StackWrapper(UD_RK_RowStack, max_accept=UNLIMITED_ACCEPTS,
max_cards=UNLIMITED_CARDS, mod=13,
base_rank=NO_RANK)
Foundation_Class = StackWrapper(RK_FoundationStack, max_cards=13)

NUM_RESERVES = 3
FOUNDATION_SETS = ((1, QUEEN),)
PLAYCARDS = 12


# register the game
registerGame(GameInfo(800, AcesAndKings, "Aces and Kings",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(814, AceyAndKingsley, "Acey and Kingsley",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(820, RacingAces, "Racing Aces",
GI.GT_3DECK_TYPE, 3, 0, GI.SL_BALANCED))
registerGame(GameInfo(911, DeucesAndQueens, "Deuces and Queens",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))

0 comments on commit d6b6eb6

Please sign in to comment.