Skip to content

Commit

Permalink
Add Ace of Hearts game
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Jul 5, 2024
1 parent 180f3fa commit 69394fa
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 12 deletions.
22 changes: 22 additions & 0 deletions html-src/rules/aceofhearts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h1>Ace of Hearts</h1>
<p>
One-Deck game type. 1 deck. No redeal.

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

<h3>Rules</h3>
<p>
Cards are dealt to seven piles, with an ascending number of cards
in each pile (1 in the first, 2 in the second, etc.), all face-up.
<p>
Build the tableau piles down by same suit. Any group of cards can
be moved, regardless of sequence. Only a king or a group of cards
starting with a king can be moved to an empty pile. When there
are no moves left, you can deal a card from the talon to each pile.
<p>
The single foundation is started with the ace of hearts. After the
ace of hearts is played, it is built up by rank, regardless of suit,
turning the corner from king to ace as neede. The game is won if
all cards are moved to this one foundation.
19 changes: 9 additions & 10 deletions pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,12 @@ def _callback(gi, gt=game_type):
# from XM Solitaire should be researched before being added to PySol.
#
# still missing:
# Ace of Hearts, Agnes Three, Antares, Avenue, Baker's Fan,
# Baker's Spider, Bedeviled, Binding, Black Spider,
# California, Color Cell, Cornelius, Desert Fox,
# Double Antares, Double Antarctica, Double Arctica,
# Double Baker's Spider, Double Cascade, Double Majesty,
# Double Spidercells, Doublet Cell 5, Doubt, Dream Fan,
# Dumfries Cell, Falcon Wing, Fan Nine, Four By Ten,
# Agnes Three, Antares, Avenue, Baker's Fan, Baker's Spider,
# Bedeviled, Binding, Black Spider, California, Color Cell,
# Cornelius, Desert Fox, Double Antares, Double Antarctica,
# Double Arctica, Double Baker's Spider, Double Cascade,
# Double Majesty, Double Spidercells, Doublet Cell 5, Doubt,
# Dream Fan, Dumfries Cell, Falcon Wing, Fan Nine, 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,
Expand All @@ -466,7 +465,7 @@ def _callback(gi, gt=game_type):
476, 480, 484, 511, 512, 513, 516, 561, 610, 613, 625, 629,
631, 638, 641, 647, 650, 655, 678, 684, 702, 734, 751, 784,
825, 829, 834, 837, 844, 862, 867, 880, 889, 901, 911, 933,
941, 947, 953
941, 947, 953, 966
)),

# xpat2 1.06 (we have 14 out of 16 games)
Expand Down Expand Up @@ -514,7 +513,7 @@ def _callback(gi, gt=game_type):
("Thomas Warfield", (189, 264, 300, 320, 336, 337, 359,
415, 427, 458, 495, 496, 497, 508,
800, 814, 820, 825, 889, 911, 926,
941)),
941, 966)),
("Mary Whitmore Jones", (421, 624,)),
("Jan Wolter", (917, 939, 946, 963,)),
)
Expand Down Expand Up @@ -604,7 +603,7 @@ def _callback(gi, gt=game_type):
tuple(range(13168, 13170)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
('dev', tuple(range(961, 966))),
('dev', tuple(range(961, 967))),
)

# deprecated - the correct way is to or a GI.GT_XXX flag
Expand Down
55 changes: 53 additions & 2 deletions pysollib/games/gypsy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
InitialDealTalonStack, \
KingAC_RowStack, \
OpenStack, \
RK_FoundationStack, \
ReserveStack, \
SS_FoundationStack, \
SS_RowStack, \
Expand All @@ -45,8 +46,9 @@
TalonStack, \
WasteStack, \
WasteTalonStack, \
Yukon_AC_RowStack
from pysollib.util import ACE, ANY_SUIT, KING, UNLIMITED_ACCEPTS, \
Yukon_AC_RowStack, \
Yukon_SS_RowStack
from pysollib.util import ACE, ANY_SUIT, HEART, KING, UNLIMITED_ACCEPTS, \
UNLIMITED_MOVES

# ************************************************************************
Expand Down Expand Up @@ -1002,6 +1004,53 @@ def startGame(self):
self._startAndDealRow()


# ************************************************************************
# * Ace of Hearts
# ************************************************************************

class AceOfHearts_Foundation(RK_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not self.cards:
return cards[0].suit == HEART and cards[0].rank == ACE
return RK_FoundationStack.acceptsCards(self, from_stack, cards)

def getBottomImage(self):
return self.game.app.images.getSuitBottom(HEART)


class AceOfHearts(Game):
Hint_Class = YukonType_Hint

def createGame(self, **layout):
# create layout
l, s = Layout(self), self.s
kwdefault(layout, rows=7, waste=0, texts=1, playcards=30)
Layout.klondikeLayout(l, **layout)
self.setSize(l.size[0], l.size[1])
# create stacks
s.talon = DealRowTalonStack(l.s.talon.x, l.s.talon.y, self)
if l.s.waste:
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self)
r = l.s.foundations[3]
s.foundations.append(
AceOfHearts_Foundation(r.x, r.y, self, suit=HEART,
max_cards=52, mod=13))
for r in l.s.rows:
s.rows.append(Yukon_SS_RowStack(r.x, r.y, self,
base_rank=KING))
# default
l.defaultAll()

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

shallHighlightMatch = Game._shallHighlightMatch_SS


# register the game
registerGame(GameInfo(1, Gypsy, "Gypsy",
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
Expand Down Expand Up @@ -1088,3 +1137,5 @@ def startGame(self):
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(912, SmallTriangle, "Small Triangle",
GI.GT_GYPSY, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(966, AceOfHearts, "Ace of Hearts",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_SKILL))

0 comments on commit 69394fa

Please sign in to comment.