From 3319f877a1713678644b011da076a8f2bbb870f9 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Sun, 26 Aug 2007 21:20:53 +0000 Subject: [PATCH] + 1 new game + new option: `Enable shuffle' git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@200 39dd0a4e-7c14-0410-91b3-c4f2d318f732 --- pysollib/actions.py | 8 +++-- pysollib/games/capricieuse.py | 68 +++++++++++++++++++++++++++++++++-- pysollib/options.py | 3 ++ pysollib/tile/menubar.py | 8 +++++ pysollib/tk/menubar.py | 8 +++++ pysollib/tk/tkwidget.py | 3 +- 6 files changed, 91 insertions(+), 7 deletions(-) diff --git a/pysollib/actions.py b/pysollib/actions.py index 0b3fa166..2e097ebc 100644 --- a/pysollib/actions.py +++ b/pysollib/actions.py @@ -198,7 +198,8 @@ class PysolMenubarActions: if game.gameinfo.si.game_type == GI.GT_CUSTOM: ms.custom_game = 1 if game.canShuffle(): - ms.shuffle = 1 + if opt.shuffle: + ms.shuffle = 1 # update menu items and toolbar def _updateMenus(self): @@ -492,8 +493,9 @@ class PysolMenubarActions: def mShuffle(self, *args): if self._cancelDrag(): return - if self.game.canShuffle(): - self.game._mahjonggShuffle() + if self.menustate.shuffle: + if self.game.canShuffle(): + self.game._mahjonggShuffle() def mStatus(self, *args): if self._cancelDrag(break_pause=False): return diff --git a/pysollib/games/capricieuse.py b/pysollib/games/capricieuse.py index e85ebfc0..73d0c955 100644 --- a/pysollib/games/capricieuse.py +++ b/pysollib/games/capricieuse.py @@ -133,11 +133,11 @@ class Strata(Game): for i in range(8): s.foundations.append(DieRussische_Foundation(x, y, self, suit=i%4, max_cards=8)) - x = x + l.XS + x += l.XS x, y, = l.XM+l.XS, l.YM+l.YS for i in range(8): s.rows.append(AC_RowStack(x, y, self, max_move=1, max_accept=1)) - x = x + l.XS + x += l.XS s.talon = RedealTalonStack(l.XM, l.YM+l.YS/2, self, max_rounds=3) l.createRoundText(s.talon, 'nn') @@ -177,6 +177,67 @@ class Fifteen(Capricieuse): return cards +# /*********************************************************************** +# // Choice +# ************************************************************************/ + +class Choice_Foundation(RK_FoundationStack): + def acceptsCards(self, from_stack, cards): + if not RK_FoundationStack.acceptsCards(self, from_stack, cards): + return False + # check the suit + num_cards = len(self.cards) + for f in self.game.s.foundations: + if len(f.cards) > num_cards: + suit = f.cards[num_cards].suit + break + else: + return True + return cards[0].suit == suit + + +class Choice(Game): + + def createGame(self, rows=8, playcards=16): + # create layout + l, s = Layout(self), self.s + + # set window + decks = self.gameinfo.decks + max_rows = max(8, rows) + self.setSize(l.XM + max_rows*l.XS, + l.YM + 2*l.YS + (playcards+4*decks)*l.YOFFSET) + + # create stacks + x, y = l.XM + (max_rows-8)*l.XS/2, l.YM + for i in range(8): + stack = Choice_Foundation(x, y, self, base_rank=(i+5), dir=0, + suit=ANY_SUIT, max_cards=(4*decks) ) + stack.CARD_YOFFSET = l.YOFFSET + s.foundations.append(stack) + x += l.XS + + x, y = l.XM + (max_rows-rows)*l.XS/2, l.YM + l.YS + (4*decks)*l.YOFFSET + for i in range(rows): + s.rows.append(AC_RowStack(x, y, self)) + x += l.XS + + x, y = self.width - l.XS, self.height - l.YS + s.talon = InitialDealTalonStack(x, y, self) + + # define stack-groups + l.defaultStackGroups() + + + def startGame(self): + for i in range(11): + self.s.talon.dealRowAvail(frames=0) + self.startDealSample() + self.s.talon.dealRowAvail() + + shallHighlightMatch = Game._shallHighlightMatch_AC + + # register the game registerGame(GameInfo(292, Capricieuse, "Capricieuse", @@ -190,4 +251,7 @@ registerGame(GameInfo(606, Strata, "Strata", altnames=('Persian Patience',) )) registerGame(GameInfo(673, Fifteen, "Fifteen", GI.GT_BAKERS_DOZEN | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(755, Choice, "Choice", + GI.GT_3DECK_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL, + ranks=(5, 6, 7, 8, 9, 10, 11, 12) )) diff --git a/pysollib/options.py b/pysollib/options.py index db7ab1d5..9b15409e 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -47,6 +47,7 @@ autofaceup = boolean autodrop = boolean autodeal = boolean quickplay = boolean +shuffle = boolean undo = boolean bookmarks = boolean hint = boolean @@ -174,6 +175,7 @@ class Options: ('autodrop', 'bool'), ('autodeal', 'bool'), ('quickplay', 'bool'), + ('shuffle', 'bool'), ('undo', 'bool'), ('bookmarks', 'bool'), ('hint', 'bool'), @@ -243,6 +245,7 @@ class Options: self.autodrop = False self.autodeal = True self.quickplay = True + self.shuffle = True self.undo = True self.bookmarks = True self.hint = True diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py index 9e0834b7..a874e510 100644 --- a/pysollib/tile/menubar.py +++ b/pysollib/tile/menubar.py @@ -217,6 +217,7 @@ class PysolMenubar(PysolMenubarActions): undo = Tkinter.BooleanVar(), bookmarks = Tkinter.BooleanVar(), hint = Tkinter.BooleanVar(), + shuffle = Tkinter.BooleanVar(), highlight_piles = Tkinter.BooleanVar(), highlight_cards = Tkinter.BooleanVar(), highlight_samerank = Tkinter.BooleanVar(), @@ -263,6 +264,7 @@ class PysolMenubar(PysolMenubarActions): tkopt.quickplay.set(opt.quickplay) tkopt.undo.set(opt.undo) tkopt.hint.set(opt.hint) + tkopt.shuffle.set(opt.shuffle) tkopt.bookmarks.set(opt.bookmarks) tkopt.highlight_piles.set(opt.highlight_piles) tkopt.highlight_cards.set(opt.highlight_cards) @@ -446,6 +448,7 @@ class PysolMenubar(PysolMenubarActions): submenu.add_checkbutton(label=n_("Enable &undo"), variable=self.tkopt.undo, command=self.mOptEnableUndo) submenu.add_checkbutton(label=n_("Enable &bookmarks"), variable=self.tkopt.bookmarks, command=self.mOptEnableBookmarks) submenu.add_checkbutton(label=n_("Enable &hint"), variable=self.tkopt.hint, command=self.mOptEnableHint) + submenu.add_checkbutton(label=n_("Enable shu&ffle"), variable=self.tkopt.shuffle, command=self.mOptEnableShuffle) submenu.add_checkbutton(label=n_("Enable highlight p&iles"), variable=self.tkopt.highlight_piles, command=self.mOptEnableHighlightPiles) submenu.add_checkbutton(label=n_("Enable highlight &cards"), variable=self.tkopt.highlight_cards, command=self.mOptEnableHighlightCards) submenu.add_checkbutton(label=n_("Enable highlight same &rank"), variable=self.tkopt.highlight_samerank, command=self.mOptEnableHighlightSameRank) @@ -1076,6 +1079,11 @@ class PysolMenubar(PysolMenubarActions): self.app.opt.hint = self.tkopt.hint.get() self.game.updateMenus() + def mOptEnableShuffle(self, *args): + if self._cancelDrag(break_pause=False): return + self.app.opt.shuffle = self.tkopt.shuffle.get() + self.game.updateMenus() + def mOptEnableHighlightPiles(self, *args): if self._cancelDrag(break_pause=False): return self.app.opt.highlight_piles = self.tkopt.highlight_piles.get() diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py index e4e3dc75..2a73850b 100644 --- a/pysollib/tk/menubar.py +++ b/pysollib/tk/menubar.py @@ -216,6 +216,7 @@ class PysolMenubar(PysolMenubarActions): undo = Tkinter.BooleanVar(), bookmarks = Tkinter.BooleanVar(), hint = Tkinter.BooleanVar(), + shuffle = Tkinter.BooleanVar(), highlight_piles = Tkinter.BooleanVar(), highlight_cards = Tkinter.BooleanVar(), highlight_samerank = Tkinter.BooleanVar(), @@ -261,6 +262,7 @@ class PysolMenubar(PysolMenubarActions): tkopt.quickplay.set(opt.quickplay) tkopt.undo.set(opt.undo) tkopt.hint.set(opt.hint) + tkopt.shuffle.set(opt.shuffle) tkopt.bookmarks.set(opt.bookmarks) tkopt.highlight_piles.set(opt.highlight_piles) tkopt.highlight_cards.set(opt.highlight_cards) @@ -451,6 +453,7 @@ class PysolMenubar(PysolMenubarActions): submenu.add_checkbutton(label=n_("Enable &undo"), variable=self.tkopt.undo, command=self.mOptEnableUndo) submenu.add_checkbutton(label=n_("Enable &bookmarks"), variable=self.tkopt.bookmarks, command=self.mOptEnableBookmarks) submenu.add_checkbutton(label=n_("Enable &hint"), variable=self.tkopt.hint, command=self.mOptEnableHint) + submenu.add_checkbutton(label=n_("Enable shu&ffle"), variable=self.tkopt.shuffle, command=self.mOptEnableShuffle) submenu.add_checkbutton(label=n_("Enable highlight p&iles"), variable=self.tkopt.highlight_piles, command=self.mOptEnableHighlightPiles) submenu.add_checkbutton(label=n_("Enable highlight &cards"), variable=self.tkopt.highlight_cards, command=self.mOptEnableHighlightCards) submenu.add_checkbutton(label=n_("Enable highlight same &rank"), variable=self.tkopt.highlight_samerank, command=self.mOptEnableHighlightSameRank) @@ -1077,6 +1080,11 @@ class PysolMenubar(PysolMenubarActions): self.app.opt.hint = self.tkopt.hint.get() self.game.updateMenus() + def mOptEnableShuffle(self, *args): + if self._cancelDrag(break_pause=False): return + self.app.opt.shuffle = self.tkopt.shuffle.get() + self.game.updateMenus() + def mOptEnableHighlightPiles(self, *args): if self._cancelDrag(break_pause=False): return self.app.opt.highlight_piles = self.tkopt.highlight_piles.get() diff --git a/pysollib/tk/tkwidget.py b/pysollib/tk/tkwidget.py index fbef7c4d..1260e0b9 100644 --- a/pysollib/tk/tkwidget.py +++ b/pysollib/tk/tkwidget.py @@ -674,8 +674,7 @@ class StackDesc: text = stack.getHelp()+'\n'+stack.getBaseCard() text = text.strip() if text: - frame = Tkinter.Frame(self.canvas, highlightthickness=1, - highlightbackground='black') + frame = Tkinter.Frame(self.canvas) self.frame = frame label = Tkinter.Message(frame, font=font, text=text, width=cardw-8, relief='solid',