From 9928cd87906cbf6e055a0dfe6addb6a016e6cdb1 Mon Sep 17 00:00:00 2001 From: Joe R Date: Mon, 20 Dec 2021 20:41:26 -0500 Subject: [PATCH] Added Pyramid Dozen game. --- html-src/rules/giza.html | 19 +++++++++++ html-src/rules/pyramiddozen.html | 14 +++++++++ pysollib/gamedb.py | 2 +- pysollib/games/pyramid.py | 54 ++++++++++++++++++++++++++++++-- 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 html-src/rules/giza.html create mode 100644 html-src/rules/pyramiddozen.html diff --git a/html-src/rules/giza.html b/html-src/rules/giza.html new file mode 100644 index 00000000..9bd41a16 --- /dev/null +++ b/html-src/rules/giza.html @@ -0,0 +1,19 @@ +

Giza

+

+Pairing game type. 1 deck. No redeal. + +

Object

+

+Fill all of the foundations. + +

Quick Description

+

+Like Pyramid, +but there is no talon. Instead, all of the remaining +cards are dealt to eight reserve piles of three cards +each, the top of which can be paired with cards in the +pyramid or on top of other reserves. +

Notes

+

+Giza is an open variation of Pyramid invented by Michael +Keller. diff --git a/html-src/rules/pyramiddozen.html b/html-src/rules/pyramiddozen.html new file mode 100644 index 00000000..cb6d3fbb --- /dev/null +++ b/html-src/rules/pyramiddozen.html @@ -0,0 +1,14 @@ +

Pyramid Dozen

+

+Pairing game type. 1 deck. No redeal. + +

Object

+

+Fill all of the foundations. + +

Quick Description

+

+Like Giza, +but cards are removed if they total 12. Kings and +queens are paired off together. Also, there are only +six reserves, with four cards each. diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index 102c7ae0..d6faa053 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -520,7 +520,7 @@ class GI: ('fc-2.12', tuple(range(774, 811)) + (16681,) + tuple(range(22217, 22219))), ('fc-2.14', tuple(range(811, 827))), - ('fc-2.16', tuple(range(827, 846))) + ('fc-2.16', tuple(range(827, 847))) ) # deprecated - the correct way is to or a GI.GT_XXX flag diff --git a/pysollib/games/pyramid.py b/pysollib/games/pyramid.py index 537f4f15..863d7b05 100644 --- a/pysollib/games/pyramid.py +++ b/pysollib/games/pyramid.py @@ -233,7 +233,8 @@ class Pyramid(Game): n += 1 return rows - def createGame(self, pyramid_len=7, reserves=0, waste=True, texts=True): + def createGame(self, pyramid_len=7, reserves=0, waste=True, + texts=True, playcards=2): # create layout layout, s = Layout(self), self.s @@ -243,7 +244,7 @@ class Pyramid(Game): h = layout.YM + layout.YS + \ (pyramid_len-1)*layout.YS//self.PYRAMID_Y_FACTOR if reserves: - h += layout.YS+2*layout.YOFFSET + h += layout.YS + playcards * layout.YOFFSET self.setSize(w, h) # create stacks @@ -334,6 +335,53 @@ class Giza(Pyramid): self.s.talon.dealRow(frames=4) +# ************************************************************************ +# * Pyramid Dozen +# ************************************************************************ + +class PyramidDozen_StackMethods(): + def acceptsCards(self, from_stack, cards): + if self.basicIsBlocked(): + return False + if from_stack is self or not self.cards or len(cards) != 1: + return False + c = self.cards[-1] + return c.face_up and cards[0].face_up and \ + (cards[0].rank + c.rank == 10 or cards[0].rank + c.rank == 23) + + def _dropKingClickHandler(self, event): + return 0 + + +class PyramidDozen_RowStack(PyramidDozen_StackMethods, Pyramid_RowStack): + pass + + +class PyramidDozen_Reserve(PyramidDozen_StackMethods, Giza_Reserve): + pass + + +class PyramidDozen_Foundation(AbstractFoundationStack): + def acceptsCards(self, from_stack, cards): + return False + + +class PyramidDozen(Giza): + RowStack_Class = PyramidDozen_RowStack + Reserve_Class = StackWrapper(PyramidDozen_Reserve, max_accept=1) + Foundation_Class = PyramidDozen_Foundation + + def createGame(self): + Pyramid.createGame(self, reserves=6, waste=False, texts=False, + playcards=3) + + def startGame(self): + for i in range(4): + self.s.talon.dealRow(rows=self.s.reserves, frames=0) + self.startDealSample() + self.s.talon.dealRow(frames=4) + + # ************************************************************************ # * Thirteen # * FIXME: UNFINISHED @@ -1422,3 +1470,5 @@ registerGame(GameInfo(796, Exit, "Exit", registerGame(GameInfo(802, TripleAlliance2Decks, "Triple Alliance (2 decks)", GI.GT_2DECK_TYPE | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(846, PyramidDozen, "Pyramid Dozen", + GI.GT_PAIRING_TYPE | GI.GT_OPEN, 1, 0, GI.SL_BALANCED))