mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ 4 new games
git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@152 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
c5e893e9bb
commit
c47a82f880
4 changed files with 336 additions and 3 deletions
|
@ -386,6 +386,7 @@ class FourLeafClovers_Foundation(AbstractFoundationStack):
|
|||
def getHelp(self):
|
||||
return _('Foundation. Build up regardless of suit.')
|
||||
|
||||
|
||||
class FourLeafClovers(Game):
|
||||
|
||||
Hint_Class = CautiousDefaultHint
|
||||
|
@ -432,8 +433,6 @@ class FourLeafClovers(Game):
|
|||
# // All in a Row
|
||||
# ************************************************************************/
|
||||
|
||||
|
||||
|
||||
class AllInARow(BlackHole):
|
||||
|
||||
def createGame(self):
|
||||
|
@ -677,6 +676,171 @@ class Waterfall(Game):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Basis
|
||||
# ************************************************************************/
|
||||
|
||||
class Basis_RowStack(BasicRowStack):
|
||||
clickHandler = BasicRowStack.doubleclickHandler
|
||||
|
||||
|
||||
class Basis(Game):
|
||||
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+6*l.XS, l.YM+4*l.YS)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
s.talon = TalonStack(x, y, self)
|
||||
l.createText(s.talon, 'ne')
|
||||
|
||||
x, y = l.XM+2*l.XS, l.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
|
||||
base_rank=ANY_RANK, mod=13))
|
||||
x += l.XS
|
||||
|
||||
y = l.YM+l.YS
|
||||
for i in range(3):
|
||||
x = l.XM
|
||||
for j in range(6):
|
||||
s.rows.append(Basis_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
y += l.YS
|
||||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
self.s.talon.flipMove()
|
||||
|
||||
def fillStack(self, stack):
|
||||
if stack in self.s.rows and not stack.cards:
|
||||
if self.s.talon.cards:
|
||||
old_state = self.enterState(self.S_FILL)
|
||||
if not self.s.talon.cards[-1].face_up:
|
||||
self.s.talon.flipMove()
|
||||
self.s.talon.moveMove(1, stack)
|
||||
self.leaveState(old_state)
|
||||
|
||||
def getAutoStacks(self, event=None):
|
||||
if event is None:
|
||||
# disable auto drop - this would ruin the whole gameplay
|
||||
return ((), (), self.sg.dropstacks)
|
||||
else:
|
||||
# rightclickHandler
|
||||
return ((), self.sg.dropstacks, self.sg.dropstacks)
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Devil's Solitaire
|
||||
# ************************************************************************/
|
||||
|
||||
class DevilsSolitaire_Foundation(RK_FoundationStack):
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
|
||||
return False
|
||||
if self.cards:
|
||||
return True
|
||||
if self.game.s.reserves[0].cards:
|
||||
c = self.game.s.reserves[0].cards[-1]
|
||||
return (c.rank+1) % 13 == cards[-1].rank
|
||||
return True
|
||||
|
||||
|
||||
class DevilsSolitaire_WasteStack(WasteStack):
|
||||
clickHandler = WasteStack.doubleclickHandler
|
||||
|
||||
|
||||
class DevilsSolitaire(Game):
|
||||
|
||||
def createGame(self):
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+9*l.XS, l.YM+3*l.YS+7*l.YOFFSET+2*l.TEXT_HEIGHT)
|
||||
|
||||
x, y = l.XM+4*l.XS, l.YM
|
||||
stack = DevilsSolitaire_Foundation(x, y, self,
|
||||
suit=ANY_SUIT, base_rank=ANY_RANK, mod=13)
|
||||
tx, ty, ta, tf = l.getTextAttr(stack, 'nw')
|
||||
font = self.app.getFont('canvas_default')
|
||||
stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
|
||||
anchor=ta, font=font)
|
||||
s.foundations.append(stack)
|
||||
|
||||
x, y = self.width-l.XS, l.YM
|
||||
stack = AbstractFoundationStack(x, y, self,
|
||||
suit=ANY_SUIT, max_move=0, max_cards=104,
|
||||
max_accept=0, base_rank=ANY_RANK)
|
||||
l.createText(stack, 'nw')
|
||||
s.foundations.append(stack)
|
||||
|
||||
x, y = l.XM, l.YM+l.YS
|
||||
for i in range(4):
|
||||
s.rows.append(Basis_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
x += l.XS
|
||||
for i in range(4):
|
||||
s.rows.append(Basis_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
|
||||
x, y = l.XM+4*l.XS, l.YM+l.YS
|
||||
stack = OpenStack(x, y, self)
|
||||
stack.CARD_YOFFSET = l.YOFFSET
|
||||
s.reserves.append(stack)
|
||||
|
||||
x, y = l.XM+4.5*l.XS, self.height-l.YS
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=3)
|
||||
l.createText(s.talon, 'n')
|
||||
tx, ty, ta, tf = l.getTextAttr(s.talon, "nn")
|
||||
font = self.app.getFont("canvas_default")
|
||||
s.talon.texts.rounds = MfxCanvasText(self.canvas, tx, ty-l.TEXT_MARGIN,
|
||||
anchor=ta, font=font)
|
||||
|
||||
x -= l.XS
|
||||
s.waste = DevilsSolitaire_WasteStack(x, y, self)
|
||||
l.createText(s.waste, 'n')
|
||||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
for i in range(8):
|
||||
self.s.talon.dealRow(rows=self.s.reserves, frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
self.s.talon.dealCards()
|
||||
|
||||
def fillStack(self, stack):
|
||||
old_state = self.enterState(self.S_FILL)
|
||||
if stack in self.s.rows and not stack.cards:
|
||||
if not self.s.waste.cards:
|
||||
self.s.talon.dealCards()
|
||||
if self.s.waste.cards:
|
||||
self.s.waste.moveMove(1, stack)
|
||||
f0 = self.s.foundations[0]
|
||||
if len(f0.cards) == 12:
|
||||
self.moveMove(1, self.s.reserves[0], f0, frames=4)
|
||||
f1 = self.s.foundations[1]
|
||||
for i in range(13):
|
||||
self.moveMove(1, f0, f1, frames=4)
|
||||
self.leaveState(old_state)
|
||||
|
||||
def updateText(self):
|
||||
if self.preview > 1:
|
||||
return
|
||||
f = self.s.foundations[0]
|
||||
r = self.s.reserves[0]
|
||||
if not r.cards:
|
||||
t = ''
|
||||
else:
|
||||
c = r.cards[-1]
|
||||
t = RANKS[(c.rank+1) % 13]
|
||||
f.texts.misc.config(text=t)
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(36, Golf, "Golf",
|
||||
GI.GT_GOLF, 1, 0, GI.SL_BALANCED))
|
||||
|
@ -705,4 +869,8 @@ registerGame(GameInfo(662, DoubleDolphin, "Double Dolphin",
|
|||
GI.GT_GOLF | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(709, Waterfall, "Waterfall",
|
||||
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(720, Basis, "Basis",
|
||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))
|
||||
registerGame(GameInfo(723, DevilsSolitaire, "Devil's Solitaire",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
|
||||
|
||||
|
|
|
@ -880,6 +880,83 @@ class LockedCards(Game):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Thirty
|
||||
# ************************************************************************/
|
||||
|
||||
class Thirty_RowStack(BasicRowStack):
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not BasicRowStack.acceptsCards(self, from_stack, cards):
|
||||
return False
|
||||
if self.cards:
|
||||
# check the rank - an ACE equals a Six
|
||||
rank = self.cards[-1].rank
|
||||
if rank == ACE:
|
||||
rank = 5
|
||||
if (rank + self.cap.dir) % self.cap.mod != cards[0].rank:
|
||||
return False
|
||||
return True
|
||||
|
||||
def canMoveCards(self, cards):
|
||||
if not BasicRowStack.canMoveCards(self, cards):
|
||||
return False
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if c1.suit != c2.suit:
|
||||
return False
|
||||
# check the rank - an ACE equals a Six
|
||||
rank = c1.rank
|
||||
if rank == ACE:
|
||||
rank = 5
|
||||
if (rank + self.cap.dir) % self.cap.mod != c2.rank:
|
||||
return False
|
||||
c1 = c2
|
||||
return True
|
||||
|
||||
|
||||
class Thirty(Game):
|
||||
|
||||
def createGame(self):
|
||||
|
||||
l, s = Layout(self), self.s
|
||||
self.setSize(l.XM+7*l.XS, l.YM+2*l.YS+12*l.YOFFSET)
|
||||
|
||||
x, y = l.XM, l.YM
|
||||
for i in range(2):
|
||||
s.reserves.append(OpenStack(x, y, self))
|
||||
x += l.XS
|
||||
|
||||
x, y = l.XM+3*l.XS, l.YM
|
||||
for i in range(4):
|
||||
s.foundations.append(DieRussische_Foundation(x, y, self,
|
||||
suit=i, max_cards=8))
|
||||
x += l.XS
|
||||
|
||||
x, y = l.XM+l.XS/2, l.YM+l.YS
|
||||
for i in range(6):
|
||||
s.rows.append(Thirty_RowStack(x, y, self,
|
||||
max_move=UNLIMITED_MOVES,
|
||||
max_accept=UNLIMITED_ACCEPTS))
|
||||
x += l.XS
|
||||
|
||||
x, y = self.width-l.XS, self.height-l.YS
|
||||
s.talon = InitialDealTalonStack(x, y, self)
|
||||
|
||||
l.defaultAll()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
for i in range(4):
|
||||
self.s.talon.dealRow(frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
self.s.talon.dealRow(rows=self.s.reserves)
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||
getQuickPlayScore = Game._getSpiderQuickPlayScore
|
||||
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(1, Gypsy, "Gypsy",
|
||||
|
@ -949,3 +1026,6 @@ registerGame(GameInfo(712, Leprechaun, "Leprechaun",
|
|||
GI.GT_GYPSY | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(718, LockedCards, "Locked Cards",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(721, Thirty, "Thirty",
|
||||
GI.GT_1DECK_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL,
|
||||
ranks=(0, 6, 7, 8, 9, 10, 11, 12)))
|
||||
|
|
|
@ -767,6 +767,8 @@ class AnnoDomini(Numerica):
|
|||
|
||||
# /***********************************************************************
|
||||
# // Circle Nine
|
||||
# // Measure
|
||||
# // Double Measure
|
||||
# ************************************************************************/
|
||||
|
||||
class CircleNine_RowStack(BasicRowStack):
|
||||
|
|
|
@ -32,6 +32,9 @@ from pysollib.stack import *
|
|||
from pysollib.game import Game
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||
from pysollib.pysoltk import MfxCanvasText
|
||||
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Zodiac
|
||||
|
@ -54,6 +57,7 @@ class Zodiac_RowStack(UD_SS_RowStack):
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
class Zodiac_ReserveStack(ReserveStack):
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not ReserveStack.acceptsCards(self, from_stack, cards):
|
||||
|
@ -63,7 +67,6 @@ class Zodiac_ReserveStack(ReserveStack):
|
|||
return True
|
||||
|
||||
|
||||
|
||||
class Zodiac(Game):
|
||||
|
||||
def createGame(self):
|
||||
|
@ -120,6 +123,86 @@ class Zodiac(Game):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_SS
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
# // Twelve Sleeping Maids
|
||||
# ************************************************************************/
|
||||
|
||||
class TwelveSleepingMaids_Reserve(OpenStack):
|
||||
def canFlipCard(self):
|
||||
if not OpenStack.canFlipCard(self):
|
||||
return False
|
||||
for s in self.game.s.rows:
|
||||
if not s.cards:
|
||||
break
|
||||
else:
|
||||
return False
|
||||
i = list(self.game.s.reserves).index(self)
|
||||
if i == 0:
|
||||
return True
|
||||
if self.game.s.reserves[i-1].cards:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class TwelveSleepingMaids(Game):
|
||||
|
||||
def createGame(self):
|
||||
|
||||
# create layout
|
||||
l, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
self.setSize(l.XM+12*l.XS, l.YM+3*l.YS+14*l.YOFFSET)
|
||||
|
||||
# create stacks
|
||||
x, y = l.XM, l.YM
|
||||
for i in range(12):
|
||||
stack = TwelveSleepingMaids_Reserve(x, y, self)
|
||||
stack.CARD_YOFFSET = l.YOFFSET
|
||||
s.reserves.append(stack)
|
||||
x += l.XS
|
||||
|
||||
x, y = l.XM+2*l.XS, l.YM+l.YS+3*l.YOFFSET
|
||||
for i in range(8):
|
||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=i/2,
|
||||
base_rank=KING, mod=13))
|
||||
x += l.XS
|
||||
|
||||
x, y = l.XM+2*l.XS, l.YM+2*l.YS+3*l.YOFFSET
|
||||
for i in range(8):
|
||||
s.rows.append(SS_RowStack(x, y, self))
|
||||
x += l.XS
|
||||
|
||||
x, y = self.width-l.XS, self.height-l.YS
|
||||
s.talon = WasteTalonStack(x, y, self, max_rounds=3)
|
||||
l.createText(s.talon, 'n')
|
||||
tx, ty, ta, tf = l.getTextAttr(s.talon, "nn")
|
||||
font = self.app.getFont("canvas_default")
|
||||
s.talon.texts.rounds = MfxCanvasText(self.canvas, tx, ty-l.TEXT_MARGIN,
|
||||
anchor=ta, font=font)
|
||||
|
||||
x -= l.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
l.createText(s.waste, 'n')
|
||||
|
||||
# define stack-groups
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
for i in range(4):
|
||||
self.s.talon.dealRow(rows=self.s.reserves, flip=0, frames=0)
|
||||
self.startDealSample()
|
||||
self.s.talon.dealRow()
|
||||
self.s.talon.dealCards()
|
||||
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_SS
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(467, Zodiac, "Zodiac",
|
||||
GI.GT_2DECK_TYPE, 2, -1, GI.SL_BALANCED))
|
||||
registerGame(GameInfo(722, TwelveSleepingMaids, "Twelve Sleeping Maids",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
|
||||
|
|
Loading…
Add table
Reference in a new issue