mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
+ 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
This commit is contained in:
parent
2ae3f5505c
commit
cc05937c71
7 changed files with 67 additions and 23 deletions
3
README
3
README
|
@ -15,7 +15,7 @@ Requirements.
|
||||||
|
|
||||||
** other packages (optional) **
|
** other packages (optional) **
|
||||||
- Tile: http://tktable.sourceforge.net/tile/ (0.7.8 or later)
|
- 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/
|
- Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ or just run from the source directory:
|
||||||
|
|
||||||
$ python pysol.py
|
$ python pysol.py
|
||||||
|
|
||||||
|
|
||||||
** Freecell Solver **
|
** Freecell Solver **
|
||||||
If you want to use Solver, you should configure freecell-solver with following
|
If you want to use Solver, you should configure freecell-solver with following
|
||||||
options:
|
options:
|
||||||
|
|
|
@ -1539,6 +1539,13 @@ class Game:
|
||||||
self.regions.remaining = tuple(remaining)
|
self.regions.remaining = tuple(remaining)
|
||||||
##print self.regions.info
|
##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
|
# Game - subclass overridable actions - IMPORTANT FOR GAME LOGIC
|
||||||
|
|
|
@ -169,22 +169,33 @@ class Montana(Game):
|
||||||
RLEN, RSTEP, RBASE = 52, 13, 1
|
RLEN, RSTEP, RBASE = 52, 13, 1
|
||||||
|
|
||||||
def createGame(self, round_text=True):
|
def createGame(self, round_text=True):
|
||||||
|
decks = self.gameinfo.decks
|
||||||
|
|
||||||
# create layout
|
# create layout
|
||||||
l, s = Layout(self, card_x_space=4), self.s
|
l, s = Layout(self, card_x_space=4), self.s
|
||||||
|
|
||||||
# set window
|
# 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
|
# create stacks
|
||||||
for i in range(4):
|
for k in range(decks):
|
||||||
x, y, = l.XM, l.YM + i*l.YS
|
for i in range(4):
|
||||||
for j in range(self.RSTEP):
|
x, y = l.XM, l.YM + (i+k*4)*l.YS
|
||||||
s.rows.append(self.RowStack_Class(x, y, self, max_accept=1, max_cards=1))
|
for j in range(self.RSTEP):
|
||||||
x = x + l.XS
|
s.rows.append(self.RowStack_Class(x, y, self,
|
||||||
x = l.XM + (self.RSTEP-1)*l.XS/2
|
max_accept=1, max_cards=1))
|
||||||
s.talon = self.Talon_Class(x, self.height-l.YS, self)
|
x += l.XS
|
||||||
if round_text:
|
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')
|
l.createRoundText(s.talon, 'se')
|
||||||
|
else:
|
||||||
|
# Talon is invisible
|
||||||
|
x, y = self.getInvisibleCoords()
|
||||||
|
s.talon = self.Talon_Class(x, y, self)
|
||||||
if self.RBASE:
|
if self.RBASE:
|
||||||
# create an invisible stack to hold the four Aces
|
# create an invisible stack to hold the four Aces
|
||||||
s.internals.append(InvisibleStack(self))
|
s.internals.append(InvisibleStack(self))
|
||||||
|
@ -552,6 +563,29 @@ class Spoilt(Game):
|
||||||
return (), (), ()
|
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
|
# register the game
|
||||||
registerGame(GameInfo(53, Montana, "Montana",
|
registerGame(GameInfo(53, Montana, "Montana",
|
||||||
|
@ -582,4 +616,7 @@ registerGame(GameInfo(736, Spoilt, "Spoilt",
|
||||||
GI.GT_MONTANA, 1, 0, GI.SL_MOSTLY_LUCK,
|
GI.GT_MONTANA, 1, 0, GI.SL_MOSTLY_LUCK,
|
||||||
ranks=(0, 6, 7, 8, 9, 10, 11, 12),
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class MonteCarlo(Game):
|
||||||
RowStack_Class = MonteCarlo_RowStack
|
RowStack_Class = MonteCarlo_RowStack
|
||||||
Hint_Class = MonteCarlo_Hint
|
Hint_Class = MonteCarlo_Hint
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 0
|
FILL_STACKS_AFTER_DROP = False
|
||||||
|
|
||||||
#
|
#
|
||||||
# game layout
|
# game layout
|
||||||
|
@ -256,7 +256,7 @@ class Weddings(MonteCarlo):
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
||||||
class SimpleCarlo(MonteCarlo):
|
class SimpleCarlo(MonteCarlo):
|
||||||
FILL_STACKS_AFTER_DROP = 1
|
FILL_STACKS_AFTER_DROP = True
|
||||||
|
|
||||||
def getAutoStacks(self, event=None):
|
def getAutoStacks(self, event=None):
|
||||||
return ((), (), ())
|
return ((), (), ())
|
||||||
|
@ -361,7 +361,7 @@ class Neighbour(MonteCarlo):
|
||||||
Foundation_Class = Neighbour_Foundation
|
Foundation_Class = Neighbour_Foundation
|
||||||
RowStack_Class = Neighbour_RowStack
|
RowStack_Class = Neighbour_RowStack
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 1
|
FILL_STACKS_AFTER_DROP = True
|
||||||
|
|
||||||
def getAutoStacks(self, event=None):
|
def getAutoStacks(self, event=None):
|
||||||
return ((), self.sg.dropstacks, ())
|
return ((), self.sg.dropstacks, ())
|
||||||
|
@ -386,7 +386,7 @@ class Fourteen(Game):
|
||||||
Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0)
|
Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0)
|
||||||
RowStack_Class = Fourteen_RowStack
|
RowStack_Class = Fourteen_RowStack
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 0
|
FILL_STACKS_AFTER_DROP = False
|
||||||
|
|
||||||
#
|
#
|
||||||
# game layout
|
# game layout
|
||||||
|
@ -450,7 +450,7 @@ class Nestor(Game):
|
||||||
Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0)
|
Foundation_Class = StackWrapper(AbstractFoundationStack, max_accept=0)
|
||||||
RowStack_Class = Nestor_RowStack
|
RowStack_Class = Nestor_RowStack
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 0
|
FILL_STACKS_AFTER_DROP = False
|
||||||
|
|
||||||
#
|
#
|
||||||
# game layout
|
# game layout
|
||||||
|
@ -577,7 +577,7 @@ class Vertical(Nestor):
|
||||||
|
|
||||||
class TheWish(Game):
|
class TheWish(Game):
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 0
|
FILL_STACKS_AFTER_DROP = False
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
# create layout
|
# create layout
|
||||||
|
@ -853,7 +853,7 @@ class RightAndLeft_Talon(DealRowRedealTalonStack):
|
||||||
|
|
||||||
class RightAndLeft(Game):
|
class RightAndLeft(Game):
|
||||||
|
|
||||||
FILL_STACKS_AFTER_DROP = 0
|
FILL_STACKS_AFTER_DROP = False
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
# create layout
|
# create layout
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ class Voracious(Grandee):
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# //
|
# // Desert Island
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
||||||
class DesertIsland(Game):
|
class DesertIsland(Game):
|
||||||
|
|
|
@ -2783,11 +2783,9 @@ class ReserveStack(OpenStack):
|
||||||
|
|
||||||
class InvisibleStack(Stack):
|
class InvisibleStack(Stack):
|
||||||
def __init__(self, game, **cap):
|
def __init__(self, game, **cap):
|
||||||
##x, y = -500, -500 - len(game.allstacks)
|
x, y = game.getInvisibleCoords()
|
||||||
cardw, cardh = game.app.images.CARDW, game.app.images.CARDH
|
|
||||||
x, y = cardw+game.canvas.xmargin, cardh+game.canvas.ymargin
|
|
||||||
kwdefault(cap, max_move=0, max_accept=0)
|
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):
|
def assertStack(self):
|
||||||
Stack.assertStack(self)
|
Stack.assertStack(self)
|
||||||
|
|
|
@ -41,8 +41,9 @@ def init_root_window(root, app):
|
||||||
if color:
|
if color:
|
||||||
root.tk_setPalette(color) # for non-Tile widgets
|
root.tk_setPalette(color) # for non-Tile widgets
|
||||||
|
|
||||||
# standard Tk scrollbars work on OS X, but Tile ones look weird
|
if app.opt.tile_theme == 'aqua':
|
||||||
Tile.Scrollbar = Tkinter.Scrollbar
|
# standard Tk scrollbars work on OS X, but Tile ones look weird
|
||||||
|
Tile.Scrollbar = Tkinter.Scrollbar
|
||||||
|
|
||||||
else: # pure Tk
|
else: # pure Tk
|
||||||
#root.option_add(...)
|
#root.option_add(...)
|
||||||
|
|
Loading…
Add table
Reference in a new issue