From 3ed6a3c0b2162ad949bdc06f37b180efaa0998c3 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Thu, 22 Jun 2006 21:24:12 +0000 Subject: [PATCH] + 3 new games * added skill_level to gameinfodialog and playable preview git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@12 39dd0a4e-7c14-0410-91b3-c4f2d318f732 --- pysollib/app.py | 1 - pysollib/games/freecell.py | 31 +++++++++++++++++-- pysollib/games/spider.py | 39 ++++++++++++++++++++--- pysollib/hint.py | 2 ++ pysollib/stack.py | 4 +-- pysollib/tk/gameinfodialog.py | 1 + pysollib/tk/selectgame.py | 58 ++++++++++++++++++++--------------- 7 files changed, 101 insertions(+), 35 deletions(-) diff --git a/pysollib/app.py b/pysollib/app.py index 50222aa6..3cdc7f3e 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -59,7 +59,6 @@ from settings import TOP_SIZE, TOP_TITLE # Toolkit imports from pysoltk import tkname, tkversion, wm_withdraw, loadImage -from pysoltk import bind, unbind_destroy from pysoltk import MfxMessageDialog, MfxExceptionDialog from pysoltk import TclError, MfxRoot, MfxCanvas, MfxScrolledCanvas from pysoltk import PysolMenubar diff --git a/pysollib/games/freecell.py b/pysollib/games/freecell.py index 3aafff6c..25c949e1 100644 --- a/pysollib/games/freecell.py +++ b/pysollib/games/freecell.py @@ -263,15 +263,16 @@ class TripleFreecell(FreeCell): l, s = Layout(self), self.s # set window - max_rows = max(12, rows, reserves) + decks = self.gameinfo.decks + max_rows = max(decks*4, rows, reserves) w, h = l.XM+max_rows*l.XS, l.YM+3*l.YS+playcards*l.YOFFSET self.setSize(w, h) # create stacks s.talon = self.Talon_Class(l.XM, h-l.YS, self) - x, y = l.XM+(max_rows-12)*l.XS/2, l.YM - for i in range(3): + x, y = l.XM+(max_rows-decks*4)*l.XS/2, l.YM + for i in range(decks): for j in range(4): s.foundations.append(self.Foundation_Class(x, y, self, suit=j)) x += l.XS @@ -504,6 +505,28 @@ class FourColours(FreeCell): self.dealOne(frames=-1) +# /*********************************************************************** +# // Ocean Towers +# ************************************************************************/ + +class OceanTowers(TripleFreecell): + Hint_Class = FreeCellType_Hint + RowStack_Class = StackWrapper(FreeCell_SS_RowStack, base_rank=KING) + + def createGame(self): + TripleFreecell.createGame(self, rows=14, reserves=8, playcards=20) + + def startGame(self): + for i in range(6): + self.s.talon.dealRow(frames=0) + self.startDealSample() + self.s.talon.dealRow() + self.s.talon.dealRow(rows=self.s.reserves[1:-1]) + + def shallHighlightMatch(self, stack1, card1, stack2, card2): + return card1.suit == card2.suit and abs(card1.rank-card2.rank) == 1 + + # register the game registerGame(GameInfo(5, RelaxedFreeCell, "Relaxed FreeCell", @@ -542,4 +565,6 @@ registerGame(GameInfo(464, FourColours, "Four Colours", GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(509, BigCell, "Big Cell", GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(513, OceanTowers, "Ocean Towers", + GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index 928ee791..cc62099d 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -354,6 +354,31 @@ class ScorpionTail(Scorpion): return card1.color != card2.color and abs(card1.rank-card2.rank) == 1 +class DoubleScorpion(Scorpion): + Talon_Class = InitialDealTalonStack + def createGame(self): + RelaxedSpider.createGame(self, rows=10, playcards=26, texts=0) + def startGame(self): + for i in (5, 5, 5, 5, 0, 0, 0, 0, 0): + self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0) + self.s.talon.dealRow(rows=self.s.rows[i:], flip=1, frames=0) + self.startDealSample() + self.s.talon.dealRow() + self.s.talon.dealRowAvail() + + +class TripleScorpion(Scorpion): + Talon_Class = InitialDealTalonStack + def createGame(self): + RelaxedSpider.createGame(self, rows=13, playcards=30, texts=0) + def startGame(self): + for i in (5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0): + self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0) + self.s.talon.dealRow(rows=self.s.rows[i:], flip=1, frames=0) + self.startDealSample() + self.s.talon.dealRow() + + # /*********************************************************************** # // Wasp # ************************************************************************/ @@ -927,7 +952,7 @@ class York(RelaxedSpider): self.startDealSample() self.s.talon.dealRow(rows=self.s.rows[2:-2]) -class TripleYork(York): +class BigYork(York): def createGame(self): RelaxedSpider.createGame(self, rows=14, playcards=26, texts=0) @@ -1025,7 +1050,7 @@ registerGame(GameInfo(270, Spider2Suits, "Spider (2 suits)", registerGame(GameInfo(305, ThreeBlindMice, "Three Blind Mice", GI.GT_SPIDER, 1, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(309, MrsMop, "Mrs. Mop", - GI.GT_SPIDER | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL)) + GI.GT_SPIDER | GI.GT_OPEN, 2, 0, GI.SL_SKILL)) registerGame(GameInfo(341, Cicely, "Cicely", GI.GT_SPIDER, 2, 0, GI.SL_BALANCED)) registerGame(GameInfo(342, Trillium, "Trillium", @@ -1049,9 +1074,9 @@ registerGame(GameInfo(384, BigSpider, "Big Spider", registerGame(GameInfo(401, GroundForADivorce3Decks, "Big Ground", GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(441, York, "York", - GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) -registerGame(GameInfo(444, TripleYork, "Triple York", - GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL)) + GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_SKILL)) +registerGame(GameInfo(444, BigYork, "Big York", + GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_SKILL)) registerGame(GameInfo(445, BigSpider1Suit, "Big Spider (1 suit)", GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL, suits=(0, 0, 0, 0), @@ -1080,4 +1105,8 @@ registerGame(GameInfo(501, WakeRobin, "Wake-Robin", GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(502, TripleWakeRobin, "Wake-Robin (3 decks)", GI.GT_SPIDER | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(511, DoubleScorpion, "Double Scorpion", + GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL)) +registerGame(GameInfo(512, TripleScorpion, "Triple Scorpion", + GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL)) diff --git a/pysollib/hint.py b/pysollib/hint.py index 4a0144f3..35d47170 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -714,6 +714,8 @@ if os.name in ('posix', 'nt'): class FreeCellSolverWrapper: + __name__ = 'FreeCellSolverWrapper' # for gameinfodialog + class FreeCellSolver_Hint(AbstractHint): def str1(self, card): return "A23456789TJQK"[card.rank] + "CSHD"[card.suit] diff --git a/pysollib/stack.py b/pysollib/stack.py index 620f9337..b5db5d43 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -320,8 +320,8 @@ class Stack: bind(group, "<3>", self.__rightclickEventHandler) bind(group, "<2>", self.__middleclickEventHandler) bind(group, "", self.__middleclickEventHandler) - bind(self.group, "", self.__shiftrightclickEventHandler) - ##bind(self.group, "", "") + ##bind(group, "", self.__shiftrightclickEventHandler) + ##bind(group, "", "") bind(group, "", self.__enterEventHandler) bind(group, "", self.__leaveEventHandler) diff --git a/pysollib/tk/gameinfodialog.py b/pysollib/tk/gameinfodialog.py index 27730254..ce6ecb55 100644 --- a/pysollib/tk/gameinfodialog.py +++ b/pysollib/tk/gameinfodialog.py @@ -50,6 +50,7 @@ class GameInfoDialog(MfxDialog): game = app.game gi = game.gameinfo + # if gi.redeals == -2: redeals = 'VARIABLE' elif gi.redeals == -1: redeals = 'UNLIMITED' diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index 056d9733..e8cec38e 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -368,19 +368,20 @@ class SelectGameDialogWithPreview(SelectGameDialog): self.info_labels = {} i = 0 for n, t, f, row in ( - ('name', _('Name:'), info_frame, 0), - ('altnames', _('Alternate names:'), info_frame, 1), - ('category', _('Category:'), info_frame, 2), - ('type', _('Type:'), info_frame, 3), - ('decks', _('Decks:'), info_frame, 4), - ('redeals', _('Redeals:'), info_frame, 5), + ('name', _('Name:'), info_frame, 0), + ('altnames', _('Alternate names:'), info_frame, 1), + ('category', _('Category:'), info_frame, 2), + ('type', _('Type:'), info_frame, 3), + ('skill_level', _('Skill level:'), info_frame, 4), + ('decks', _('Decks:'), info_frame, 5), + ('redeals', _('Redeals:'), info_frame, 6), # - ('played', _('Played:'), stats_frame, 0), - ('won', _('Won:'), stats_frame, 1), - ('lost', _('Lost:'), stats_frame, 2), - ('time', _('Playing time:'), stats_frame, 3), - ('moves', _('Moves:'), stats_frame, 4), - ('percent', _('% won:'), stats_frame, 5), + ('played', _('Played:'), stats_frame, 0), + ('won', _('Won:'), stats_frame, 1), + ('lost', _('Lost:'), stats_frame, 2), + ('time', _('Playing time:'), stats_frame, 3), + ('moves', _('Moves:'), stats_frame, 4), + ('percent', _('% won:'), stats_frame, 5), ): title_label = Tkinter.Label(f, text=t, justify='left', anchor='w') title_label.grid(row=row, column=0, sticky='nw') @@ -541,6 +542,14 @@ class SelectGameDialogWithPreview(SelectGameDialog): type = '' if GI.TYPE_NAMES.has_key(gi.si.game_type): type = gettext(GI.TYPE_NAMES[gi.si.game_type]) + sl = { + GI.SL_LUCK: _('Luck only'), + GI.SL_MOSTLY_LUCK: _('Mostly luck'), + GI.SL_BALANCED: _('Balanced'), + GI.SL_MOSTLY_SKILL: _('Mostly skill'), + GI.SL_SKILL: _('Skill only'), + } + skill_level = sl.get(gi.skill_level) if gi.redeals == -2: redeals = _('variable') elif gi.redeals == -1: redeals = _('unlimited') else: redeals = str(gi.redeals) @@ -551,18 +560,19 @@ class SelectGameDialogWithPreview(SelectGameDialog): time = format_time(time) moves = str(round(moves, 1)) for n, t in ( - ('name', name), - ('altnames', altnames), - ('category', category), - ('type', type), - ('decks', gi.decks), - ('redeals', redeals), - ('played', won+lost), - ('won', won), - ('lost', lost), - ('time', time), - ('moves', moves), - ('percent', percent), + ('name', name), + ('altnames', altnames), + ('category', category), + ('type', type), + ('skill_level', skill_level), + ('decks', gi.decks), + ('redeals', redeals), + ('played', won+lost), + ('won', won), + ('lost', lost), + ('time', time), + ('moves', moves), + ('percent', percent), ): title_label, text_label = self.info_labels[n] if t == '':