From 7f0cb89de27f022521533201d3901109e81194a1 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Tue, 31 Jul 2007 21:31:52 +0000 Subject: [PATCH] * refactoring: `sound=0' -> `sound=False' ... * fixed loading options * fixed some games git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@189 39dd0a4e-7c14-0410-91b3-c4f2d318f732 --- pysollib/app.py | 6 ++-- pysollib/game.py | 8 ++--- pysollib/games/acesup.py | 6 ++-- pysollib/games/algerian.py | 8 ++--- pysollib/games/auldlangsyne.py | 16 ++++----- pysollib/games/bakersdozen.py | 4 +-- pysollib/games/braid.py | 4 +-- pysollib/games/bristol.py | 2 +- pysollib/games/calculation.py | 6 ++-- pysollib/games/camelot.py | 2 +- pysollib/games/canfield.py | 2 +- pysollib/games/dieboesesieben.py | 2 +- pysollib/games/fan.py | 12 +++---- pysollib/games/fortythieves.py | 6 ++-- pysollib/games/glenwood.py | 8 ++--- pysollib/games/grandduchess.py | 4 +-- pysollib/games/grandfathersclock.py | 8 ++--- pysollib/games/gypsy.py | 10 +++--- pysollib/games/katzenschwanz.py | 6 ++-- pysollib/games/klondike.py | 6 ++-- pysollib/games/labyrinth.py | 2 +- pysollib/games/larasgame.py | 4 +-- pysollib/games/mahjongg/mahjongg.py | 2 +- pysollib/games/matriarchy.py | 2 +- pysollib/games/montana.py | 2 +- pysollib/games/montecarlo.py | 4 +-- pysollib/games/numerica.py | 45 +++++++++++++------------ pysollib/games/parallels.py | 6 ++-- pysollib/games/pushpin.py | 4 +-- pysollib/games/pyramid.py | 4 +-- pysollib/games/royalcotillion.py | 12 +++---- pysollib/games/spider.py | 8 ++--- pysollib/games/sthelena.py | 6 ++-- pysollib/games/sultan.py | 8 ++--- pysollib/games/takeaway.py | 6 +--- pysollib/games/terrace.py | 8 ++--- pysollib/games/threepeaks.py | 2 +- pysollib/games/tournament.py | 6 ++-- pysollib/games/ultra/matrix.py | 4 +-- pysollib/games/yukon.py | 8 ++--- pysollib/help.py | 4 +-- pysollib/main.py | 14 ++++---- pysollib/options.py | 10 +++--- pysollib/stack.py | 52 ++++++++++++++--------------- pysollib/winsystems/x11.py | 3 +- 45 files changed, 175 insertions(+), 177 deletions(-) diff --git a/pysollib/app.py b/pysollib/app.py index 8810abc4..91f43054 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -1041,7 +1041,6 @@ Please select a %s type %s. def loadOptions(self): self.opt.setDefaults(self.top) - if os.path.exists(self.fn.opt): # for backwards compatibility opt = unpickle(self.fn.opt) @@ -1051,11 +1050,12 @@ Please select a %s type %s. os.remove(self.fn.opt) except: pass - self.opt.load(self.fn.opt_cfg) self.opt.setConstants() def loadStatistics(self): + if not os.path.exists(self.fn.stats): + return stats = unpickle(self.fn.stats) if stats: ##print "loaded:", stats.__dict__ @@ -1066,6 +1066,8 @@ Please select a %s type %s. self.stats.gameid_balance = 0 def loadComments(self): + if not os.path.exists(self.fn.comments): + return comments = unpickle(self.fn.comments) if comments: ##print "loaded:", comments.__dict__ diff --git a/pysollib/game.py b/pysollib/game.py index 0d7dec48..741ef0d6 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -1534,7 +1534,7 @@ class Game: return self.s.talon and self.s.talon.canDealCards() # deal cards - return number of cards dealt - def dealCards(self, sound=1): + def dealCards(self, sound=True): # default: set state to deal and pass dealing to Talon if self.s.talon and self.canDealCards(): self.finishMove() @@ -1788,7 +1788,7 @@ Congratulations, you did it ! return (self.sg.dropstacks, self.sg.dropstacks, self.sg.dropstacks) # handles autofaceup, autodrop and autodeal - def autoPlay(self, autofaceup=-1, autodrop=-1, autodeal=-1, sound=1): + def autoPlay(self, autofaceup=-1, autodrop=-1, autodeal=-1, sound=True): if self.demo: return 0 old_busy, self.busy = self.busy, 1 @@ -1843,7 +1843,7 @@ Congratulations, you did it ! return 1 return 0 - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): # default: deal a card to the waste if the waste is empty w = self.s.waste if w and len(w.cards) == 0 and self.canDealCards(): @@ -2384,7 +2384,7 @@ Congratulations, you did it ! sleep = demo.sleep # first try to deal cards to the Waste (unless there was a forced move) if not demo.hint or not demo.hint[6]: - if self._autoDeal(sound=0): + if self._autoDeal(sound=False): return 0 # display a hint h = self.showHint(demo.level, sleep, taken_hint=demo.hint) diff --git a/pysollib/games/acesup.py b/pysollib/games/acesup.py index 7d5601bb..11d97604 100644 --- a/pysollib/games/acesup.py +++ b/pysollib/games/acesup.py @@ -149,7 +149,7 @@ class Fortunes(AcesUp): # ************************************************************************/ class RussianAces_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = filter(lambda s: not s.cards, self.game.s.rows) if not rows: rows = self.game.s.rows @@ -171,7 +171,7 @@ class PerpetualMotion_Talon(DealRowTalonStack): return False return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): if self.cards: return DealRowTalonStack.dealCards(self, sound=sound) if sound: @@ -186,7 +186,7 @@ class PerpetualMotion_Talon(DealRowTalonStack): if self.cards[-1].face_up: game.flipMove(self) assert len(self.cards) == num_cards - n = DealRowTalonStack.dealCards(self, sound=0) + n = DealRowTalonStack.dealCards(self, sound=False) if sound: self.game.stopSamples() return n diff --git a/pysollib/games/algerian.py b/pysollib/games/algerian.py index 5a1b7cbb..3f383199 100644 --- a/pysollib/games/algerian.py +++ b/pysollib/games/algerian.py @@ -39,14 +39,14 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint # ************************************************************************/ class Carthage_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): if sound: self.game.startDealSample() if len(self.cards) == len(self.game.s.rows): - n = self.dealRowAvail(rows=self.game.s.rows, sound=0) + n = self.dealRowAvail(rows=self.game.s.rows, sound=False) else: - n = self.dealRowAvail(rows=self.game.s.reserves, sound=0) - n += self.dealRowAvail(rows=self.game.s.reserves, sound=0) + n = self.dealRowAvail(rows=self.game.s.reserves, sound=False) + n += self.dealRowAvail(rows=self.game.s.reserves, sound=False) if sound: self.game.stopSamples() return n diff --git a/pysollib/games/auldlangsyne.py b/pysollib/games/auldlangsyne.py index 8ce23eb6..ea6e2fda 100644 --- a/pysollib/games/auldlangsyne.py +++ b/pysollib/games/auldlangsyne.py @@ -342,19 +342,19 @@ class Primrose_Talon(DealRowTalonStack): self.game.flipMove(self) self.game.nextRoundMove(self) - def dealCards(self, sound=0): + def dealCards(self, sound=False): if sound: self.game.startDealSample() if len(self.cards) == 0: self._redeal() if self.round == 1: - n = self.dealRowAvail(sound=0) + n = self.dealRowAvail(sound=False) else: rows = self.game.s.rows - n = self.dealRowAvail(rows=rows[self.round-2:], sound=0) + n = self.dealRowAvail(rows=rows[self.round-2:], sound=False) #n = 0 while self.cards: - n += self.dealRowAvail(rows=rows, sound=0) + n += self.dealRowAvail(rows=rows, sound=False) if sound: self.game.stopSamples() return n @@ -455,12 +455,12 @@ class Amazons_Talon(RedealTalonStack): def canDealCards(self): return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): if not self.cards: RedealTalonStack.redealCards(self, frames=4, sound=sound) return self.dealRowAvail(sound=sound) - def dealRowAvail(self, rows=None, flip=1, reverse=0, frames=-1, sound=0): + def dealRowAvail(self, rows=None, flip=1, reverse=0, frames=-1, sound=False): if rows is None: rows = [] i = 0 @@ -518,7 +518,7 @@ class Scuffle_Talon(RedealTalonStack): return len(self.cards) != 0 return not self.game.isGameWon() - def dealCards(self, sound=0, shuffle=True): + def dealCards(self, sound=False, shuffle=True): if self.cards: return self.dealRowAvail(sound=sound) self.redealCards(frames=4, shuffle=shuffle, sound=sound) @@ -532,7 +532,7 @@ class Scuffle(AuldLangSyne): class Acquaintance_Talon(Scuffle_Talon): - def dealCards(self, sound=0): + def dealCards(self, sound=False): Scuffle_Talon.dealCards(self, sound=sound, shuffle=False) diff --git a/pysollib/games/bakersdozen.py b/pysollib/games/bakersdozen.py index 9f8de53a..d354378a 100644 --- a/pysollib/games/bakersdozen.py +++ b/pysollib/games/bakersdozen.py @@ -205,7 +205,7 @@ class Cruel_Talon(TalonStack): return False return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): lr = len(self.game.s.rows) # move all cards to the Talon and redeal (no shuffling) num_cards = 0 @@ -310,7 +310,7 @@ class Perseverance(Cruel, BakersDozen): cards = Cruel._shuffleHook(self, cards) return cards -## def dealCards(self, sound=1): +## def dealCards(self, sound=True): ## Cruel.dealCards(self, sound) diff --git a/pysollib/games/braid.py b/pysollib/games/braid.py index 5eeb6495..e78398a3 100644 --- a/pysollib/games/braid.py +++ b/pysollib/games/braid.py @@ -517,7 +517,7 @@ class Well_TalonStack(DealRowRedealTalonStack): def canDealCards(self): return DealRowRedealTalonStack.canDealCards(self, rows=self.game.s.wastes) - def dealCards(self, sound=0): + def dealCards(self, sound=False): num_cards = 0 if sound and self.game.app.opt.animations: self.game.startDealSample() @@ -526,7 +526,7 @@ class Well_TalonStack(DealRowRedealTalonStack): num_cards = self._redeal(rows=self.game.s.wastes, frames=3) self.game.nextRoundMove(self) wastes = self.game.s.wastes[:(6-self.round)] - num_cards += self.dealRowAvail(rows=wastes, frames=4, sound=0) + num_cards += self.dealRowAvail(rows=wastes, frames=4, sound=False) if sound: self.game.stopSamples() return num_cards diff --git a/pysollib/games/bristol.py b/pysollib/games/bristol.py index 7d716ab9..e7da8a0d 100644 --- a/pysollib/games/bristol.py +++ b/pysollib/games/bristol.py @@ -71,7 +71,7 @@ class Bristol_Hint(CautiousDefaultHint): # ************************************************************************/ class Bristol_Talon(TalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): return self.dealRowAvail(rows=self.game.s.reserves, sound=sound) diff --git a/pysollib/games/calculation.py b/pysollib/games/calculation.py index 28ed0308..be57a716 100644 --- a/pysollib/games/calculation.py +++ b/pysollib/games/calculation.py @@ -363,7 +363,7 @@ class SeniorWrangler_Talon(DealRowTalonStack): return False return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): num_cards = 0 r = self.game.s.rows[self.round-1] if not r.cards: @@ -375,9 +375,9 @@ class SeniorWrangler_Talon(DealRowTalonStack): while r.cards: self.game.flipMove(r) self.game.moveMove(1, r, self, frames=4, shadow=0) - self.dealRowAvail(rows=self.game.s.rows[self.round-1:], sound=0) + self.dealRowAvail(rows=self.game.s.rows[self.round-1:], sound=False) while self.cards: - num_cards += self.dealRowAvail(sound=0) + num_cards += self.dealRowAvail(sound=False) self.game.nextRoundMove(self) self.game.leaveState(old_state) if sound: diff --git a/pysollib/games/camelot.py b/pysollib/games/camelot.py index 0e52d2d1..0a9034a3 100644 --- a/pysollib/games/camelot.py +++ b/pysollib/games/camelot.py @@ -94,7 +94,7 @@ class Camelot_RowStack(ReserveStack): game = self.game if game.is_fill and self.cards and self.cards[0].rank == 9: game.playSample("autodrop", priority=20) - self.playMoveMove(1, game.s.foundations[0], sound=0) + self.playMoveMove(1, game.s.foundations[0], sound=False) self.fillStack() return True return False diff --git a/pysollib/games/canfield.py b/pysollib/games/canfield.py index d77d427e..4c7bba7c 100644 --- a/pysollib/games/canfield.py +++ b/pysollib/games/canfield.py @@ -715,7 +715,7 @@ class Demon(Canfield): # ************************************************************************/ class CanfieldRush_Talon(WasteTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): self.num_deal = 4-self.round WasteTalonStack.dealCards(self, sound=sound) diff --git a/pysollib/games/dieboesesieben.py b/pysollib/games/dieboesesieben.py index 95b5be7c..763febb9 100644 --- a/pysollib/games/dieboesesieben.py +++ b/pysollib/games/dieboesesieben.py @@ -53,7 +53,7 @@ class DieBoeseSieben_Talon(DieKoenigsbergerin_Talon): def canDealCards(self): return len(self.cards) or self.round != self.max_rounds - def dealCards(self, sound=0): + def dealCards(self, sound=False): if self.cards: return DieKoenigsbergerin_Talon.dealCards(self, sound=sound) game, num_cards = self.game, len(self.cards) diff --git a/pysollib/games/fan.py b/pysollib/games/fan.py index f825fb95..d4e5837b 100644 --- a/pysollib/games/fan.py +++ b/pysollib/games/fan.py @@ -191,7 +191,7 @@ class LaBelleLucie_Talon(TalonStack): def canDealCards(self): return self.round != self.max_rounds and not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): n = self.redealCards1() if n == 0: return 0 @@ -410,7 +410,7 @@ class Intelligence_RowStack(UD_SS_RowStack): if not self.cards: r = self.game.s.reserves[0] if r.cards: - r.dealRow((self,self,self), sound=1) + r.dealRow((self,self,self), sound=True) class Intelligence_ReserveStack(ReserveStack, DealRow_StackMethods): @@ -644,7 +644,7 @@ class Quads(Troika): # ************************************************************************/ class FascinationFan_Talon(RedealTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): RedealTalonStack.redealCards(self, shuffle=True, sound=sound) class FascinationFan(Fan): @@ -678,7 +678,7 @@ class FascinationFan(Fan): class Crescent_Talon(RedealTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): old_state = self.game.enterState(self.game.S_DEAL) ncards = 0 intern1, intern2 = self.game.s.internals @@ -813,7 +813,7 @@ class ForestGlade_Talon(DealRowRedealTalonStack): return False return True - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = [r for r in self.game.s.rows if not r.cards] if not rows or not self.cards: if sound and self.game.app.opt.animations: @@ -842,7 +842,7 @@ class ForestGlade_Talon(DealRowRedealTalonStack): for i in range(3): if not self.cards: break - ncards += self.dealRowAvail(rows=[r], sound=0) + ncards += self.dealRowAvail(rows=[r], sound=False) if sound: self.game.stopSamples() return ncards diff --git a/pysollib/games/fortythieves.py b/pysollib/games/fortythieves.py index 6af9ee05..c3a8cef3 100644 --- a/pysollib/games/fortythieves.py +++ b/pysollib/games/fortythieves.py @@ -520,7 +520,7 @@ class FinalBattle(DoubleRail): class Octave_Talon(WasteTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): if self.round == self.max_rounds: # last round old_state = self.game.enterState(self.game.S_DEAL) @@ -607,7 +607,7 @@ class Octave(Game): shallHighlightMatch = Game._shallHighlightMatch_AC - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): ncards = len(self.s.waste.cards) + sum([len(i.cards) for i in self.s.reserves]) if ncards == 0: return self.dealCards(sound=sound) @@ -878,7 +878,7 @@ class TheSpark_Talon(TalonStack): def canDealCards(self): return len(self.cards) > 0 - def dealCards(self, sound=0): + def dealCards(self, sound=False): old_state = self.game.enterState(self.game.S_DEAL) num_cards = 0 if self.cards: diff --git a/pysollib/games/glenwood.py b/pysollib/games/glenwood.py index 65463a17..539be55e 100644 --- a/pysollib/games/glenwood.py +++ b/pysollib/games/glenwood.py @@ -199,7 +199,7 @@ class DoubleFives_Talon(RedealTalonStack): return len(self.cards) != 0 return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): old_state = self.game.enterState(self.game.S_DEAL) num_cards = 0 if self.round == 1: @@ -208,10 +208,10 @@ class DoubleFives_Talon(RedealTalonStack): self.moveToStock() if not self.cards: num_cards += self.redealCards(rows=[self.game.s.stock], - frames=4, sound=0) + frames=4, sound=False) else: num_cards += self.dealRowAvail(rows=self.game.s.reserves[:5], - sound=0) + sound=False) if sound: self.game.stopSamples() else: @@ -315,7 +315,7 @@ class DoubleFives(Glenwood): self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.reserves[-2:]) - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): waste_cards = 0 for r in self.s.reserves[:5]: waste_cards += len(r.cards) diff --git a/pysollib/games/grandduchess.py b/pysollib/games/grandduchess.py index e52c21db..003df89c 100644 --- a/pysollib/games/grandduchess.py +++ b/pysollib/games/grandduchess.py @@ -46,11 +46,11 @@ class GrandDuchess_Talon(RedealTalonStack): return len(self.cards) != 0 return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = self.game.s.rows reserves = self.game.s.reserves if not self.cards: - RedealTalonStack.redealCards(self, rows=rows+reserves, sound=0) + RedealTalonStack.redealCards(self, rows=rows+reserves, sound=False) if sound and not self.game.demo: self.game.startDealSample() num_cards = 0 diff --git a/pysollib/games/grandfathersclock.py b/pysollib/games/grandfathersclock.py index 94f3d2ef..340c5877 100644 --- a/pysollib/games/grandfathersclock.py +++ b/pysollib/games/grandfathersclock.py @@ -367,17 +367,17 @@ class Hemispheres(Game): class BigBen_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = [s for s in self.game.s.rows if len(s.cards) < 3] if not rows: if sound and not self.game.demo: self.game.playSample("dealwaste") - return self.dealRow(rows=[self.game.s.waste], sound=0) + return self.dealRow(rows=[self.game.s.waste], sound=False) if sound and self.game.app.opt.animations: self.game.startDealSample() ncards = 0 while rows: - n = self.dealRowAvail(rows=rows, sound=0) + n = self.dealRowAvail(rows=rows, sound=False) if not n: break ncards += n @@ -466,7 +466,7 @@ class BigBen(Game): for i in range(3): self.s.talon.dealRow(frames=4) - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): # don't deal a card to the waste if the waste is empty return 0 diff --git a/pysollib/games/gypsy.py b/pysollib/games/gypsy.py index bc80925b..d2ab1f64 100644 --- a/pysollib/games/gypsy.py +++ b/pysollib/games/gypsy.py @@ -112,7 +112,7 @@ class Giant(Gypsy): class Irmgard_Talon(TalonStack): # A single click deals 9 (or 7) new cards to the RowStacks. - def dealCards(self, sound=0): + def dealCards(self, sound=False): if self.cards: if len(self.cards) > 7: c = self.dealRow(sound=sound) @@ -415,7 +415,7 @@ class Cone_Talon(DealRowTalonStack): return False return True - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = self.game.s.rows if len(self.cards) == 4: rows = self.game.s.reserves @@ -577,7 +577,7 @@ class RightTriangle_Talon(OpenStack, DealRowTalonStack): def clickHandler(self, event): if self.cards and not self.cards[-1].face_up: - return self.game.dealCards(sound=1) + return self.game.dealCards(sound=True) return OpenStack.clickHandler(self, event) def canDealCards(self): @@ -612,7 +612,7 @@ class RightTriangle(Hypotenuse): # ************************************************************************/ class Trapdoor_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): if not self.cards: return 0 if sound: @@ -626,7 +626,7 @@ class Trapdoor_Talon(DealRowTalonStack): if r1.cards: r1.moveMove(1, r2) n += 1 - n += self.dealRowAvail(rows=self.game.s.reserves, sound=0) + n += self.dealRowAvail(rows=self.game.s.reserves, sound=False) if sound: self.game.stopSamples() return n diff --git a/pysollib/games/katzenschwanz.py b/pysollib/games/katzenschwanz.py index c75df7ed..307171eb 100644 --- a/pysollib/games/katzenschwanz.py +++ b/pysollib/games/katzenschwanz.py @@ -225,7 +225,7 @@ class SalicLaw_Talon(OpenTalonStack): def canFlipCard(self): return False - def dealCards(self, sound=0): + def dealCards(self, sound=False): if len(self.cards) == 0: return 0 base_rank=self.game.ROW_BASE_RANK @@ -239,11 +239,11 @@ class SalicLaw_Talon(OpenTalonStack): to_stack = rows[ri-1] ##frames = (3, 4)[ri > 4] frames = 3 - if not self.game.demo: + if sound and not self.game.demo: self.game.startDealSample() self.game.flipMove(self) self.game.moveMove(1, self, to_stack, frames=frames) - if not self.game.demo: + if sound and not self.game.demo: self.game.stopSamples() self.game.leaveState(old_state) return 1 diff --git a/pysollib/games/klondike.py b/pysollib/games/klondike.py index c934b4d0..9b41ba97 100644 --- a/pysollib/games/klondike.py +++ b/pysollib/games/klondike.py @@ -607,7 +607,7 @@ class Jane_Talon(OpenTalonStack): def canDealCards(self): return len(self.cards) >= 2 - def dealCards(self, sound=0): + def dealCards(self, sound=False): c = 0 if len(self.cards) > 2: c = self.dealRow(self.game.s.reserves, sound=sound) @@ -675,12 +675,12 @@ class Jane(Klondike): shallHighlightMatch = Game._shallHighlightMatch_ACW - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): return 0 class AgnesBernauer_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): return self.dealRowAvail(self.game.s.reserves, sound=sound) diff --git a/pysollib/games/labyrinth.py b/pysollib/games/labyrinth.py index d1c203ba..4df100ff 100644 --- a/pysollib/games/labyrinth.py +++ b/pysollib/games/labyrinth.py @@ -39,7 +39,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint # ************************************************************************/ class Labyrinth_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): top_stacks = [] for i in range(8): for r in self.game.s.rows[i::8]: diff --git a/pysollib/games/larasgame.py b/pysollib/games/larasgame.py index aafbdda8..d1955c56 100644 --- a/pysollib/games/larasgame.py +++ b/pysollib/games/larasgame.py @@ -53,7 +53,7 @@ class LarasGame_Hint(CautiousDefaultHint): class LarasGame_Talon(WasteTalonStack): # Deal a card to each of the RowStacks. Then deal # cards to the talon. Return number of cards dealt. - def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=0): + def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=False): game = self.game if rows is None: rows = game.s.rows @@ -103,7 +103,7 @@ class LarasGame_Talon(WasteTalonStack): move(1, self, game.s.rows[-1], frames=frames) return len(stacks) - def dealCards(self, sound=0): + def dealCards(self, sound=False): game = self.game if sound and self.game.app.opt.animations: self.game.startDealSample() diff --git a/pysollib/games/mahjongg/mahjongg.py b/pysollib/games/mahjongg/mahjongg.py index 2f5cfcad..c30d3307 100644 --- a/pysollib/games/mahjongg/mahjongg.py +++ b/pysollib/games/mahjongg/mahjongg.py @@ -269,7 +269,7 @@ class Mahjongg_RowStack(OpenStack): if self.acceptsCards(from_stack, from_stack.cards): self._stopDrag() # this code actually moves the tiles - from_stack.playMoveMove(1, self, frames=0, sound=1) + from_stack.playMoveMove(1, self, frames=0, sound=True) return 1 drag.stack = self self.game.playSample("startdrag") diff --git a/pysollib/games/matriarchy.py b/pysollib/games/matriarchy.py index a18da085..ef131a91 100644 --- a/pysollib/games/matriarchy.py +++ b/pysollib/games/matriarchy.py @@ -85,7 +85,7 @@ class Matriarchy_Talon(WasteTalonStack): assert ncards > 0 return len(self.cards) >= ncards or self.round < self.max_rounds - def dealCards(self, sound=0): + def dealCards(self, sound=False): # get number of cards to deal ncards = self.DEAL[self.round-1] assert ncards > 0 diff --git a/pysollib/games/montana.py b/pysollib/games/montana.py index 865b759c..898e346e 100644 --- a/pysollib/games/montana.py +++ b/pysollib/games/montana.py @@ -86,7 +86,7 @@ class Montana_Talon(TalonStack): def _inSequence(self, card, suit, rank): return card.suit == suit and card.rank == rank - def dealCards(self, sound=0): + def dealCards(self, sound=False): # move cards to the Talon, shuffle and redeal game = self.game RLEN, RSTEP, RBASE = game.RLEN, game.RSTEP, game.RBASE diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index e57e9440..a1fad6c3 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -66,7 +66,7 @@ class MonteCarlo_Talon(TalonStack): return True return free and len(self.cards) - def dealCards(self, sound=0): + def dealCards(self, sound=False): self.game.updateStackMove(self.game.s.talon, 2|16) # for undo n = self.game.fillEmptyStacks() self.game.updateStackMove(self.game.s.talon, 1|16) # for redo @@ -345,7 +345,7 @@ class Neighbour_RowStack(MonteCarlo_RowStack): c = self.cards[-1] if c.face_up and c.rank == KING and not self.basicIsBlocked(): self.game.playSample("autodrop", priority=20) - self.playMoveMove(1, self.game.s.foundations[0], sound=0) + self.playMoveMove(1, self.game.s.foundations[0], sound=False) return 1 return 0 diff --git a/pysollib/games/numerica.py b/pysollib/games/numerica.py index e1c7dfbc..1450caaa 100644 --- a/pysollib/games/numerica.py +++ b/pysollib/games/numerica.py @@ -229,7 +229,7 @@ class PussInTheCorner_Talon(OpenTalonStack): else: return TalonStack.clickHandler(self, event) - def dealCards(self, sound=0): + def dealCards(self, sound=False): ncards = 0 old_state = self.game.enterState(self.game.S_DEAL) if not self.cards and self.round != self.max_rounds: @@ -315,7 +315,7 @@ class PussInTheCorner(Numerica): self.s.talon.fillStack() - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): return 0 @@ -473,6 +473,24 @@ class Gnat(Game): # // Chamberlain # ************************************************************************/ +class Gloaming_Hint(Numerica_Hint): + def computeHints(self): + self.step010(self.game.s.rows, self.game.s.rows) + self.step060(self.game.sg.reservestacks, self.game.s.rows) + + # try if we should move a card from a ReserveStack to a RowStack + def step060(self, reservestacks, rows): + for r in reservestacks: + if not r.cards: + continue + for t in rows: + if t.cards: + score = self._computeScore(r, t) + self.addHint(score, 1, r, t) + else: + self.addHint(90000+r.cards[-1].rank, 1, r, t) + + class Gloaming_RowStack(Numerica_RowStack): def acceptsCards(self, from_stack, cards): if not BasicRowStack.acceptsCards(self, from_stack, cards): @@ -483,7 +501,7 @@ class Gloaming_RowStack(Numerica_RowStack): class Gloaming(Game): - Hint_Class = Numerica_Hint + Hint_Class = Gloaming_Hint Foundation_Class = SS_FoundationStack def createGame(self, reserves=3, rows=5): @@ -544,23 +562,6 @@ class Chamberlain(Gloaming): # // Toad # ************************************************************************/ -class Toad_Hint(Numerica_Hint): - def computeHints(self): - self.step010(self.game.s.rows, self.game.s.rows) - self.step060(self.game.sg.reservestacks, self.game.s.rows) - - # try if we should move a card from a ReserveStack to a RowStack - def step060(self, reservestacks, rows): - for r in reservestacks: - if not r.cards: - continue - for t in rows: - if t.cards: - score = self._computeScore(r, t) - self.addHint(score, 1, r, t) - else: - self.addHint(90000+r.cards[-1].rank, 1, r, t) - class Toad_TalonStack(DealRowTalonStack): def canDealCards(self): @@ -570,12 +571,12 @@ class Toad_TalonStack(DealRowTalonStack): if r.cards: return False return True - def dealCards(self, sound=0): + def dealCards(self, sound=False): self.dealRow(rows=self.game.s.reserves, sound=sound) class Toad(Game): - Hint_Class = Toad_Hint + Hint_Class = Gloaming_Hint def createGame(self, reserves=3, rows=5): # create layout diff --git a/pysollib/games/parallels.py b/pysollib/games/parallels.py index a1779d12..7fea31e0 100644 --- a/pysollib/games/parallels.py +++ b/pysollib/games/parallels.py @@ -54,10 +54,10 @@ class Parallels_RowStack(BasicRowStack): class Parallels_TalonStack(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): return self.dealRow(sound=sound) - def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=0): + def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=False): if not rows is None: return DealRowTalonStack.dealRowAvail(self, rows=rows, flip=flip, reverse=reverse, frames=frames, sound=sound) @@ -76,7 +76,7 @@ class Parallels_TalonStack(DealRowTalonStack): return DealRowTalonStack.dealRowAvail(self, rows=r, flip=flip, reverse=reverse, frames=frames, sound=sound) - def _fillRow(self, frames=-1, sound=0): + def _fillRow(self, frames=-1, sound=False): rows = self.game.s.rows column_ncards = [] for i in range(10): diff --git a/pysollib/games/pushpin.py b/pysollib/games/pushpin.py index 5d5f233e..87c8b0c8 100644 --- a/pysollib/games/pushpin.py +++ b/pysollib/games/pushpin.py @@ -57,7 +57,7 @@ class PushPin_Foundation(AbstractFoundationStack): return True class PushPin_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): for r in self.game.s.rows: if not r.cards: return self.dealRowAvail(rows=[r], sound=sound) @@ -82,7 +82,7 @@ class PushPin_RowStack(ReserveStack): if self._checkPair(ps, ns): if not self.game.demo: self.game.playSample("autodrop", priority=20) - self.playMoveMove(1, self.game.s.foundations[0], sound=0) + self.playMoveMove(1, self.game.s.foundations[0], sound=False) return True return False diff --git a/pysollib/games/pyramid.py b/pysollib/games/pyramid.py index 5ab14c8a..d28f5f1f 100644 --- a/pysollib/games/pyramid.py +++ b/pysollib/games/pyramid.py @@ -74,7 +74,7 @@ class Pyramid_StackMethods: c = self.cards[-1] if c.face_up and c.rank == KING and not self.basicIsBlocked(): self.game.playSample("autodrop", priority=20) - self.playMoveMove(1, self.game.s.foundations[0], sound=0) + self.playMoveMove(1, self.game.s.foundations[0], sound=sound) return 1 return 0 @@ -790,7 +790,7 @@ class Pharaohs(Pyramid): # ************************************************************************/ class Baroness_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): rows = self.game.s.rows if len(self.cards) == 7: rows += self.game.s.reserves diff --git a/pysollib/games/royalcotillion.py b/pysollib/games/royalcotillion.py index 38278957..0f4ea5da 100644 --- a/pysollib/games/royalcotillion.py +++ b/pysollib/games/royalcotillion.py @@ -245,7 +245,7 @@ class Alhambra_Talon(DealRowTalonStack): return True return False - def dealCards(self, sound=0): + def dealCards(self, sound=False): old_state = self.game.enterState(self.game.S_DEAL) num_cards = 0 rows = self.game.s.rows @@ -253,7 +253,7 @@ class Alhambra_Talon(DealRowTalonStack): if self.cards: if sound and not self.game.demo: self.game.playSample("dealwaste") - num_cards = self.dealRowAvail(sound=0, frames=4) + num_cards = self.dealRowAvail(sound=False, frames=4) elif r_cards and self.round != self.max_rounds: if sound: self.game.playSample("turnwaste", priority=20) @@ -261,7 +261,7 @@ class Alhambra_Talon(DealRowTalonStack): for i in range(len(r.cards)): self.game.moveMove(1, r, self, frames=0) self.game.flipMove(self) - num_cards = self.dealRowAvail(sound=0, frames=4) + num_cards = self.dealRowAvail(sound=False, frames=4) self.game.nextRoundMove(self) self.game.leaveState(old_state) return num_cards @@ -579,14 +579,14 @@ class Twenty(Game): # ************************************************************************/ class ThreePirates_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): num_cards = 0 old_state = self.game.enterState(self.game.S_DEAL) if self.cards: if sound and not self.game.demo: self.game.playSample("dealwaste") num_cards = self.dealRowAvail(rows=self.game.s.reserves, - sound=0, frames=4) + sound=False, frames=4) self.game.leaveState(old_state) return num_cards @@ -1286,7 +1286,7 @@ class TwilightZone(Game): from_stack.moveMove(1, stack) self.leaveState(old_state) - def _autoDeal(self, sound=1): + def _autoDeal(self, sound=True): return 0 shallHighlightMatch = Game._shallHighlightMatch_AC diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index f0c9d821..4c25dfe4 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -186,7 +186,7 @@ class BlackWidow(Spider): class GroundForADivorce_Talon(TalonStack): # A single click deals a new cards to each non-empty row. - def dealCards(self, sound=1): + def dealCards(self, sound=True): if self.cards: rows = filter(lambda r: r.cards, self.game.s.rows) if not rows: @@ -514,12 +514,12 @@ class MrsMop(RelaxedSpider): # ************************************************************************/ class Cicely_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): n = 0 if sound: self.game.startDealSample() for i in range(4): - n += self.dealRow(rows=self.game.s.rows, sound=0) + n += self.dealRow(rows=self.game.s.rows, sound=False) if sound: self.game.stopSamples() return n @@ -1148,7 +1148,7 @@ class Tarantula(Spider): # ************************************************************************/ class FechtersGame_Talon(TalonStack): - def dealCards(self, sound=1): + def dealCards(self, sound=True): if self.cards: rows = [] for r in self.game.s.rows: diff --git a/pysollib/games/sthelena.py b/pysollib/games/sthelena.py index 5b0b367a..585dc777 100644 --- a/pysollib/games/sthelena.py +++ b/pysollib/games/sthelena.py @@ -46,7 +46,7 @@ class StHelena_Talon(TalonStack): return False return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): # move all cards to the Talon and redeal lr = len(self.game.s.rows) num_cards = 0 @@ -187,9 +187,9 @@ class LesQuatreCoins_Talon(RedealTalonStack): return len(self.cards) != 0 return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): if not self.cards: - RedealTalonStack.redealCards(self, sound=0) + RedealTalonStack.redealCards(self, sound=False) if sound and not self.game.demo: self.game.startDealSample() rows = self.game.s.rows diff --git a/pysollib/games/sultan.py b/pysollib/games/sultan.py index d0753829..085337d0 100644 --- a/pysollib/games/sultan.py +++ b/pysollib/games/sultan.py @@ -425,19 +425,19 @@ class Matrimony_Talon(DealRowTalonStack): self.game.nextRoundMove(self) return num_cards - def dealCards(self, sound=0): + def dealCards(self, sound=False): if sound: self.game.startDealSample() num_cards = 0 if len(self.cards) == 0: num_cards += self._redeal() if self.round == 1: - num_cards += self.dealRowAvail(sound=0) + num_cards += self.dealRowAvail(sound=False) else: rows = self.game.s.rows[-self.round+1:] - num_cards += self.dealRowAvail(rows=rows, sound=0) + num_cards += self.dealRowAvail(rows=rows, sound=False) while self.cards: - num_cards += self.dealRowAvail(rows=self.game.s.rows, sound=0) + num_cards += self.dealRowAvail(rows=self.game.s.rows, sound=False) if sound: self.game.stopSamples() return num_cards diff --git a/pysollib/games/takeaway.py b/pysollib/games/takeaway.py index dad95682..e507a33c 100644 --- a/pysollib/games/takeaway.py +++ b/pysollib/games/takeaway.py @@ -157,7 +157,7 @@ class Striptease(TakeAway): x += l.XS x += l.XS for i in range(4): - stack = Striptease_RowStack(x, y, self, max_move=0) + stack = Striptease_RowStack(x, y, self, max_move=0, mod=13) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET s.rows.append(stack) x += l.XS @@ -202,7 +202,3 @@ registerGame(GameInfo(335, FourStacks, "Four Stacks", registerGame(GameInfo(654, Striptease, "Striptease", GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_SKILL)) - - - - diff --git a/pysollib/games/terrace.py b/pysollib/games/terrace.py index 804da312..7b803b3d 100644 --- a/pysollib/games/terrace.py +++ b/pysollib/games/terrace.py @@ -108,7 +108,7 @@ class Terrace_RowStack(AC_RowStack): for s in self.game.s.foundations: s.cap.base_rank = to_stack.cards[0].rank freerows = filter(lambda s: not s.cards, self.game.s.rows) - self.game.s.talon.dealRow(rows=freerows, sound=1) + self.game.s.talon.dealRow(rows=freerows, sound=True) self.game.s.talon.dealCards() # deal first card to WasteStack @@ -349,7 +349,7 @@ class MamySusan(Terrace): class BastilleDay_BastilleStack(Stack): def clickHandler(self, event): - return self.dealCards(sound=1) + return self.dealCards(sound=True) def rightclickHandler(self, event): return self.clickHandler(event) @@ -359,7 +359,7 @@ class BastilleDay_BastilleStack(Stack): return 0 < len(self.cards) < 12 return len(self.cards) > 0 - def dealCards(self, sound=0): + def dealCards(self, sound=False): if not self.canDealCards(): return 0 old_state = self.game.enterState(self.game.S_DEAL) @@ -427,7 +427,7 @@ class BastilleDay(Game): self.s.talon.dealRow() self.s.talon.dealCards() - def dealCards(self, sound=1): + def dealCards(self, sound=True): # for demo-mode if self.demo: r = self.s.reserves[0] diff --git a/pysollib/games/threepeaks.py b/pysollib/games/threepeaks.py index 1a4315a6..27dd9f30 100644 --- a/pysollib/games/threepeaks.py +++ b/pysollib/games/threepeaks.py @@ -48,7 +48,7 @@ from golf import Golf_Waste, Golf_Hint class ThreePeaks_TalonStack(WasteTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): game = self.game game.sequence = 0 old_state = game.enterState(game.S_DEAL) diff --git a/pysollib/games/tournament.py b/pysollib/games/tournament.py index b3c40933..568c06a3 100644 --- a/pysollib/games/tournament.py +++ b/pysollib/games/tournament.py @@ -40,7 +40,7 @@ from pysollib.pysoltk import MfxCanvasText # ************************************************************************/ class Tournament_Talon(DealRowRedealTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): num_cards = 0 if sound and self.game.app.opt.animations: self.game.startDealSample() @@ -51,7 +51,7 @@ class Tournament_Talon(DealRowRedealTalonStack): for i in range(4): if not self.cards: break - num_cards += self.dealRow([r], sound=0) + num_cards += self.dealRow([r], sound=False) if sound: self.game.stopSamples() return num_cards @@ -151,7 +151,7 @@ class LaNivernaise(Tournament): # ************************************************************************/ class KingsdownEights_Talon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): if len(self.cards) == 0: self._redeal() self.game.startDealSample() diff --git a/pysollib/games/ultra/matrix.py b/pysollib/games/ultra/matrix.py index 6831e727..2e635667 100644 --- a/pysollib/games/ultra/matrix.py +++ b/pysollib/games/ultra/matrix.py @@ -113,11 +113,11 @@ class Matrix_RowStack(OpenStack): step = 1 from_stack = row[stack_map[j][i + dir]] while not from_stack is self: - from_stack.playMoveMove(1, to_stack, frames=0, sound=0) + from_stack.playMoveMove(1, to_stack, frames=0, sound=False) to_stack = from_stack step = step + 1 from_stack = row[stack_map[j][i + dir * step]] - self.playMoveMove(1, to_stack, frames=0, sound=0) + self.playMoveMove(1, to_stack, frames=0, sound=False) return 1 return 1 diff --git a/pysollib/games/yukon.py b/pysollib/games/yukon.py index 0c9566c6..691667b3 100644 --- a/pysollib/games/yukon.py +++ b/pysollib/games/yukon.py @@ -141,7 +141,7 @@ class Odessa(RussianSolitaire): # ************************************************************************/ class Grandfather_Talon(RedealTalonStack): - def redealCards(self, sound=0): + def redealCards(self, sound=False): RedealTalonStack.redealCards(self, sound=sound, shuffle=True) class Grandfather(RussianSolitaire): @@ -677,11 +677,11 @@ class Hawaiian(Game): # ************************************************************************/ class WaveTalon(DealRowTalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): if sound and self.game.app.opt.animations: self.game.startDealSample() - n = self.dealRowAvail(flip=0, sound=0) - n += self.dealRowAvail(sound=0) + n = self.dealRowAvail(flip=0, sound=False) + n += self.dealRowAvail(sound=False) if sound: self.game.stopSamples() return n diff --git a/pysollib/help.py b/pysollib/help.py index a79dd043..826ef9c9 100644 --- a/pysollib/help.py +++ b/pysollib/help.py @@ -48,7 +48,7 @@ from pysoltk import HTMLViewer # // # ************************************************************************/ -def help_about(app, timeout=0, sound=1): +def help_about(app, timeout=0, sound=True): if sound: app.audio.playSample("about") t = _("A Python Solitaire Game Collection\n") @@ -82,7 +82,7 @@ For more information about this application visit''') % (t, version), return d.status -def help_credits(app, timeout=0, sound=1): +def help_credits(app, timeout=0, sound=True): if sound: app.audio.playSample("credits") t = "" diff --git a/pysollib/main.py b/pysollib/main.py index 12591a52..9916072d 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -183,13 +183,6 @@ def pysol_init(app, args): traceback.print_exc() pass - # load options - try: - app.loadOptions() - except: - traceback.print_exc() - pass - # init DataLoader f = os.path.join("html", "license.html") app.dataloader = DataLoader(args[0], f) @@ -200,6 +193,13 @@ def pysol_init(app, args): app.top_bg = top.cget("bg") app.top_cursor = top.cget("cursor") + # load options + try: + app.loadOptions() + except: + traceback.print_exc() + pass + # init toolkit 2) init_root_window(top, app) diff --git a/pysollib/options.py b/pysollib/options.py index 13449ed3..a4767fe4 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -121,7 +121,6 @@ redo = boolean dealwaste = boolean [fonts] -default = list sans = list small = list fixed = list @@ -353,9 +352,6 @@ class Options: self.randomize_place = False self.save_cardsets = True self.dragcursor = True - # defaults & constants - self.setDefaults() - self.setConstants() def setDefaults(self, top=None): # toolbar @@ -366,7 +362,7 @@ class Options: self.fonts["sans"] = ("times new roman", 12) self.fonts["fixed"] = ("courier new", 10) elif WIN_SYSTEM == 'x11': - self.fonts["sans"] = ("helvetica", 12) + self.fonts["sans"] = ("helvetica", -12) # tile theme if WIN_SYSTEM == 'win32': self.tile_theme = self.default_tile_theme = 'winnative' @@ -444,6 +440,8 @@ class Options: # fonts for key, val in self.fonts.items(): + if key == 'default': + continue if val is None: continue config['fonts'][key] = val @@ -569,6 +567,8 @@ class Options: # fonts for key in self.fonts: + if key == 'default': + continue val = self._getOption('fonts', key, 'str') if val is not None: try: diff --git a/pysollib/stack.py b/pysollib/stack.py index 3f6276b2..37f39af8 100644 --- a/pysollib/stack.py +++ b/pysollib/stack.py @@ -708,7 +708,7 @@ class Stack: # Playing move actions. Better not override. # - def playFlipMove(self, sound=1, animation=False): + def playFlipMove(self, sound=True, animation=False): if sound: self.game.playSample("flip", 5) self.flipMove(animation=animation) @@ -716,7 +716,7 @@ class Stack: self.game.autoPlay() self.game.finishMove() - def playMoveMove(self, ncards, to_stack, frames=-1, shadow=-1, sound=1): + def playMoveMove(self, ncards, to_stack, frames=-1, shadow=-1, sound=True): if sound: if to_stack in self.game.s.foundations: self.game.playSample("drop", priority=30) @@ -998,7 +998,7 @@ class Stack: def shiftrightclickHandler(self, event): return 0 - def releaseHandler(self, event, drag, sound=1): + def releaseHandler(self, event, drag, sound=True): # default action: move cards back to their origin position if drag.cards: if sound: @@ -1171,7 +1171,7 @@ class Stack: return self.cards[index:] # begin a drag operation - def startDrag(self, event, sound=1): + def startDrag(self, event, sound=True): #print event.x, event.y assert self.game.drag.stack is None i = self._findCard(event) @@ -1516,7 +1516,7 @@ class Stack: class DealRow_StackMethods: # Deal a card to each of the RowStacks. Return number of cards dealt. - def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=0): + def dealRow(self, rows=None, flip=1, reverse=0, frames=-1, sound=False): if rows is None: rows = self.game.s.rows if sound and frames and self.game.app.opt.animations: self.game.startDealSample() @@ -1526,7 +1526,7 @@ class DealRow_StackMethods: return n # Same, but no error if not enough cards are available. - def dealRowAvail(self, rows=None, flip=1, reverse=0, frames=-1, sound=0): + def dealRowAvail(self, rows=None, flip=1, reverse=0, frames=-1, sound=False): if rows is None: rows = self.game.s.rows if sound and frames and self.game.app.opt.animations: self.game.startDealSample() @@ -1637,7 +1637,7 @@ class RedealCards_StackMethods: assert len(self.cards) == num_cards return num_cards - def redealCards(self, rows=None, sound=0, + def redealCards(self, rows=None, sound=False, shuffle=False, reverse=False, frames=0): if sound and self.game.app.opt.animations: self.game.startDealSample() @@ -1682,7 +1682,7 @@ class TalonStack(Stack, # Control of dealing is transferred to the game which usually # transfers it back to the Talon - see dealCards() below. def clickHandler(self, event): - return self.game.dealCards(sound=1) + return self.game.dealCards(sound=True) def rightclickHandler(self, event): return self.clickHandler(event) @@ -1693,7 +1693,7 @@ class TalonStack(Stack, # Actual dealing, usually called by Game.dealCards(). # Either deal all cards in Game.startGame(), or subclass responsibility. - def dealCards(self, sound=0): + def dealCards(self, sound=False): pass # remove all cards from all stacks @@ -1797,7 +1797,7 @@ class TalonStack(Stack, # A single click deals one card to each of the RowStacks. class DealRowTalonStack(TalonStack): - def dealCards(self, sound=0): + def dealCards(self, sound=False): return self.dealRowAvail(sound=sound) @@ -1816,7 +1816,7 @@ class RedealTalonStack(TalonStack, RedealCards_StackMethods): if self.round == self.max_rounds: return False return not self.game.isGameWon() - def dealCards(self, sound=0): + def dealCards(self, sound=False): RedealCards_StackMethods.redealCards(self, sound=sound) @@ -1832,7 +1832,7 @@ class DealRowRedealTalonStack(TalonStack, RedealCards_StackMethods): return True return False - def dealCards(self, sound=0, rows=None, shuffle=False): + def dealCards(self, sound=False, rows=None, shuffle=False): num_cards = 0 if rows is None: rows = self.game.s.rows @@ -1845,12 +1845,12 @@ class DealRowRedealTalonStack(TalonStack, RedealCards_StackMethods): # shuffle self.game.shuffleStackMove(self) self.game.nextRoundMove(self) - num_cards += self.dealRowAvail(rows=rows, sound=0) + num_cards += self.dealRowAvail(rows=rows, sound=False) if sound: self.game.stopSamples() return num_cards - def shuffleAndDealCards(self, sound=0, rows=None): + def shuffleAndDealCards(self, sound=False, rows=None): DealRowRedealTalonStack.dealCards(self, sound=sound, rows=rows, shuffle=True) @@ -1861,7 +1861,7 @@ class DealReserveRedealTalonStack(DealRowRedealTalonStack): return DealRowRedealTalonStack.canDealCards(self, rows=self.game.s.reserves) - def dealCards(self, sound=0, rows=None): + def dealCards(self, sound=False, rows=None): return DealRowRedealTalonStack.dealCards(self, sound=sound, rows=self.game.s.reserves) @@ -1878,7 +1878,7 @@ class SpiderTalonStack(DealRowRedealTalonStack): class GroundForADivorceTalonStack(DealRowRedealTalonStack): # A single click deals a new cards to each non-empty row. - def dealCards(self, sound=1): + def dealCards(self, sound=True): if self.cards: rows = filter(lambda r: r.cards, self.game.s.rows) ## if not rows: @@ -1964,7 +1964,7 @@ class OpenStack(Stack): to_stack, ncards = self.canDropCards(self.game.s.foundations) if to_stack: self.game.playSample("autodrop", priority=30) - self.playMoveMove(ncards, to_stack, sound=0) + self.playMoveMove(ncards, to_stack, sound=False) return 1 return 0 @@ -1974,14 +1974,14 @@ class OpenStack(Stack): return self.highlightMatchingCards(event) return 0 - def dragMove(self, drag, stack, sound=1): + def dragMove(self, drag, stack, sound=True): if self.game.app.opt.mouse_type == 'point-n-click': self.playMoveMove(len(drag.cards), stack, sound=sound) else: #self.playMoveMove(len(drag.cards), stack, frames=0, sound=sound) self.playMoveMove(len(drag.cards), stack, frames=-2, sound=sound) - def releaseHandler(self, event, drag, sound=1): + def releaseHandler(self, event, drag, sound=True): cards = drag.cards # check if we moved the card by at least 10 pixels if event is not None: @@ -2609,7 +2609,7 @@ class WasteTalonStack(TalonStack): return True return False - def dealCards(self, sound=0, shuffle=False): + def dealCards(self, sound=False, shuffle=False): old_state = self.game.enterState(self.game.S_DEAL) num_cards = 0 waste = self.waste @@ -2640,7 +2640,7 @@ class WasteTalonStack(TalonStack): self.game.leaveState(old_state) return num_cards - def shuffleAndDealCards(self, sound=0): + def shuffleAndDealCards(self, sound=False): WasteTalonStack.dealCards(self, sound=sound, shuffle=True) @@ -2653,7 +2653,7 @@ class FaceUpWasteTalonStack(WasteTalonStack): self.game.singleFlipMove(self) self.game.fillStack(self) - def dealCards(self, sound=0): + def dealCards(self, sound=False): WasteTalonStack.dealCards(self, sound=sound) if self.canFlipCard(): self.flipMove() @@ -2749,7 +2749,7 @@ class ArbitraryStack(OpenStack): def getDragCards(self, index): return [ self.cards[index] ] - def startDrag(self, event, sound=1): + def startDrag(self, event, sound=True): OpenStack.startDrag(self, event, sound=sound) if self.game.app.opt.mouse_type == 'point-n-click': self.cards[self.game.drag.index].tkraise() @@ -2773,7 +2773,7 @@ class ArbitraryStack(OpenStack): for s in self.game.s.foundations: if s is not self and s.acceptsCards(self, cards): self.game.playSample("autodrop", priority=30) - self.playSingleCardMove(i, s, sound=0) + self.playSingleCardMove(i, s, sound=False) return 1 return 0 @@ -2788,10 +2788,10 @@ class ArbitraryStack(OpenStack): self.game.singleCardMove(self, to_stack, index, frames=frames, shadow=shadow) self.fillStack() - def dragMove(self, drag, to_stack, sound=1): + def dragMove(self, drag, to_stack, sound=True): self.playSingleCardMove(drag.index, to_stack, frames=0, sound=sound) - def playSingleCardMove(self, index, to_stack, frames=-1, shadow=-1, sound=1): + def playSingleCardMove(self, index, to_stack, frames=-1, shadow=-1, sound=True): if sound: if to_stack in self.game.s.foundations: self.game.playSample("drop", priority=30) diff --git a/pysollib/winsystems/x11.py b/pysollib/winsystems/x11.py index b8e2033f..61c68713 100644 --- a/pysollib/winsystems/x11.py +++ b/pysollib/winsystems/x11.py @@ -125,8 +125,7 @@ def init_root_window(root, app): if fn: root.option_add('*font', font) app.opt.fonts['default'] = fn - if app.opt.tile_theme in ('clam', 'clearlooks'): - ##root.wm_minsize(550, 360) + if app.opt.tile_theme == 'clam': style.configure('TLabelframe', labeloutside=False, labelmargins=(8, 0, 8, 0))