From 5e588ab8bc547c3e3ccaaac83516045d649315e1 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Wed, 27 Sep 2006 21:12:16 +0000 Subject: [PATCH] - removed `closeStackMove' * bugs fixes git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@73 39dd0a4e-7c14-0410-91b3-c4f2d318f732 --- pysollib/game.py | 10 +--------- pysollib/games/picturegallery.py | 12 +++--------- pysollib/games/pileon.py | 5 +++-- pysollib/games/takeaway.py | 8 ++++++-- pysollib/move.py | 25 ------------------------- pysollib/stack.py | 14 +++++++------- pysollib/tk/menubar.py | 2 +- 7 files changed, 21 insertions(+), 55 deletions(-) diff --git a/pysollib/game.py b/pysollib/game.py index fc1d410f..b52018da 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -60,7 +60,7 @@ from pysoltk import Card from move import AMoveMove, AFlipMove, ATurnStackMove from move import ANextRoundMove, ASaveSeedMove, AShuffleStackMove from move import AUpdateStackMove, AFlipAllMove, ASaveStateMove -from move import ACloseStackMove, ASingleCardMove +from move import ASingleCardMove from hint import DefaultHint from help import help_about @@ -2155,14 +2155,6 @@ for %d moves. am.do(self) ##self.hints.list = None - # move type 10 - def closeStackMove(self, stack): - assert stack - am = ACloseStackMove(stack) - # don't store this move (???) - ##self.__storeMove(am) - am.do(self) - # for ArbitraryStack def singleCardMove(self, from_stack, to_stack, position, frames=-1, shadow=-1): am = ASingleCardMove(from_stack, to_stack, position, frames, shadow) diff --git a/pysollib/games/picturegallery.py b/pysollib/games/picturegallery.py index 8b8a8115..81227b28 100644 --- a/pysollib/games/picturegallery.py +++ b/pysollib/games/picturegallery.py @@ -143,9 +143,10 @@ class PictureGallery_Foundation(RK_FoundationStack): def getBottomImage(self): return self.game.app.images.getLetter(ACE) - def closeStackMove(self): + def closeStack(self): if len(self.cards) == 8: - self.game.flipAllMove(self) + if not self.game.moves.state == self.game.S_REDO: + self.game.flipAllMove(self) def canFlipCard(self): return False @@ -168,13 +169,6 @@ class PictureGallery_TableauStack(SS_RowStack): def getBottomImage(self): return self.game.app.images.getLetter(self.cap.base_rank) -## def closeStackMove(self): -## if len(self.cards) == self.cap.max_cards: -## self.game.closeStackMove(self) -## ##self.game.flipAllMove(self) -## def canFlipCard(self): -## return False - class PictureGallery_RowStack(BasicRowStack): def acceptsCards(self, from_stack, cards): diff --git a/pysollib/games/pileon.py b/pysollib/games/pileon.py index 636eef91..e7df1948 100644 --- a/pysollib/games/pileon.py +++ b/pysollib/games/pileon.py @@ -50,9 +50,10 @@ class PileOn_RowStack(RK_RowStack): def getBottomImage(self): return self.game.app.images.getReserveBottom() - def closeStackMove(self): + def closeStack(self): if len(self.cards) == 4 and isRankSequence(self.cards, dir=0): - self.game.flipAllMove(self) + if not self.game.moves.state == self.game.S_REDO: + self.game.flipAllMove(self) def canFlipCard(self): return False diff --git a/pysollib/games/takeaway.py b/pysollib/games/takeaway.py index c9773c14..dad95682 100644 --- a/pysollib/games/takeaway.py +++ b/pysollib/games/takeaway.py @@ -46,7 +46,7 @@ class TakeAway_Foundation(AbstractFoundationStack): return (c1.rank == (c2.rank + 1) % mod or c2.rank == (c1.rank + 1) % mod) - def closeStackMove(self): + def closeStack(self): pass @@ -101,9 +101,13 @@ class TakeAway(Game): # // Four Stacks # ************************************************************************/ +class FourStacks_Foundation(AC_FoundationStack): + def closeStack(self): + pass + class FourStacks(TakeAway): RowStack_Class = StackWrapper(AC_RowStack, max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS) - Foundation_Class = StackWrapper(AC_FoundationStack, max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS, dir=-1) + Foundation_Class = StackWrapper(FourStacks_Foundation, max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS, dir=-1) shallHighlightMatch = Game._shallHighlightMatch_AC diff --git a/pysollib/move.py b/pysollib/move.py index af78da62..b6064cd2 100644 --- a/pysollib/move.py +++ b/pysollib/move.py @@ -438,31 +438,6 @@ class AShuffleStackMove(AtomicMove): cmp(self.state, other.state)) -# /*********************************************************************** -# // ACloseStackMove -# ************************************************************************/ - -class ACloseStackMove(AtomicMove): - - def __init__(self, stack): - self.stack_id = stack.id - - def redo(self, game): - stack = game.allstacks[self.stack_id] - assert stack.cards - stack.is_filled = True - stack._shadeStack() - - def undo(self, game): - stack = game.allstacks[self.stack_id] - assert stack.cards - stack.is_filled = False - stack._unshadeStack() - - def cmpForRedo(self, other): - return cmp(self.stack_id, other.stack_id) - - # /*********************************************************************** # // ASingleCardMove - move single card from *anyone* position # // (for ArbitraryStack) diff --git a/pysollib/stack.py b/pysollib/stack.py index dd08257b..46099155 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -438,7 +438,7 @@ class Stack: view._position(card) if update: view.updateText() - self.closeStackMove() + self.closeStack() return card def insertCard(self, card, positon, unhide=1, update=1): @@ -454,8 +454,7 @@ class Stack: view._position(c) if update: view.updateText() - if not self.game.moves.state == self.game.S_REDO: - self.closeStackMove() + self.closeStack() return card # Remove a card from the stack. Also update display. {model -> view} @@ -663,7 +662,7 @@ class Stack: def fillStack(self): self.game.fillStack(self) - def closeStackMove(self): + def closeStack(self): pass # @@ -1251,7 +1250,7 @@ class Stack: drag.stack.group.tkraise() - # for closeStackMove + # for closeStack def _shadeStack(self): if not self.game.app.opt.shade_filled_stacks: return @@ -1966,9 +1965,10 @@ class AbstractFoundationStack(OpenStack): def getBaseCard(self): return self._getBaseCard() - def closeStackMove(self): + def closeStack(self): if len(self.cards) == self.cap.max_cards: - self.game.closeStackMove(self) + self.is_filled = True + self._shadeStack() def getHelp(self): return _('Foundation.') diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py index cbd315f9..87208604 100644 --- a/pysollib/tk/menubar.py +++ b/pysollib/tk/menubar.py @@ -75,7 +75,7 @@ def createToolbarMenu(menubar, menu): submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff) for f in os.listdir(data_dir): d = os.path.join(data_dir, f) - if os.path.isdir(d): + if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')): name = f.replace('_', ' ').capitalize() submenu.add_radiobutton(label=name, variable=menubar.tkopt.toolbar_style,