From cc05937c71d7e9b236de780b14afd03a7f95f900 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Wed, 3 Oct 2007 21:19:01 +0000 Subject: [PATCH] + 1 new game + added Game.getInvisibleCoords method * minor fixes git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@213 efabe8c0-fbe8-4139-b769-b5e6d273206e --- README | 3 +- pysollib/game.py | 7 +++++ pysollib/games/montana.py | 53 ++++++++++++++++++++++++++++++------ pysollib/games/montecarlo.py | 14 +++++----- pysollib/games/sultan.py | 2 +- pysollib/stack.py | 6 ++-- pysollib/winsystems/aqua.py | 5 ++-- 7 files changed, 67 insertions(+), 23 deletions(-) diff --git a/README b/README index 53001b16..6c9e4aa2 100644 --- a/README +++ b/README @@ -15,7 +15,7 @@ Requirements. ** other packages (optional) ** - Tile: http://tktable.sourceforge.net/tile/ (0.7.8 or later) - - PIL (Python Image Library): http://www.pythonware.com/products/pil + - PIL (Python Imaging Library): http://www.pythonware.com/products/pil - Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/ @@ -28,6 +28,7 @@ or just run from the source directory: $ python pysol.py + ** Freecell Solver ** If you want to use Solver, you should configure freecell-solver with following options: diff --git a/pysollib/game.py b/pysollib/game.py index e064177b..2ef455fe 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -1539,6 +1539,13 @@ class Game: self.regions.remaining = tuple(remaining) ##print self.regions.info + def getInvisibleCoords(self): + # for InvisibleStack, etc + ##x, y = -500, -500 - len(game.allstacks) + cardw, cardh = self.app.images.CARDW, self.app.images.CARDH + x, y = cardw + self.canvas.xmargin, cardh + self.canvas.ymargin + return -x-10, -y-10 + # # Game - subclass overridable actions - IMPORTANT FOR GAME LOGIC diff --git a/pysollib/games/montana.py b/pysollib/games/montana.py index 0f6a4431..633bd911 100644 --- a/pysollib/games/montana.py +++ b/pysollib/games/montana.py @@ -169,22 +169,33 @@ class Montana(Game): RLEN, RSTEP, RBASE = 52, 13, 1 def createGame(self, round_text=True): + decks = self.gameinfo.decks + # create layout l, s = Layout(self, card_x_space=4), self.s # set window - self.setSize(l.XM + self.RSTEP*l.XS, l.YM + 5*l.YS) + w, h = l.XM + self.RSTEP*l.XS, l.YM + (4*decks)*l.YS + if round_text: + h += l.YS + self.setSize(w, h) # create stacks - for i in range(4): - x, y, = l.XM, l.YM + i*l.YS - for j in range(self.RSTEP): - s.rows.append(self.RowStack_Class(x, y, self, max_accept=1, max_cards=1)) - x = x + l.XS - x = l.XM + (self.RSTEP-1)*l.XS/2 - s.talon = self.Talon_Class(x, self.height-l.YS, self) + for k in range(decks): + for i in range(4): + x, y = l.XM, l.YM + (i+k*4)*l.YS + for j in range(self.RSTEP): + s.rows.append(self.RowStack_Class(x, y, self, + max_accept=1, max_cards=1)) + x += l.XS if round_text: + x, y = l.XM + (self.RSTEP-1)*l.XS/2, self.height-l.YS + s.talon = self.Talon_Class(x, y, self) l.createRoundText(s.talon, 'se') + else: + # Talon is invisible + x, y = self.getInvisibleCoords() + s.talon = self.Talon_Class(x, y, self) if self.RBASE: # create an invisible stack to hold the four Aces s.internals.append(InvisibleStack(self)) @@ -552,6 +563,29 @@ class Spoilt(Game): return (), (), () +# /*********************************************************************** +# // Double Montana +# ************************************************************************/ + +class DoubleMontana(Montana): + Talon_Class = InitialDealTalonStack + Hint_Class = Galary_Hint + RLEN, RSTEP, RBASE = 112, 14, 0 + + def createGame(self): + Montana.createGame(self, round_text=False) + + def startGame(self): + frames = 0 + for i in range(self.RLEN): + if i == self.RLEN-self.RSTEP: # last row + self.startDealSample() + frames = -1 + if i % self.RSTEP == 0: # left column + continue + self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames) + + # register the game registerGame(GameInfo(53, Montana, "Montana", @@ -582,4 +616,7 @@ registerGame(GameInfo(736, Spoilt, "Spoilt", GI.GT_MONTANA, 1, 0, GI.SL_MOSTLY_LUCK, ranks=(0, 6, 7, 8, 9, 10, 11, 12), )) +registerGame(GameInfo(759, DoubleMontana, "Double Montana", + GI.GT_MONTANA | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL)) + diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index 844a5c91..954eb571 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -113,7 +113,7 @@ class MonteCarlo(Game): RowStack_Class = MonteCarlo_RowStack Hint_Class = MonteCarlo_Hint - FILL_STACKS_AFTER_DROP = 0 + FILL_STACKS_AFTER_DROP = False # # game layout @@ -256,7 +256,7 @@ class Weddings(MonteCarlo): # ************************************************************************/ class SimpleCarlo(MonteCarlo): - FILL_STACKS_AFTER_DROP = 1 + FILL_STACKS_AFTER_DROP = True def getAutoStacks(self, event=None): return ((), (), ()) @@ -361,7 +361,7 @@ class Neighbour(MonteCarlo): Foundation_Class = Neighbour_Foundation RowStack_Class = Neighbour_RowStack - FILL_STACKS_AFTER_DROP = 1 + FILL_STACKS_AFTER_DROP = True def getAutoStacks(self, event=None): return ((), self.sg.dropstacks, ()) @@ -386,7 +386,7 @@ class Fourteen(Game): Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0) RowStack_Class = Fourteen_RowStack - FILL_STACKS_AFTER_DROP = 0 + FILL_STACKS_AFTER_DROP = False # # game layout @@ -450,7 +450,7 @@ class Nestor(Game): Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0) RowStack_Class = Nestor_RowStack - FILL_STACKS_AFTER_DROP = 0 + FILL_STACKS_AFTER_DROP = False # # game layout @@ -577,7 +577,7 @@ class Vertical(Nestor): class TheWish(Game): - FILL_STACKS_AFTER_DROP = 0 + FILL_STACKS_AFTER_DROP = False def createGame(self): # create layout @@ -853,7 +853,7 @@ class RightAndLeft_Talon(DealRowRedealTalonStack): class RightAndLeft(Game): - FILL_STACKS_AFTER_DROP = 0 + FILL_STACKS_AFTER_DROP = False def createGame(self): # create layout diff --git a/pysollib/games/sultan.py b/pysollib/games/sultan.py index 288196d4..0027d3a7 100644 --- a/pysollib/games/sultan.py +++ b/pysollib/games/sultan.py @@ -1208,7 +1208,7 @@ class Voracious(Grandee): # /*********************************************************************** -# // +# // Desert Island # ************************************************************************/ class DesertIsland(Game): diff --git a/pysollib/stack.py b/pysollib/stack.py index 1766ef44..45b36377 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -2783,11 +2783,9 @@ class ReserveStack(OpenStack): class InvisibleStack(Stack): def __init__(self, game, **cap): - ##x, y = -500, -500 - len(game.allstacks) - cardw, cardh = game.app.images.CARDW, game.app.images.CARDH - x, y = cardw+game.canvas.xmargin, cardh+game.canvas.ymargin + x, y = game.getInvisibleCoords() kwdefault(cap, max_move=0, max_accept=0) - Stack.__init__(self, -x-10, -y-10, game, cap=cap) + Stack.__init__(self, x, y, game, cap=cap) def assertStack(self): Stack.assertStack(self) diff --git a/pysollib/winsystems/aqua.py b/pysollib/winsystems/aqua.py index 5b951214..d4eb1dbb 100644 --- a/pysollib/winsystems/aqua.py +++ b/pysollib/winsystems/aqua.py @@ -41,8 +41,9 @@ def init_root_window(root, app): if color: root.tk_setPalette(color) # for non-Tile widgets - # standard Tk scrollbars work on OS X, but Tile ones look weird - Tile.Scrollbar = Tkinter.Scrollbar + if app.opt.tile_theme == 'aqua': + # standard Tk scrollbars work on OS X, but Tile ones look weird + Tile.Scrollbar = Tkinter.Scrollbar else: # pure Tk #root.option_add(...)