1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Combined code for Double Line and Grandfather, as they're almost identical games.

This commit is contained in:
Joe R 2022-07-26 18:56:21 -04:00
parent 1d290d1ed1
commit fbcd5d4ec8
3 changed files with 30 additions and 74 deletions

View file

@ -0,0 +1,12 @@
<h1>Double Line</h1>
<p>
Numerica type. 2 decks. No redeal.
<h3>Object</h3>
<p>
Move all cards to the foundations.
<h3>Quick Description</h3>
<p>
Just like <a href="grandfather.html">Grandfather</a>,
but with no redeal.

View file

@ -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))

View file

@ -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))