Skip to content

Commit

Permalink
Added Wildcards game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Mar 7, 2024
1 parent 6c79c25 commit 2dfca42
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
24 changes: 24 additions & 0 deletions html-src/rules/wildcards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h1>Wildcards</h1>
<p>
Beleaguered Castle type. 1 joker deck. No redeal.

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

<h3>Rules</h3>
<p>
Cards are dealt to ten tableau piles, with the first pile
containing one card, the second containing two, and so on, up
until the last two piles containing nine cards.
<p>
Tableau piles are built down by alternating colors, and cards
can be moved between tableau piles one at a time. Foundations
are built up by suit, starting from aces.
<p>
There are two jokers in the layout, which are wild cards. Any
card can be played on a joker, and a joker can be played on any
pile. Jokers can be moved to a fifth joker foundation, but only
after all other cards have been moved.
<p>
The game is won if all cards are moved to the foundations.
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,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, 954)) + tuple(range(11017, 11020)) +
('dev', tuple(range(906, 955)) + tuple(range(11017, 11020)) +
tuple(range(5600, 5624)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
Expand Down
41 changes: 41 additions & 0 deletions pysollib/games/klondike.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,43 @@ def redealCards(self):
self.s.talon.dealRowAvail(rows=self.s.rows[n:], frames=4)
n += 1

# ************************************************************************
# * Wildcards
# ************************************************************************


class Wildcards_RowStack(SuperMoveAC_RowStack):
def acceptsCards(self, from_stack, cards):
if not self.basicAcceptsCards(from_stack, cards):
return 0
stackcards = self.cards
if stackcards:
if (stackcards[-1].suit == 4 or cards[0].suit == 4):
return 1
return AC_RowStack.acceptsCards(self, from_stack, cards)


class Wildcards_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if self.cap.suit == 4 and cards[0].suit == 4:
for s in self.game.s.foundations[:3]:
if len(s.cards) != 13:
return 0
return 1
return SS_FoundationStack.acceptsCards(self, from_stack, cards)


class Wildcards(Somerset):
RowStack_Class = Wildcards_RowStack
Foundation_Class = Wildcards_Foundation

def startGame(self):
for i in range(7):
self.s.talon.dealRow(rows=self.s.rows[i:], frames=0)
self.startDealSample()
self.s.talon.dealRow(rows=self.s.rows[7:])
self.s.talon.dealRow(rows=self.s.rows[8:])

# ************************************************************************
# * Canister
# * American Canister
Expand Down Expand Up @@ -1727,3 +1764,7 @@ def startGame(self):
GI.GT_KLONDIKE, 1, -1, GI.SL_BALANCED))
registerGame(GameInfo(930, KlondikeTerritory, "Klondike Territory",
GI.GT_RAGLAN, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(954, Wildcards, "Wildcards",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL,
subcategory=GI.GS_JOKER_DECK, trumps=list(range(2))))
3 changes: 2 additions & 1 deletion pysollib/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def _check(self, cs):
if s == CSI.TYPE_FRENCH:
if cs.subtype == 1:
cs.trumps = list(range(2))
cs.nbottoms = 8
elif s == CSI.TYPE_HANAFUDA:
cs.nbottoms = 15
elif s == CSI.TYPE_TAROCK:
Expand Down Expand Up @@ -561,7 +562,7 @@ def _check(self, cs):
cs.nshadows = 0
cs.trumps = list(range(cs.ncards))
elif s == CSI.TYPE_ISHIDO:
cs.nbottoms = 0
cs.nbottoms = 1
cs.nletters = 0
cs.nshadows = 0
else:
Expand Down

0 comments on commit 2dfca42

Please sign in to comment.