diff --git a/html-src/rules/petal.html b/html-src/rules/petal.html new file mode 100644 index 000000000..3e8092e87 --- /dev/null +++ b/html-src/rules/petal.html @@ -0,0 +1,15 @@ +

Petal

+

+FreeCell type. 1 deck. No redeal. + +

Object

+

+Move all cards to the foundations. + +

Quick Description

+

+Like FreeCell, but four cards of the same +rank are dealt to the foundations at the start, and the foundations +are built up from that rank, turning the corner from king to ace as +necessary. Also, a cards is dealt to each of the four free cells at +the start of the game. diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index e23c8877e..5682a333e 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -450,7 +450,7 @@ def _callback(gi, gt=game_type): # Little Gazette, Magic FreeCell, Mini Gaps, Montreal, # Napoleon at Iena, Napoleon at Waterloo, Napoleon's Guards, # Oasis, Opera, Ordered Suits, Osmotic FreeCell, Pair FreeCell, - # Pairs 2, Petal, Reserved Thirteens, Sea Spider, Sept Piles 0, + # Pairs 2, 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, @@ -466,7 +466,7 @@ def _callback(gi, gt=game_type): 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 + 947, 953 )), # xpat2 1.06 (we have 14 out of 16 games) @@ -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, 953)) + tuple(range(11017, 11020)) + + ('dev', tuple(range(906, 954)) + tuple(range(11017, 11020)) + tuple(range(5600, 5624)) + tuple(range(18000, 18005)) + tuple(range(19000, 19012)) + tuple(range(22303, 22311)) + tuple(range(22353, 22361))), diff --git a/pysollib/games/freecell.py b/pysollib/games/freecell.py index eb2affc5d..798ce3b11 100644 --- a/pysollib/games/freecell.py +++ b/pysollib/games/freecell.py @@ -122,6 +122,51 @@ def startGame(self): self.s.talon.dealRow(rows=self.s.reserves) +# ************************************************************************ +# * Petal +# ************************************************************************ + +class Petal(FreeCell): + Foundation_Class = StackWrapper(SS_FoundationStack, mod=13) + + def _shuffleHook(self, cards): + # move base cards to top of the Talon (i.e. first cards to be dealt) + return self._shuffleHookMoveToTop( + cards, + lambda c, rank=cards[-1].rank: (c.rank == rank, 0)) + + def _updateStacks(self): + for s in self.s.foundations: + s.cap.base_rank = self.base_card.rank + + def startGame(self): + self.base_card = self.s.talon.cards[-4] + self._updateStacks() + # deal base cards to Foundations + for i in range(4): + c = self.s.talon.getCard() + assert c.rank == self.base_card.rank + to_stack = self.s.foundations[c.suit * self.gameinfo.decks] + self.flipMove(self.s.talon) + self.moveMove(1, self.s.talon, to_stack, frames=0) + self._startDealNumRows(4) + self.s.talon.dealRow() + r = self.s.rows + self.s.talon.dealRow(rows=r[:4]) + self.s.talon.dealRow(rows=self.s.reserves) + + def _restoreGameHook(self, game): + self.base_card = self.cards[game.loadinfo.base_card_id] + self._updateStacks() + + def _loadGameHook(self, p): + self.loadinfo.addattr(base_card_id=None) # register extra load var. + self.loadinfo.base_card_id = p.load() + + def _saveGameHook(self, p): + p.dump(self.base_card.id) + + # ************************************************************************ # * Challenge FreeCell # * Super Challenge FreeCell @@ -715,3 +760,5 @@ def createGame(self): GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(813, DoubleFreecellTd, "Double FreeCell (Traditional)", GI.GT_FREECELL | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(953, Petal, "Petal", + GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))