From fbcd5d4ec897a09676ec69f052dc1c572a98c515 Mon Sep 17 00:00:00 2001 From: Joe R Date: Tue, 26 Jul 2022 18:56:21 -0400 Subject: [PATCH] Combined code for Double Line and Grandfather, as they're almost identical games. --- html-src/rules/doubleline.html | 12 ++++++ pysollib/games/auldlangsyne.py | 23 +++++++++--- pysollib/games/camelot.py | 69 +--------------------------------- 3 files changed, 30 insertions(+), 74 deletions(-) create mode 100644 html-src/rules/doubleline.html diff --git a/html-src/rules/doubleline.html b/html-src/rules/doubleline.html new file mode 100644 index 00000000..de073bce --- /dev/null +++ b/html-src/rules/doubleline.html @@ -0,0 +1,12 @@ +

Double Line

+

+Numerica type. 2 decks. No redeal. + +

Object

+

+Move all cards to the foundations. + +

Quick Description

+

+Just like Grandfather, +but with no redeal. diff --git a/pysollib/games/auldlangsyne.py b/pysollib/games/auldlangsyne.py index 663cebe1..4258d6a8 100644 --- a/pysollib/games/auldlangsyne.py +++ b/pysollib/games/auldlangsyne.py @@ -367,6 +367,8 @@ class Primrose(Interregnum): # ************************************************************************ # * Colorado +# * Double Line +# * Grandfather # ************************************************************************ class Colorado_RowStack(OpenStack): @@ -396,7 +398,7 @@ class Colorado(Game): roff = l.YOFFSET * (tableau_max - 1) self.setSize(l.XM + 10 * l.XS, - l.YM + 4 * l.YS + l.TEXT_HEIGHT + (2 * roff)) + l.YM + 4 * l.YS + (2 * l.TEXT_HEIGHT) + (2 * roff)) # create stacks x, y, = l.XS, l.YM @@ -422,13 +424,14 @@ class Colorado(Game): x += l.XS y += l.YS + roff - x, y = l.XM + 9 * l.XS, self.height - l.YS + x, y = l.XM + 9 * l.XS, self.height - l.YS - l.TEXT_HEIGHT s.talon = WasteTalonStack(x, y, self, max_rounds=max_rounds) - l.createText(s.talon, "n") + l.createText(s.talon, "s") x -= l.XS s.waste = WasteStack(x, y, self, max_cards=waste_max) + l.createText(s.waste, "s") if max_rounds > 1: - l.createRoundText(s.waste, "s") + l.createRoundText(s.talon, "n") # define stack-groups l.defaultStackGroups() @@ -460,8 +463,8 @@ class Grandfather_RowStack(BasicRowStack): class Grandfather(Colorado): RowStack_Class = Grandfather_RowStack - def createGame(self): - Colorado.createGame(self, waste_max=999999, max_rounds=2, + def createGame(self, max_rounds=2): + Colorado.createGame(self, waste_max=999999, max_rounds=max_rounds, tableau_max=2) def startGame(self): @@ -473,6 +476,12 @@ class Grandfather(Colorado): return cards +class DoubleLine(Grandfather): + + def createGame(self): + Grandfather.createGame(self, max_rounds=1) + + # ************************************************************************ # * Amazons # ************************************************************************ @@ -664,5 +673,7 @@ registerGame(GameInfo(636, StrategyPlus, "Strategy +", GI.GT_NUMERICA, 1, 0, GI.SL_SKILL)) registerGame(GameInfo(688, Formic, "Formic", GI.GT_NUMERICA, 1, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(702, DoubleLine, "Double Line", + GI.GT_NUMERICA, 2, 0, GI.SL_BALANCED)) registerGame(GameInfo(853, Grandfather, "Grandfather", GI.GT_NUMERICA, 2, 1, GI.SL_BALANCED)) diff --git a/pysollib/games/camelot.py b/pysollib/games/camelot.py index 8c418f47..d5beff75 100644 --- a/pysollib/games/camelot.py +++ b/pysollib/games/camelot.py @@ -39,7 +39,7 @@ from pysollib.stack import \ StackWrapper, \ WasteStack, \ WasteTalonStack -from pysollib.util import ACE, ANY_RANK, ANY_SUIT, JACK, KING, NO_RANK, \ +from pysollib.util import ACE, ANY_RANK, ANY_SUIT, JACK, KING, \ QUEEN, RANKS, \ UNLIMITED_CARDS # ************************************************************************ @@ -605,71 +605,6 @@ class GrandmammasPatience(Game): p.dump(self.base_rank) -# ************************************************************************ -# * Double Line -# ************************************************************************ - -class DoubleLine_RowStack(BasicRowStack): - def acceptsCards(self, from_stack, cards): - if not BasicRowStack.acceptsCards(self, from_stack, cards): - return False - # this stack accepts any one card from the Waste pile - return from_stack is self.game.s.waste - - def getHelp(self): - return _('Tableau. Build regardless of rank and suit.') - - -class DoubleLine(Game): - - def createGame(self): - - l, s = Layout(self), self.s - h0 = l.YS+3*l.YOFFSET - self.setSize(l.XM+10*l.XS, l.YM+l.YS+l.TEXT_HEIGHT+2*h0) - - x, y = l.XM, l.YM - s.talon = WasteTalonStack(x, y, self, max_rounds=1) - l.createText(s.talon, 's') - x += l.XS - s.waste = WasteStack(x, y, self) - l.createText(s.waste, 's') - - x += l.XS - for i in range(4): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4)) - x += l.XS - for i in range(4): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i, - base_rank=KING, dir=-1)) - x += l.XS - - y = l.YM+l.YS+l.TEXT_HEIGHT - for i in range(2): - x = l.XM - for j in range(10): - s.rows.append(DoubleLine_RowStack(x, y, self, max_cards=2, - max_move=1, max_accept=1, base_rank=NO_RANK)) - x += l.XS - y += h0 - - l.defaultStackGroups() - - def startGame(self): - self.startDealSample() - self.s.talon.dealRow() - self.s.talon.dealCards() - - def fillStack(self, stack): - if stack in self.s.rows and not stack.cards: - old_state = self.enterState(self.S_FILL) - if not self.s.waste.cards: - self.s.talon.dealCards() - if self.s.waste.cards: - self.s.waste.moveMove(1, stack) - self.leaveState(old_state) - - # register the game registerGame(GameInfo(280, Camelot, "Camelot", GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED, @@ -683,5 +618,3 @@ registerGame(GameInfo(623, PrincessPatience, "Princess Patience", GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED)) registerGame(GameInfo(622, GrandmammasPatience, "Grandmamma's Patience", GI.GT_NUMERICA, 2, 0, GI.SL_MOSTLY_SKILL)) -registerGame(GameInfo(702, DoubleLine, "Double Line", - GI.GT_NUMERICA, 2, 0, GI.SL_BALANCED))