From cf787d633e324b55e1ac5609388c15d59fc76fec Mon Sep 17 00:00:00 2001 From: skomoroh Date: Wed, 4 Jul 2007 21:34:05 +0000 Subject: [PATCH] + 1 new game * new category in gamedb: `GAMES_BY_INVENTORS' git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@183 efabe8c0-fbe8-4139-b769-b5e6d273206e --- pysollib/gamedb.py | 20 +++++++++++++++ pysollib/games/unionsquare.py | 47 ++++++++++++++++++++++++++++++++--- pysollib/options.py | 4 +-- pysollib/tile/selectgame.py | 12 +++++++-- pysollib/tk/selectgame.py | 13 +++++++--- 5 files changed, 85 insertions(+), 11 deletions(-) diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index 819ccf75..8936adbb 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -274,6 +274,26 @@ class GI: )), ) + GAMES_BY_INVENTORS = ( + ("Paul Alfille", (8,)), + ("C.L. Baker", (45,)), + ("David Bernazzani", (314,)), + ("Art Cabral", (9,)), + ("Charles Jewell", (220, 309,)), + ("Robert Harbin", (381,)), + ("Michael Keller", (592,)), + ("Fred Lunde", (459,)), + ("Albert Morehead and Geoffrey Mott-Smith", (25, 42, 48, 173, + 303, 547, 738)), + ("David Parlett", (64, 98, 294, 338, 654, 674,)), + ("Capt. Jeffrey T. Spaulding", (400,)), + ("John Stoneham", (201,)), + ("Bryan Stout", (655,)), + ("Bill Taylor", (349,)), + ("Thomas Warfield", (189, 264, 300, 320, 336, 337, 359, + 415, 427, 458, 495, 496, 497, 508,)), + ) + GAMES_BY_PYSOL_VERSION = ( ("1.00", (1, 2, 3, 4)), ("1.01", (5, 6)), diff --git a/pysollib/games/unionsquare.py b/pysollib/games/unionsquare.py index af9eaea5..5ba4afb9 100644 --- a/pysollib/games/unionsquare.py +++ b/pysollib/games/unionsquare.py @@ -32,7 +32,6 @@ __all__ = [] # imports -import sys # PySol imports from pysollib.gamedb import registerGame, GameInfo, GI @@ -50,7 +49,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint class UnionSquare_Foundation(AbstractFoundationStack): def acceptsCards(self, from_stack, cards): if not AbstractFoundationStack.acceptsCards(self, from_stack, cards): - return 0 + return False # check the rank if len(self.cards) > 12: return cards[0].rank == 25 - len(self.cards) @@ -89,6 +88,7 @@ class UnionSquare_RowStack(OpenStack): class UnionSquare(Game): Hint_Class = CautiousDefaultHint + Foundation_Class = StackWrapper(UnionSquare_Foundation, max_cards=26) RowStack_Class = UnionSquare_RowStack # @@ -119,8 +119,8 @@ class UnionSquare(Game): y = y + l.YS x, y = self.width-l.XS, l.YM for i in range(4): - stack = UnionSquare_Foundation(x, y, self, i, max_move=0, - dir=0, max_cards=26) + stack = self.Foundation_Class(x, y, self, suit=i, + max_move=0, dir=0) l.createText(stack, "sw") s.foundations.append(stack) y = y + l.YS @@ -174,6 +174,41 @@ class SolidSquare(UnionSquare): shallHighlightMatch = Game._shallHighlightMatch_SSW +# /*********************************************************************** +# // Boomerang +# ************************************************************************/ + +class Boomerang_Foundation(AbstractFoundationStack): + def acceptsCards(self, from_stack, cards): + if not AbstractFoundationStack.acceptsCards(self, from_stack, cards): + return False + # check the rank + # 7, 8, 9, 10, J, Q, K, A, K, Q, J, 10, 9, 8, 7, A + if len(self.cards) < 7: + return cards[0].rank - 6 == len(self.cards) + elif len(self.cards) == 7: + return cards[0].rank == ACE + elif len(self.cards) < 15: + return cards[0].rank == 20 - len(self.cards) + else: # len(self.cards) == 15 + return cards[0].rank == ACE + +class Boomerang(UnionSquare): + Foundation_Class = StackWrapper(Boomerang_Foundation, + base_rank=6, max_cards=16) + + def createGame(self): + UnionSquare.createGame(self, rows=12) + + def fillStack(self, stack): + if stack in self.s.rows and not stack.cards: + old_state = self.enterState(self.S_FILL) + if not self.s.waste.cards: + self.s.talon.dealCards() + if self.s.waste.cards: + self.s.waste.moveMove(1, stack) + self.leaveState(old_state) + # register the game registerGame(GameInfo(35, UnionSquare, "Union Square", @@ -182,3 +217,7 @@ registerGame(GameInfo(35, UnionSquare, "Union Square", )) registerGame(GameInfo(439, SolidSquare, "Solid Square", GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED)) +registerGame(GameInfo(738, Boomerang, "Boomerang", + GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED, + ranks=(0, 6, 7, 8, 9, 10, 11, 12), + )) diff --git a/pysollib/options.py b/pysollib/options.py index a212d3db..13449ed3 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -77,7 +77,7 @@ statusbar = boolean statusbar_game_number = boolean num_cards = boolean helpbar = boolean -num_recent_games = integer +num_recent_games = integer(10, 100) last_gameid = integer game_holded = integer wm_maximized = boolean @@ -90,7 +90,7 @@ save_cardsets = boolean dragcursor = boolean save_games_geometry = boolean sound = boolean -sound_mode = integer +sound_mode = integer(0, 1) sound_sample_volume = integer(0, 128) sound_music_volume = integer(0, 128) tabletile_name = string diff --git a/pysollib/tile/selectgame.py b/pysollib/tile/selectgame.py index 05c2f523..efd0ea0f 100644 --- a/pysollib/tile/selectgame.py +++ b/pysollib/tile/selectgame.py @@ -158,6 +158,15 @@ class SelectGameData(SelectDialogTreeData): if 1 and gg: s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg)) + s_by_inventors, gg = None, [] + for name, games in GI.GAMES_BY_INVENTORS: + select_func = lambda gi, games=games: gi.id in games + if name is None or not filter(select_func, self.all_games_gi): + continue + gg.append(SelectGameNode(None, name, select_func)) + if 1 and gg: + s_by_inventors = SelectGameNode(None, _("by Inventors"), + tuple(gg)) # ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName())) # @@ -232,6 +241,7 @@ class SelectGameData(SelectDialogTreeData): s_by_compatibility, )), s_by_pysol_version, + s_by_inventors, SelectGameNode(None, _("Other Categories"), ( SelectGameNode(None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN), @@ -255,7 +265,6 @@ class SelectGameData(SelectDialogTreeData): class SelectGameTreeWithPreview(SelectDialogTreeCanvas): data = None - html_viewer = None class SelectGameTree(SelectGameTreeWithPreview): @@ -422,7 +431,6 @@ class SelectGameDialogWithPreview(SelectGameDialog): self.preview_app = None self.updatePreview(gameid, animations=0) ##focus = self.tree.frame - SelectGameTreeWithPreview.html_viewer = None self.mainloop(focus, kw.timeout) def initKw(self, kw): diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index 3329c34d..260a5aaf 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -159,7 +159,15 @@ class SelectGameData(SelectDialogTreeData): if 1 and gg: s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg)) - pass + s_by_inventors, gg = None, [] + for name, games in GI.GAMES_BY_INVENTORS: + select_func = lambda gi, games=games: gi.id in games + if name is None or not filter(select_func, self.all_games_gi): + continue + gg.append(SelectGameNode(None, name, select_func)) + if 1 and gg: + s_by_inventors = SelectGameNode(None, _("by Inventors"), + tuple(gg)) # ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName())) # @@ -234,6 +242,7 @@ class SelectGameData(SelectDialogTreeData): s_by_compatibility, )), s_by_pysol_version, + s_by_inventors, SelectGameNode(None, _("Other Categories"), ( SelectGameNode(None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN), @@ -257,7 +266,6 @@ class SelectGameData(SelectDialogTreeData): class SelectGameTreeWithPreview(SelectDialogTreeCanvas): data = None - html_viewer = None class SelectGameTree(SelectGameTreeWithPreview): @@ -425,7 +433,6 @@ class SelectGameDialogWithPreview(SelectGameDialog): self.preview_app = None self.updatePreview(gameid, animations=0) ##focus = self.tree.frame - SelectGameTreeWithPreview.html_viewer = None self.mainloop(focus, kw.timeout) def initKw(self, kw):