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

+ 4 new games

* minor improvements


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@188 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2007-07-30 21:22:27 +00:00
parent 13358ce72d
commit cedbb8f575
38 changed files with 514 additions and 285 deletions

View file

@ -1006,7 +1006,7 @@ class Game:
def areYouSure(self, title=None, text=None, confirm=-1, default=0):
if self.preview:
return 1
return True
if confirm < 0:
confirm = self.app.opt.confirm
if confirm:
@ -1017,8 +1017,8 @@ class Game:
bitmap="question",
strings=(_("&OK"), _("&Cancel")))
if d.status != 0 or d.button != 0:
return 0
return 1
return False
return True
def notYetImplemented(self):
# don't used
@ -1166,15 +1166,18 @@ class Game:
shrink_dy = 0
elif dest_x == 0:
# move to top/bottom waste
return False
ascent_dx, ascent_dy = 0, 0
## min_size = h/10
## shrink_dx = 0
## shrink_dy = (h-min_size) / (frames-1)
min_size = w/10
shrink_dx = (w-min_size) / (frames-1)
shrink_dy = 0
if 0:
ascent_dx, ascent_dy = 0, h/10.0/frames
min_size = w/10
shrink_dx = (w-min_size) / (frames-1)
shrink_dy = 0
elif 0:
ascent_dx, ascent_dy = 0, 0
min_size = h/10
shrink_dx = 0
shrink_dy = (h-min_size) / (frames-1)
else:
return False
else:
# dest_x != 0 and dest_y != 0
return False
@ -1564,7 +1567,7 @@ class Game:
# can we save outself ?
def canSaveGame(self):
return 1
return True
# can we load this game ?
def canLoadGame(self, version_tuple, game_version):
return self.GAME_VERSION == game_version
@ -1574,7 +1577,7 @@ class Game:
# can we undo/redo ?
def canUndo(self):
return 1
return True
def canRedo(self):
return self.canUndo()
@ -2012,7 +2015,7 @@ Congratulations, you did it !
#
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return 0
return False
def _shallHighlightMatch_AC(self, stack1, card1, stack2, card2):
# by alternate color
@ -2108,10 +2111,10 @@ Congratulations, you did it !
# Update the balance unless this is a loaded game or
# a manually selected game number.
if self.gstats.loaded:
return 0
return False
if self.random.origin == self.random.ORIGIN_SELECTED:
return 0
return 1
return False
return True
def getGameBalance(self):
return 0

View file

@ -52,20 +52,20 @@ from montecarlo import MonteCarlo_RowStack
class AcesUp_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
c = cards[0]
for s in self.game.s.rows:
if s is not from_stack and s.cards and s.cards[-1].suit == c.suit:
if s.cards[-1].rank > c.rank or s.cards[-1].rank == ACE:
# found a higher rank or an Ace on the row stacks
return c.rank != ACE
return 0
return False
class AcesUp_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
return len(self.cards) == 0
clickHandler = BasicRowStack.doubleclickHandler
@ -121,11 +121,11 @@ class AcesUp(Game):
def isGameWon(self):
if len(self.s.foundations[0].cards) != 48:
return 0
return False
for s in self.s.rows:
if len(s.cards) != 1 or s.cards[0].rank != ACE:
return 0
return 1
return False
return True
def getAutoStacks(self, event=None):
if event is None:
@ -168,7 +168,7 @@ class PerpetualMotion_Talon(DealRowTalonStack):
def canDealCards(self):
## FIXME: this is to avoid loops in the demo
if self.game.demo and self.game.moves.index >= 500:
return 0
return False
return not self.game.isGameWon()
def dealCards(self, sound=0):
@ -195,7 +195,7 @@ class PerpetualMotion_Talon(DealRowTalonStack):
class PerpetualMotion_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
return isRankSequence(cards, dir=0)

View file

@ -124,7 +124,7 @@ class AuldLangSyne(TamOShanter):
class Strategy_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# we only accept cards if there are no cards in the talon
return len(self.game.s.talon.cards) == 0
@ -132,13 +132,13 @@ class Strategy_Foundation(SS_FoundationStack):
class Strategy_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Talon
return from_stack is self.game.s.talon and len(cards) == 1
def canMoveCards(self, cards):
if self.game.s.talon.cards:
return 0
return False
return BasicRowStack.canMoveCards(self, cards)
def clickHandler(self, event):
@ -233,7 +233,7 @@ class StrategyPlus(Strategy):
class Interregnum_Foundation(RK_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if len(self.cards) == 12:
# the final card must come from the reserve above the foundation
return from_stack.id == self.id - 8
@ -379,7 +379,7 @@ class Primrose(Interregnum):
class Colorado_RowStack(OpenStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Waste
return from_stack is self.game.s.waste and len(cards) == 1
@ -555,7 +555,7 @@ class DoubleAcquaintance(AuldLangSyne):
class Formic_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
return ((self.cards[-1].rank+1) % 13 == cards[0].rank or
(self.cards[-1].rank-1) % 13 == cards[0].rank)
@ -610,7 +610,8 @@ class Formic(TamOShanter):
registerGame(GameInfo(172, TamOShanter, "Tam O'Shanter",
GI.GT_NUMERICA, 1, 0, GI.SL_LUCK))
registerGame(GameInfo(95, AuldLangSyne, "Auld Lang Syne",
GI.GT_NUMERICA, 1, 0, GI.SL_LUCK))
GI.GT_NUMERICA, 1, 0, GI.SL_LUCK,
altnames=("Patience",) ))
registerGame(GameInfo(173, Strategy, "Strategy",
GI.GT_NUMERICA, 1, 0, GI.SL_SKILL))
registerGame(GameInfo(123, Interregnum, "Interregnum",

View file

@ -92,7 +92,7 @@ class CastlesInSpain(Game):
class Martha_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# when empty, only accept a single card
return self.cards or len(cards) == 1

View file

@ -390,13 +390,13 @@ class Chessboard_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not self.cards:
if len(cards) != 1 or not cards[0].face_up:
return 0
return False
if cards[0].suit != self.cap.base_suit:
return 0
return False
for s in self.game.s.foundations:
if s.cards:
return cards[0].rank == s.cards[0].rank
return 1
return True
return SS_FoundationStack.acceptsCards(self, from_stack, cards)

View file

@ -353,6 +353,63 @@ class BoardPatience(Game):
p.dump(self.base_card.id)
# /***********************************************************************
# // Cringle
# ************************************************************************/
class Cringle(Game):
def createGame(self):
# create layout
l, s = Layout(self), self.s
# set window
self.setSize(l.XM + 8.5*l.XS, l.YM + 3*l.YS + 14*l.XOFFSET)
# create stacks
x, y, = l.XM, l.YM
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS
x += l.XS/2
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
base_rank=KING, dir=-1))
x += l.XS
x, y = l.XM, l.YM+l.YS
for j in range(4):
s.rows.append(AC_RowStack(x, y, self))
x += l.XS
x += l.XS/2
for j in range(4):
s.rows.append(AC_RowStack(x, y, self, dir=1))
x += l.XS
x, y = self.width-l.XS, self.height-l.YS
s.talon = WasteTalonStack(x, y, self, max_rounds=1)
l.createText(s.talon, 'n')
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(frames=0)
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealCards()
shallHighlightMatch = Game._shallHighlightMatch_AC
# register the game
registerGame(GameInfo(290, Bisley, "Bisley",
GI.GT_1DECK_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
@ -368,4 +425,6 @@ registerGame(GameInfo(686, HospitalPatience, "Hospital Patience",
GI.GT_1DECK_TYPE, 1, -1, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(692, BoardPatience, "Board Patience",
GI.GT_1DECK_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(747, Cringle, "Cringle",
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_BALANCED))

View file

@ -63,9 +63,9 @@ class Braid_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if not self.cards:
return 1
return True
stack_dir = self.game.getFoundationDir()
if stack_dir == 0:
card_dir = self.getRankDir(cards=(self.cards[-1], cards[0]))
@ -106,7 +106,7 @@ class Braid_RowStack(ReserveStack):
class Braid_ReserveStack(ReserveStack):
def acceptsCards(self, from_stack, cards):
if from_stack is self.game.s.braid or from_stack in self.game.s.rows:
return 0
return False
return ReserveStack.acceptsCards(self, from_stack, cards)
def getBottomImage(self):

View file

@ -93,7 +93,7 @@ class Calculation_Foundation(BetsyRoss_Foundation):
class Calculation_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste and len(cards) == 1

View file

@ -582,7 +582,7 @@ class GrandmammasPatience(Game):
class DoubleLine_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste

View file

@ -67,7 +67,7 @@ class Canfield_AC_RowStack(AC_RowStack):
def basicAcceptsCards(self, from_stack, cards):
if from_stack in self.game.s.rows:
if len(cards) != 1 and len(cards) != len(from_stack.cards):
return 0
return False
return AC_RowStack.basicAcceptsCards(self, from_stack, cards)
@ -75,7 +75,7 @@ class Canfield_SS_RowStack(SS_RowStack):
def basicAcceptsCards(self, from_stack, cards):
if from_stack in self.game.s.rows:
if len(cards) != 1 and len(cards) != len(from_stack.cards):
return 0
return False
return SS_RowStack.basicAcceptsCards(self, from_stack, cards)
@ -83,7 +83,7 @@ class Canfield_RK_RowStack(RK_RowStack):
def basicAcceptsCards(self, from_stack, cards):
if from_stack in self.game.s.rows:
if len(cards) != 1 and len(cards) != len(from_stack.cards):
return 0
return False
return RK_RowStack.basicAcceptsCards(self, from_stack, cards)

View file

@ -50,12 +50,12 @@ from pysollib.pysoltk import MfxCanvasText
class Doublets_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.cards:
# check the rank
if (2 * self.cards[-1].rank + 1) % self.cap.mod != cards[0].rank:
return 0
return 1
return False
return True
class Doublets(Game):
@ -119,7 +119,7 @@ class Doublets(Game):
def isGameWon(self):
if self.s.talon.cards or self.s.waste.cards:
return 0
return False
return len(self.s.foundations[0].cards) == 48
def fillStack(self, stack):

View file

@ -53,7 +53,7 @@ class EiffelTower_RowStack(OpenStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
return self.cards[-1].rank + cards[0].rank == 12

View file

@ -290,12 +290,12 @@ class ThreeShufflesAndADraw_RowStack(SS_RowStack):
class ThreeShufflesAndADraw_ReserveStack(ReserveStack):
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return 0
return False
if not from_stack in self.game.s.rows:
return 0
return False
if self.game.draw_done or not from_stack._canDrawCard():
return 0
return 1
return False
return True
def updateModel(self, undo, flags):
assert undo == self.game.draw_done
@ -418,7 +418,7 @@ class Intelligence_ReserveStack(ReserveStack, DealRow_StackMethods):
dealToStacks = DealRow_StackMethods.dealToStacksOrFoundations
def canFlipCard(self):
return 0
return False
class Intelligence(Fan):

View file

@ -86,7 +86,7 @@ class Golf_Hint(AbstractHint):
class Golf_Talon(WasteTalonStack):
def canDealCards(self):
if not WasteTalonStack.canDealCards(self):
return 0
return False
return not self.game.isGameWon()
@ -97,13 +97,13 @@ class Golf_Waste(WasteStack):
def acceptsCards(self, from_stack, cards):
if not WasteStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check cards
r1, r2 = self.cards[-1].rank, cards[0].rank
if self.game.getStrictness() == 1:
# nothing on a King
if r1 == KING:
return 0
return False
return (r1 + 1) % self.cap.mod == r2 or (r2 + 1) % self.cap.mod == r1
def getHelp(self):
@ -174,8 +174,8 @@ class Golf(Game):
def isGameWon(self):
for r in self.s.rows:
if r.cards:
return 0
return 1
return False
return True
shallHighlightMatch = Game._shallHighlightMatch_RK
@ -201,7 +201,7 @@ class DeadKingGolf(Golf):
def shallHighlightMatch(self, stack1, card1, stack2, card2):
if card1.rank == KING:
return 0
return False
return Golf.shallHighlightMatch(self, stack1, card1, stack2, card2)
@ -226,8 +226,8 @@ class Elevator_RowStack(Golf_RowStack):
n = n + 1
for j in range(i, i+n):
if r[j].cards:
return 1
return 0
return True
return False
class Elevator(RelaxedGolf):
@ -288,12 +288,12 @@ class Escalator(Elevator):
class BlackHole_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
if self.cards:
r1, r2 = self.cards[-1].rank, cards[0].rank
return (r1 + 1) % self.cap.mod == r2 or (r2 + 1) % self.cap.mod == r1
return 1
return True
def getHelp(self):
return _('Foundation. Build up or down regardless of suit.')
@ -380,12 +380,12 @@ class BlackHole(Game):
class FourLeafClovers_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
if self.cards:
r1, r2 = self.cards[-1].rank, cards[0].rank
return (r1 + 1) % self.cap.mod == r2
return 1
return True
def getHelp(self):
return _('Foundation. Build up regardless of suit.')
@ -1003,6 +1003,62 @@ class NapoleonLeavesMoscow(NapoleonTakesMoscow):
self.s.talon.dealCards()
# /***********************************************************************
# // Flake
# // Flake (2 decks)
# ************************************************************************/
from pileon import FourByFour_Hint
class Flake(Game):
Hint_Class = FourByFour_Hint #CautiousDefaultHint
def createGame(self, rows=6, playcards=18):
# create layout
l, s = Layout(self), self.s
# set window
self.setSize(l.XM + rows*l.XS, l.YM + 2*l.YS + playcards*l.XOFFSET)
# create stacks
x, y, = l.XM, l.YM+l.YS
for i in range(rows):
s.rows.append(UD_RK_RowStack(x, y, self, mod=13))
x += l.XS
x, y = l.XM + (rows-1)*l.XS/2, l.YM
stack = BlackHole_Foundation(x, y, self, max_move=0, suit=ANY_SUIT,
base_rank=ANY_RANK, dir=0, mod=13,
max_cards=52*self.gameinfo.decks)
s.foundations.append(stack)
l.createText(stack, 'ne')
x, y = l.XM, self.height-l.YS
s.talon = InitialDealTalonStack(x, y, self)
# define stack-groups
l.defaultStackGroups()
def startGame(self):
for i in range(7):
self.s.talon.dealRow(frames=0)
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRowAvail()
shallHighlightMatch = Game._shallHighlightMatch_RKW
class Flake2Decks(Flake):
def createGame(self):
Flake.createGame(self, rows=8, playcards=22)
def startGame(self):
for i in range(12):
self.s.talon.dealRow(frames=0)
self.startDealSample()
self.s.talon.dealRow()
# register the game
registerGame(GameInfo(36, Golf, "Golf",
GI.GT_GOLF, 1, 0, GI.SL_BALANCED))
@ -1044,4 +1100,10 @@ registerGame(GameInfo(733, NapoleonTakesMoscow, "Napoleon Takes Moscow",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
registerGame(GameInfo(734, NapoleonLeavesMoscow, "Napoleon Leaves Moscow",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
registerGame(GameInfo(749, Flake, "Flake",
GI.GT_GOLF | GI.GT_OPEN | GI.GT_ORIGINAL,
1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(750, Flake2Decks, "Flake (2 decks)",
GI.GT_GOLF | GI.GT_OPEN | GI.GT_ORIGINAL,
2, 0, GI.SL_MOSTLY_SKILL))

View file

@ -93,7 +93,7 @@ class Gypsy(Game):
class Giant_Foundation(SS_FoundationStack):
def canMoveCards(self, cards):
if not SS_FoundationStack.canMoveCards(self, cards):
return 0
return False
# can only move cards if the Talon is empty
return len(self.game.s.talon.cards) == 0
@ -166,21 +166,21 @@ class DieKoenigsbergerin(Gypsy):
class DieRussische_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
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 0
return 1
return False
return True
class DieRussische_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# when empty, only accept a single card
return self.cards or len(cards) == 1
@ -215,7 +215,7 @@ class DieRussische(Gypsy):
class MissMilligan_ReserveStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# Note that this reserve stack accepts sequences if both
# the reserve stack and the Talon are empty.
return len(self.cards) == 0 and len(self.game.s.talon.cards) == 0

View file

@ -438,7 +438,7 @@ class EightByEight(EightTimesEight):
class Batsford_ReserveStack(ReserveStack):
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return 0
return False
# must be a King
return cards[0].rank == KING
def getHelp(self):
@ -602,7 +602,7 @@ class Jane_Talon(OpenTalonStack):
doubleclickHandler = OpenStack.doubleclickHandler
def canFlipCard(self):
return 0
return False
def canDealCards(self):
return len(self.cards) >= 2

View file

@ -151,7 +151,7 @@ class LarasGame_Talon(WasteTalonStack):
def canDealCards(self):
if self.game.demo and self.game.moves.index >= 400:
return 0
return False
return (self.cards or (self.round < self.max_rounds and not self.game.isGameWon()))
def updateText(self):
@ -181,7 +181,7 @@ class LarasGame_Reserve(OpenStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
return from_stack in self.game.s.rows
def getBottomImage(self):

View file

@ -80,7 +80,7 @@ class Matriarchy_Talon(WasteTalonStack):
if self._updateMaxRounds():
self.updateText()
if not self.cards and not self.game.s.waste.cards:
return 0
return False
ncards = self.DEAL[self.round-1]
assert ncards > 0
return len(self.cards) >= ncards or self.round < self.max_rounds
@ -222,7 +222,7 @@ class Matriarchy(Game):
def shallHighlightMatch(self, stack1, card1, stack2, card2):
if card1.rank + card2.rank == QUEEN + KING:
return 0
return False
return (card1.suit == card2.suit and
((card1.rank + 1) % 13 == card2.rank or (card2.rank + 1) % 13 == card1.rank))

View file

@ -144,7 +144,7 @@ class Montana_Talon(TalonStack):
class Montana_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.id % self.game.RSTEP == 0:
return cards[0].rank == self.game.RBASE
left = self.game.s.rows[self.id - 1]
@ -212,13 +212,13 @@ class Montana(Game):
rows = self.s.rows
for i in range(0, self.RLEN, self.RSTEP):
if not rows[i].cards:
return 0
return False
suit = rows[i].cards[-1].suit
for j in range(self.RSTEP - 1):
r = rows[i + j]
if not r.cards or r.cards[-1].rank != self.RBASE + j or r.cards[-1].suit != suit:
return 0
return 1
return False
return True
def getHighlightPilesStacks(self):
return ()
@ -307,33 +307,33 @@ class RedMoon(BlueMoon):
class Galary_Hint(Montana_Hint):
def shallMovePile(self, from_stack, to_stack, pile, rpile):
if from_stack is to_stack or not to_stack.acceptsCards(from_stack, pile):
return 0
return False
# now check for loops
rr = self.ClonedStack(from_stack, stackcards=rpile)
if rr.acceptsCards(to_stack, pile):
# the pile we are going to move could be moved back -
# this is dangerous as we can create endless loops...
return 0
return 1
return False
return True
class Galary_RowStack(Montana_RowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.id % self.game.RSTEP == 0:
return cards[0].rank == self.game.RBASE
r = self.game.s.rows
left = r[self.id - 1]
if left.cards and left.cards[-1].suit == cards[0].suit \
and left.cards[-1].rank + 1 == cards[0].rank:
return 1
return True
if self.id < len(r)-1:
right = r[self.id + 1]
if right.cards and right.cards[-1].suit == cards[0].suit \
and right.cards[-1].rank - 1 == cards[0].rank:
return 1
return 0
return True
return False
class Galary(RedMoon):
@ -357,7 +357,7 @@ class Moonlight(Montana):
class Jungle_RowStack(Montana_RowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.id % self.game.RSTEP == 0:
return cards[0].rank == self.game.RBASE
left = self.game.s.rows[self.id - 1]
@ -376,7 +376,7 @@ class Jungle(BlueMoon):
class SpacesAndAces_RowStack(Montana_RowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.id % self.game.RSTEP == 0:
return cards[0].rank == self.game.RBASE
left = self.game.s.rows[self.id - 1]

View file

@ -53,7 +53,7 @@ class MonteCarlo_Hint(DefaultHint):
# /***********************************************************************
# // Monte Carlo
# // Monaco
# // Monte Carlo (2 decks)
# ************************************************************************/
class MonteCarlo_Talon(TalonStack):
@ -63,7 +63,7 @@ class MonteCarlo_Talon(TalonStack):
if not r.cards:
free = 1
elif free:
return 1
return True
return free and len(self.cards)
def dealCards(self, sound=0):
@ -76,10 +76,10 @@ class MonteCarlo_Talon(TalonStack):
class MonteCarlo_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
if self.cards[-1].rank != cards[0].rank:
return 0
return False
# now look if the stacks are neighbours
return self.game.isNeighbour(from_stack, self)
@ -165,7 +165,7 @@ class MonteCarlo(Game):
def isNeighbour(self, stack1, stack2):
if not (0 <= stack1.id <= 24 and 0 <= stack2.id <= 24):
return 0
return False
column = stack2.id % 5
diff = stack1.id - stack2.id
if column == 0:
@ -181,7 +181,7 @@ class MonteCarlo(Game):
for r in self.s.rows:
assert len(r.cards) <= 1
if not r.cards:
free = free + 1
free += 1
elif free > 0:
to_stack = self.allstacks[r.id - free]
self.moveMove(1, r, to_stack, frames=4, shadow=0)
@ -192,12 +192,12 @@ class MonteCarlo(Game):
break
self.flipMove(self.s.talon)
self.moveMove(1, self.s.talon, r)
n = n + 1
n += 1
self.stopSamples()
return n
return n + free
class Monaco(MonteCarlo):
class MonteCarlo2Decks(MonteCarlo):
pass
@ -216,7 +216,7 @@ class Weddings_Talon(MonteCarlo_Talon):
while k >= 5 and not self.game.allstacks[k - 5].cards:
k = k - 5
if k != r.id:
return 1
return True
return free and len(self.cards)
@ -311,7 +311,7 @@ class SimplePairs(MonteCarlo):
class Neighbour_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# We accept any King. Pairs will get delivered by _dropPairMove.
return cards[0].rank == KING
@ -319,10 +319,10 @@ class Neighbour_Foundation(AbstractFoundationStack):
class Neighbour_RowStack(MonteCarlo_RowStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
if self.cards[-1].rank + cards[0].rank != 11:
return 0
return False
# now look if the stacks are neighbours
return self.game.isNeighbour(from_stack, self)
@ -376,7 +376,7 @@ class Neighbour(MonteCarlo):
class Fourteen_RowStack(MonteCarlo_RowStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
return self.cards[-1].rank + cards[0].rank == 12
@ -440,7 +440,7 @@ class Fourteen(Game):
class Nestor_RowStack(MonteCarlo_RowStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check the rank
return self.cards[-1].rank == cards[0].rank
@ -644,7 +644,7 @@ class DerLetzteMonarch_Foundation(SS_FoundationStack):
return SS_FoundationStack.acceptsCards(self, from_stack, from_stack.cards)
#
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# We only accept cards from a Reserve. Other cards will get
# delivered by _handlePairMove.
return from_stack in self.game.s.reserves
@ -656,10 +656,10 @@ class DerLetzteMonarch_RowStack(ReserveStack):
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return 0
return False
# must be neighbours
if not self.game.isNeighbour(from_stack, self):
return 0
return False
# must be able to move our card to the foundations or reserves
return self._getDropStack() is not None
@ -767,7 +767,7 @@ class DerLetzteMonarch(Game):
def isNeighbour(self, stack1, stack2):
if not (0 <= stack1.id <= 51 and 0 <= stack2.id <= 51):
return 0
return False
column = stack2.id % 13
diff = stack1.id - stack2.id
if column == 0:
@ -892,7 +892,7 @@ class RightAndLeft(Game):
registerGame(GameInfo(89, MonteCarlo, "Monte Carlo",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
altnames=("Quilt",) ))
registerGame(GameInfo(216, Monaco, "Monaco",
registerGame(GameInfo(216, MonteCarlo2Decks, "Monte Carlo (2 decks)",
GI.GT_PAIRING_TYPE, 2, 0, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(212, Weddings, "Weddings",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))

View file

@ -67,19 +67,19 @@ class Napoleon_SingleFreeCell(ReserveStack):
def acceptsCards(self, from_stack, cards):
## if from_stack.id >= 8:
## # from_stack must be a Napoleon_RowStack
## return 0
## return False
return ReserveStack.acceptsCards(self, from_stack, cards)
def canMoveCards(self, cards):
if self.game.s.rows[8].cards and self.game.s.rows[9].cards:
return 0
return False
return ReserveStack.canMoveCards(self, cards)
class Napoleon_FreeCell(ReserveStack):
def canMoveCards(self, cards):
if self.game.s.rows[self.id-2].cards:
return 0
return False
return ReserveStack.canMoveCards(self, cards)

View file

@ -81,7 +81,7 @@ class Numerica_Hint(DefaultHint):
class Numerica_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste and len(cards) == 1
@ -265,7 +265,7 @@ class PussInTheCorner_Foundation(SS_FoundationStack):
class PussInTheCorner_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from the Talon
return from_stack is self.game.s.talon and len(cards) == 1
def getBottomImage(self):
@ -476,7 +476,7 @@ class Gnat(Game):
class Gloaming_RowStack(Numerica_RowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts any one card from reserves
return from_stack in self.game.s.reserves

View file

@ -49,7 +49,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
class Osmosis_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# search foundation with max number of cards
assert len(cards) == 1
max_s, max_cards = None, -1
@ -59,9 +59,9 @@ class Osmosis_Foundation(AbstractFoundationStack):
# if we have less cards, then rank must match the card in this foundation
if len(self.cards) < max_cards:
if cards[0].rank != max_s.cards[len(self.cards)].rank:
return 0
return False
#
return 1
return True
def getHelp(self):
return _('Foundation. Build in suit regardless of rank.')

View file

@ -99,21 +99,21 @@ class PasDeDeux_Hint(AbstractHint):
class PasDeDeux_Waste(WasteStack):
def canFlipCard(self):
return 0
return False
class PasDeDeux_RowStack(ReserveStack):
def canMoveCards(self, cards):
if not ReserveStack.canMoveCards(self, cards):
return 0
return False
if not self.game.s.waste.cards:
return 0
return False
c = self.game.s.waste.cards[-1]
return c.face_up and cards[0].suit == c.suit and cards[0].rank == c.rank
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return 0
return False
# must be neighbours
return self.game.isNeighbour(from_stack, self)
@ -204,11 +204,11 @@ class PasDeDeux(Game):
def isGameWon(self):
for r in self.s.rows:
if len(r.cards) != 1:
return 0
return False
c = r.cards[-1]
if c.suit != r.id / 13 or c.rank != r.id % 13:
return 0
return 1
return False
return True
#
# game extras

View file

@ -160,11 +160,11 @@ class PictureGallery_TableauStack(SS_RowStack):
def acceptsCards(self, from_stack, cards):
if not SS_RowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check that the base card is correct
if self.cards and self.cards[0].rank != self.cap.base_rank:
return 0
return 1
return False
return True
def getBottomImage(self):
return self.game.app.images.getLetter(self.cap.base_rank)
@ -173,11 +173,11 @@ class PictureGallery_TableauStack(SS_RowStack):
class PictureGallery_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# check
if self.cards or self.game.s.talon.cards:
return 0
return 1
return False
return True
def getBottomImage(self):
return self.game.app.images.getTalonBottom()
@ -263,11 +263,11 @@ class PictureGallery(Game):
def isGameWon(self):
if len(self.s.foundations[0].cards) != 8:
return 0
return False
for stack in self.s.tableaux:
if len(stack.cards) != 4:
return 0
return 1
return False
return True
def fillStack(self, stack):
if self.s.talon.cards:
@ -276,7 +276,7 @@ class PictureGallery(Game):
def shallHighlightMatch(self, stack1, card1, stack2, card2):
if card1.rank == ACE or card2.rank == ACE:
return 0
return False
return (card1.suit == card2.suit and
(card1.rank + 3 == card2.rank or card2.rank + 3 == card1.rank))
@ -364,7 +364,7 @@ class GreatWheel(PictureGallery):
def shallHighlightMatch(self, stack1, card1, stack2, card2):
if card1.rank == ACE or card2.rank == ACE:
return 0
return False
return (card1.suit == card2.suit and
(card1.rank + 2 == card2.rank or card2.rank + 2 == card1.rank))

View file

@ -62,9 +62,9 @@ class Pyramid_Hint(DefaultHint):
class Pyramid_StackMethods:
def acceptsCards(self, from_stack, cards):
if self.basicIsBlocked():
return 0
return False
if from_stack is self or not self.cards or len(cards) != 1:
return 0
return False
c = self.cards[-1]
return c.face_up and cards[0].face_up and cards[0].rank + c.rank == 11
@ -105,7 +105,7 @@ class Pyramid_StackMethods:
class Pyramid_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# We accept any King. Pairs will get delivered by _dropPairMove.
return cards[0].rank == KING
@ -119,7 +119,7 @@ class Pyramid_Talon(Pyramid_StackMethods, FaceUpWasteTalonStack):
def canDealCards(self):
if not FaceUpWasteTalonStack.canDealCards(self):
return 0
return False
return not self.game.isGameWon()
def canDropCards(self, stacks):
@ -428,7 +428,7 @@ class Elevens_RowStack(Giza_Reserve):
def acceptsCards(self, from_stack, cards):
#if self.basicIsBlocked():
# return 0
# return False
if from_stack is self or not self.cards or len(cards) != 1:
return False
c = self.cards[-1]
@ -932,9 +932,9 @@ class Apophis(Pharaohs):
class Cheops_StackMethods(Pyramid_StackMethods):
def acceptsCards(self, from_stack, cards):
if self.basicIsBlocked():
return 0
return False
if from_stack is self or not self.cards or len(cards) != 1:
return 0
return False
c = self.cards[-1]
return (c.face_up and cards[0].face_up and
abs(cards[0].rank-c.rank) in (0,1))
@ -970,7 +970,7 @@ class Cheops(Pyramid):
class Exit_RowStack(Elevens_RowStack):
def acceptsCards(self, from_stack, cards):
#if self.basicIsBlocked():
# return 0
# return False
if from_stack is self or not self.cards or len(cards) != 1:
return False
c1 = self.cards[-1]

View file

@ -1174,6 +1174,124 @@ class TheRedAndTheBlack(Game):
shallHighlightMatch = Game._shallHighlightMatch_AC
# /***********************************************************************
# // Twilight Zone
# ************************************************************************/
class TwilightZone_Foundation(AC_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
return False
if from_stack is self.game.s.waste or \
from_stack in self.game.s.reserves:
return False
return True
class TwilightZone_Talon(OpenTalonStack, WasteTalonStack):
rightclickHandler = OpenStack.rightclickHandler
doubleclickHandler = OpenStack.doubleclickHandler
def prepareStack(self):
OpenTalonStack.prepareStack(self)
self.waste = self.game.s.waste
canDealCards = WasteTalonStack.canDealCards
dealCards = WasteTalonStack.dealCards
class TwilightZone_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return False
if from_stack is self.game.s.waste:
return False
return True
class TwilightZone_Waste(WasteStack):
def acceptsCards(self, from_stack, cards):
if not WasteStack.acceptsCards(self, from_stack, cards):
return False
return from_stack is self.game.s.talon
class TwilightZone(Game):
Hint_Class = CautiousDefaultHint
def createGame(self):
# create layout
l, s = Layout(self), self.s
# set window
self.setSize(l.XM+7*l.XS, l.YM+5*l.YS)
# create stacks
y = l.YM
for i in range(2):
x = l.XM+3*l.XS
for j in range(4):
s.foundations.append(TwilightZone_Foundation(x, y, self,
suit=j))
x += l.XS
y += l.YS
x, y = l.XM+3*l.XS, l.YM+2*l.YS
for i in range(4):
stack = TwilightZone_RowStack(x, y, self, max_move=1)
stack.CARD_YOFFSET = 0
s.rows.append(stack)
x += l.XS
x, y = l.XM+3*l.XS, l.YM+4*l.YS
for i in range(4):
s.reserves.append(OpenStack(x, y, self))
x += l.XS
x, y = l.XM, l.YM
s.talon = TwilightZone_Talon(x, y, self, max_move=1, max_rounds=2)
l.createText(s.talon, 's')
x += l.XS
s.waste = TwilightZone_Waste(x, y, self, max_accept=1)
l.createText(s.waste, 's')
# define stack-groups
l.defaultStackGroups()
self.sg.dropstacks.append(s.talon)
self.sg.openstacks.append(s.waste)
def startGame(self):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.reserves)
self.s.talon.fillStack()
def fillStack(self, stack):
if not stack.cards:
old_state = self.enterState(self.S_FILL)
if stack in self.s.rows:
i = list(self.s.rows).index(stack)
from_stack = self.s.reserves[i]
if from_stack.cards:
from_stack.moveMove(1, stack)
elif stack in self.s.reserves:
from_stack = self.s.waste
if not from_stack.cards:
from_stack = self.s.talon
if from_stack.cards:
from_stack.moveMove(1, stack)
self.leaveState(old_state)
def _autoDeal(self, sound=1):
return 0
shallHighlightMatch = Game._shallHighlightMatch_AC
# register the game
registerGame(GameInfo(54, RoyalCotillion, "Royal Cotillion",
@ -1216,4 +1334,6 @@ registerGame(GameInfo(693, Colonel, "Colonel",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(695, TheRedAndTheBlack, "The Red and the Black",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(748, TwilightZone, "Twilight Zone",
GI.GT_2DECK_TYPE, 2, 1, GI.SL_BALANCED))

View file

@ -79,31 +79,31 @@ class SiebenBisAs_Hint(CautiousDefaultHint):
class SiebenBisAs_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts only a card from a rowstack with an empty
# left neighbour
if not from_stack in self.game.s.rows:
return 0
return False
if from_stack.id % 10 == 0:
return 0
return False
return len(self.game.s.rows[from_stack.id - 1].cards) == 0
class SiebenBisAs_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.id % 10 != 0:
# left neighbour
s = self.game.s.rows[self.id - 1]
if s.cards and s.cards[-1].suit == cards[0].suit and (s.cards[-1].rank + 1) % 13 == cards[0].rank:
return 1
return True
if self.id % 10 != 10 - 1:
# right neighbour
s = self.game.s.rows[self.id + 1]
if s.cards and s.cards[-1].suit == cards[0].suit and (s.cards[-1].rank - 1) % 13 == cards[0].rank:
return 1
return 0
return True
return False
# bottom to get events for an empty stack
###prepareBottom = Stack.prepareInvisibleBottom
@ -164,33 +164,33 @@ class SiebenBisAs(Game):
class Maze_Hint(SiebenBisAs_Hint):
def shallMovePile(self, from_stack, to_stack, pile, rpile):
if from_stack is to_stack or not to_stack.acceptsCards(from_stack, pile):
return 0
return False
# now check for loops
rr = self.ClonedStack(from_stack, stackcards=rpile)
if rr.acceptsCards(to_stack, pile):
# the pile we are going to move could be moved back -
# this is dangerous as we can create endless loops...
return 0
return 1
return False
return True
class Maze_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return 0
return False
# left neighbour
s = self.game.s.rows[(self.id - 1) % 54]
if s.cards:
if s.cards[-1].suit == cards[0].suit and s.cards[-1].rank + 1 == cards[0].rank:
return 1
return True
if s.cards[-1].rank == QUEEN and cards[0].rank == ACE:
return 1
return True
# right neighbour
s = self.game.s.rows[(self.id + 1) % 54]
if s.cards:
if s.cards[-1].suit == cards[0].suit and s.cards[-1].rank - 1 == cards[0].rank:
return 1
return 0
return True
return False
# bottom to get events for an empty stack
prepareBottom = Stack.prepareInvisibleBottom
@ -250,7 +250,7 @@ class Maze(Game):
def isGameWon(self):
rows = filter(lambda s: s.cards, self.s.rows)
if len(rows) != 48:
return 0 # no cards dealt yet
return False # no cards dealt yet
i = 0
if 1:
# allow wrap around: search first Ace
@ -263,13 +263,13 @@ class Maze(Game):
r2 = rows[j+11]
if (r2.id - r1.id) % 54 != 11:
# found a space within the sequence
return 0
return False
if r1.cards[-1].rank != ACE or r2.cards[-1].rank != QUEEN:
return 0
return False
pile = getPileFromStacks(rows[j:j+12])
if not pile or not isSameSuitSequence(pile, dir=1):
return 0
return 1
return False
return True
# register the game

View file

@ -59,22 +59,22 @@ class Spider_Hint(SpiderType_Hint):
def shallMovePile(self, r, t, pile, rpile):
if not SpiderType_Hint.shallMovePile(self, r, t, pile, rpile):
return 0
return False
rr = self.ClonedStack(r, stackcards=rpile)
if rr.acceptsCards(t, pile):
# the pile we are going to move from r to t
# could be moved back from t ro r - this is
# dangerous for as we can create loops...
if len(t.cards) == 0:
return 1
return True
if pile[0].suit == t.cards[-1].suit:
# The pile will get moved onto the correct suit
if len(rpile) == 0 or pile[0].suit != rpile[-1].suit:
return 1
return True
if self.level <= 1 and len(rpile) == 0:
return 1
return 0
return 1
return True
return False
return True
# /***********************************************************************
@ -150,12 +150,12 @@ class RelaxedSpider(Game):
class Spider(RelaxedSpider):
def canDealCards(self):
if not RelaxedSpider.canDealCards(self):
return 0
return False
# no row may be empty
for r in self.s.rows:
if not r.cards:
return 0
return 1
return False
return True
class Spider1Suit(Spider):
pass

View file

@ -50,7 +50,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
class Terrace_Talon(WasteTalonStack):
def canDealCards(self):
if self.game.getState() == 0:
return 0
return False
return WasteTalonStack.canDealCards(self)
@ -62,9 +62,9 @@ class Terrace_AC_Foundation(AC_FoundationStack):
def acceptsCards(self, from_stack, cards):
if self.game.getState() == 0:
if len(cards) != 1 or not cards[0].face_up:
return 0
return False
if cards[0].suit != self.cap.base_suit:
return 0
return False
return from_stack in self.game.s.rows
return AC_FoundationStack.acceptsCards(self, from_stack, cards)
@ -77,9 +77,9 @@ class Terrace_SS_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if self.game.getState() == 0:
if len(cards) != 1 or not cards[0].face_up:
return 0
return False
if cards[0].suit != self.cap.base_suit:
return 0
return False
return from_stack in self.game.s.rows
return SS_FoundationStack.acceptsCards(self, from_stack, cards)
@ -91,9 +91,9 @@ class Terrace_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if self.game.getState() == 0:
return 0
return False
if from_stack in self.game.s.reserves:
return 0
return False
return AC_RowStack.acceptsCards(self, from_stack, cards)
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):

View file

@ -88,30 +88,10 @@ class ThreePeaks_RowStack(OpenStack):
i = i + step[i]
for j in range(2):
if r[i + j].cards:
return 1
return 0
return True
return False
def clickHandler(self, event):
if self.basicIsBlocked():
# remove selection
self._stopDrag()
return 1
game = self.game
#print self.cards, game.s.waste.cards
card, waste = self.cards[0], game.s.waste.cards[-1]
mod, ranks, trumps = [], len(game.gameinfo.ranks), len(game.gameinfo.trumps)
mod.append([ranks, trumps][(card.suit == len(game.gameinfo.suits))])
mod.append([ranks, trumps][(waste.suit == len(game.gameinfo.suits))])
if ((card.rank + 1) % mod[0] == waste.rank
or (card.rank - 1) % mod[1] == waste.rank
or (waste.rank + 1) % mod[1] == card.rank
or (waste.rank - 1) % mod[0] == card.rank):
game.sequence = game.sequence + 1
self._stopDrag()
self.game.playSample("autodrop", priority=20)
self.playMoveMove(1, game.s.waste, frames=-1, sound=0)
game.updateText()
return 1
clickHandler = OpenStack.doubleclickHandler
# /***********************************************************************
@ -206,12 +186,12 @@ class ThreePeaks(Game):
def isGameWon(self):
for r in self.s.rows:
if r.cards:
return 0
return False
if self.sequence:
self.hand_score = self.hand_score + len(self.s.talon.cards) * 10
self.updateText()
self.sequence = 0
return 1
return True
def updateText(self):
if self.preview > 1 or not self.texts.info or not self.SCORING:
@ -224,7 +204,7 @@ class ThreePeaks(Game):
if stack1 == self.s.waste or stack2 == self.s.waste:
return ((card1.rank + 1) % 13 == card2.rank
or (card1.rank - 1) % 13 == card2.rank)
return 0
return False
def getHandScore(self):
score, i = self.hand_score, 1
@ -245,7 +225,7 @@ class ThreePeaks(Game):
return score
def canUndo(self):
return 0
return False
def _restoreGameHook(self, game):
self.game_score = game.loadinfo.game_score
@ -278,7 +258,7 @@ class ThreePeaksNoScore(ThreePeaks):
SCORING = 0
def canUndo(self):
return 1
return True

View file

@ -66,11 +66,11 @@ class UnionSquare_RowStack(OpenStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return 0
return False
if not self.cards:
return 1
return True
if cards[0].suit != self.cards[0].suit:
return 0
return False
if len(self.cards) == 1:
card_dir = cards[0].rank - self.cards[-1].rank
return card_dir == 1 or card_dir == -1

View file

@ -59,7 +59,7 @@ class Windmill_Foundation(RK_FoundationStack):
class Windmill_RowStack(ReserveStack):
def acceptsCards(self, from_stack, cards):
if not ReserveStack.acceptsCards(self, from_stack, cards):
return 0
return False
# this stack accepts one card from the Waste pile
return from_stack is self.game.s.waste

View file

@ -130,74 +130,74 @@ from settings import DEBUG
# check that all cards are face-up
def cardsFaceUp(cards):
if not cards: return 0
if not cards: return False
for c in cards:
if not c.face_up:
return 0
return 1
return False
return True
# check that all cards are face-down
def cardsFaceDown(cards):
if not cards: return 0
if not cards: return False
for c in cards:
if c.face_up:
return 0
return 1
return False
return True
# check that cards are face-up and build down by rank
def isRankSequence(cards, mod=8192, dir=-1):
if not cardsFaceUp(cards):
return 0
return False
c1 = cards[0]
for c2 in cards[1:]:
if (c1.rank + dir) % mod != c2.rank:
return 0
return False
c1 = c2
return 1
return True
# check that cards are face-up and build down by alternate color
def isAlternateColorSequence(cards, mod=8192, dir=-1):
if not cardsFaceUp(cards):
return 0
return False
c1 = cards[0]
for c2 in cards[1:]:
if (c1.rank + dir) % mod != c2.rank or c1.color == c2.color:
return 0
return False
c1 = c2
return 1
return True
# check that cards are face-up and build down by same color
def isSameColorSequence(cards, mod=8192, dir=-1):
if not cardsFaceUp(cards):
return 0
return False
c1 = cards[0]
for c2 in cards[1:]:
if (c1.rank + dir) % mod != c2.rank or c1.color != c2.color:
return 0
return False
c1 = c2
return 1
return True
# check that cards are face-up and build down by same suit
def isSameSuitSequence(cards, mod=8192, dir=-1):
if not cardsFaceUp(cards):
return 0
return False
c1 = cards[0]
for c2 in cards[1:]:
if (c1.rank + dir) % mod != c2.rank or c1.suit != c2.suit:
return 0
return False
c1 = c2
return 1
return True
# check that cards are face-up and build down by any suit but own
def isAnySuitButOwnSequence(cards, mod=8192, dir=-1):
if not cardsFaceUp(cards):
return 0
return False
c1 = cards[0]
for c2 in cards[1:]:
if (c1.rank + dir) % mod != c2.rank or c1.suit == c2.suit:
return 0
return False
c1 = c2
return 1
return True
def getNumberOfFreeStacks(stacks):
return len(filter(lambda s: not s.cards, stacks))
@ -598,28 +598,28 @@ class Stack:
def basicIsBlocked(self):
# Check if the stack is blocked (e.g. Pyramid or Mahjongg)
return 0
return False
def basicAcceptsCards(self, from_stack, cards):
# Check that the limits are ok and that the cards are face up
if from_stack is self or self.basicIsBlocked():
return 0
return False
cap = self.cap
l = len(cards)
if l < cap.min_accept or l > cap.max_accept:
return 0
return False
l = l + len(self.cards)
if l > cap.max_cards: # note: we don't check cap.min_cards here
return 0
return False
for c in cards:
if not c.face_up:
return 0
return False
if cap.suit >= 0 and c.suit != cap.suit:
return 0
return False
if cap.color >= 0 and c.color != cap.color:
return 0
return False
if cap.rank >= 0 and c.rank != cap.rank:
return 0
return False
if self.cards:
# top card of our stack must be face up
return self.cards[-1].face_up
@ -627,24 +627,24 @@ class Stack:
# check required base
c = cards[0]
if cap.base_suit >= 0 and c.suit != cap.base_suit:
return 0
return False
if cap.base_color >= 0 and c.color != cap.base_color:
return 0
return False
if cap.base_rank >= 0 and c.rank != cap.base_rank:
return 0
return 1
return False
return True
def basicCanMoveCards(self, cards):
# Check that the limits are ok and the cards are face up
if self.basicIsBlocked():
return 0
return False
cap = self.cap
l = len(cards)
if l < cap.min_move or l > cap.max_move:
return 0
return False
l = len(self.cards) - l
if l < cap.min_cards: # note: we don't check cap.max_cards here
return 0
return False
return cardsFaceUp(cards)
@ -654,15 +654,15 @@ class Stack:
def acceptsCards(self, from_stack, cards):
# Do we accept receiving `cards' from `from_stack' ?
return 0
return False
def canMoveCards(self, cards):
# Can we move these cards when assuming they are our top-cards ?
return 0
return False
def canFlipCard(self):
# Can we flip our top card ?
return 0
return False
def canDropCards(self, stacks):
# Can we drop the top cards onto one of the foundation stacks ?
@ -1917,7 +1917,7 @@ class OpenStack(Stack):
def canFlipCard(self):
# default for OpenStack: we can flip the top card
if self.basicIsBlocked() or not self.cards:
return 0
return False
return not self.cards[-1].face_up
def canDropCards(self, stacks):
@ -2123,12 +2123,12 @@ class AbstractFoundationStack(OpenStack):
class SS_FoundationStack(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.cards:
# check the rank
if (self.cards[-1].rank + self.cap.dir) % self.cap.mod != cards[0].rank:
return 0
return 1
return False
return True
def getHelp(self):
if self.cap.dir > 0: return _('Foundation. Build up by suit.')
@ -2156,12 +2156,12 @@ class AC_FoundationStack(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.cards:
# check the color
if cards[0].color == self.cards[-1].color:
return 0
return 1
return False
return True
def getHelp(self):
if self.cap.dir > 0: return _('Foundation. Build up by alternate color.')
@ -2177,12 +2177,12 @@ class SC_FoundationStack(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
if self.cards:
# check the color
if cards[0].color != self.cards[-1].color:
return 0
return 1
return False
return True
def getHelp(self):
if self.cap.dir > 0: return _('Foundation. Build up by color.')
@ -2199,7 +2199,7 @@ class Spider_SS_Foundation(AbstractFoundationStack):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# now check the cards
return isSameSuitSequence(cards, self.cap.mod, self.cap.dir)
@ -2207,7 +2207,7 @@ class Spider_SS_Foundation(AbstractFoundationStack):
class Spider_AC_Foundation(Spider_SS_Foundation):
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
return False
# now check the cards
return isAlternateColorSequence(cards, self.cap.mod, self.cap.dir)
@ -2231,14 +2231,14 @@ class SequenceStack_StackMethods:
def acceptsCards(self, from_stack, cards):
if not self.basicAcceptsCards(from_stack, cards):
return 0
return False
# cards must be an acceptable sequence
if not self._isAcceptableSequence(cards):
return 0
return False
# [topcard + cards] must be an acceptable sequence
if self.cards and not self._isAcceptableSequence([self.cards[-1]] + cards):
return 0
return 1
return False
return True
def canMoveCards(self, cards):
return self.basicCanMoveCards(cards) and self._isMoveableSequence(cards)
@ -2388,11 +2388,11 @@ class Yukon_AC_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards):
if not self.basicAcceptsCards(from_stack, cards):
return 0
return False
# [topcard + card[0]] must be acceptable
if self.cards and not self._isSequence(self.cards[-1], cards[0]):
return 0
return 1
return False
return True
def getHelp(self):
if self.cap.dir > 0: return _('Tableau. Build up by alternate color, can move any face-up cards regardless of sequence.')
@ -2490,8 +2490,6 @@ class UD_RK_RowStack(SequenceRowStack):
# To simplify playing we also consider the number of free rows.
# Note that this only is legal if the game.s.rows have a
# cap.base_rank == ANY_RANK.
# See also the "SuperMove" section in the FreeCell FAQ.
class SuperMoveStack_StackMethods:
def _getMaxMove(self, to_stack_ncards):
@ -2608,8 +2606,8 @@ class WasteTalonStack(TalonStack):
num_cards = min(len(self.cards), self.num_deal)
return len(waste.cards) + num_cards <= waste.cap.max_cards
elif waste.cards and self.round != self.max_rounds:
return 1
return 0
return True
return False
def dealCards(self, sound=0, shuffle=False):
old_state = self.game.enterState(self.game.S_DEAL)
@ -2652,7 +2650,7 @@ class FaceUpWasteTalonStack(WasteTalonStack):
def fillStack(self):
if self.canFlipCard():
self.game.flipMove(self)
self.game.singleFlipMove(self)
self.game.fillStack(self)
def dealCards(self, sound=0):
@ -2671,14 +2669,14 @@ class OpenTalonStack(TalonStack, OpenStack):
TalonStack.__init__(self, x, y, game, **cap)
def canDealCards(self):
return 0
return False
def canFlipCard(self):
return len(self.cards) > 0 and not self.cards[-1].face_up
def fillStack(self):
if self.canFlipCard():
self.game.flipMove(self)
self.game.singleFlipMove(self)
self.game.fillStack(self)
def clickHandler(self, event):

View file

@ -107,7 +107,7 @@ class SelectGameData(SelectDialogTreeData):
for name, select_func in data:
if name is None or not filter(select_func, self.all_games_gi):
continue
gg.append(SelectGameNode(None, name, select_func))
gg.append(SelectGameNode(None, _(name), select_func))
g.append(gg)
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
gg = None

View file

@ -44,7 +44,7 @@ __all__ = ['MfxDialog',
]
# imports
import os, time, locale
import sys, os, time, locale
import Tkinter
import Tile
import tkFont
@ -320,7 +320,13 @@ class PysolAboutDialog(MfxMessageDialog):
width=kw.width)
msg.pack(fill='both', expand=True)
font = tkFont.Font(parent, app.getFont('default'))
if sys.version_info >= (2, 4):
##font_name = msg.lookup('TLabel', 'font')
font_name = 'TkDefaultFont'
font = tkFont.Font(parent, name=font_name, exists=True)
font = font.copy()
else:
font = tkFont.Font(parent, app.getFont('default'))
font.configure(underline=True)
url_label = Tile.Label(frame, text=kw.url, font=font,
foreground='blue', cursor='hand2')

View file

@ -283,7 +283,7 @@ class PysolToolbar(PysolToolbarActions):
##color = '#ffffff'
##factor = 0.6
color = '#dedede'
factor = 0.75
factor = 0.7
sh = Image.new(dis_im.mode, dis_im.size, color)
tmp = Image.blend(dis_im, sh, factor)
dis_im = Image.composite(tmp, im, im)

View file

@ -107,7 +107,7 @@ class SelectGameData(SelectDialogTreeData):
for name, select_func in data:
if name is None or not filter(select_func, self.all_games_gi):
continue
gg.append(SelectGameNode(None, name, select_func))
gg.append(SelectGameNode(None, _(name), select_func))
g.append(gg)
select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG
gg = None