1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

* fixed using non-ascii filenames for background images

* refactoring: move getBottomImage to Stack as _get*BottomImage
* bugfixes


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@191 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2007-08-11 21:20:05 +00:00
parent f283ecd210
commit ea3e9d98e7
33 changed files with 139 additions and 170 deletions

View file

@ -1440,34 +1440,37 @@ Please select a %s type %s.
def initTiles(self): def initTiles(self):
manager = self.tabletile_manager manager = self.tabletile_manager
# find all available tiles # find all available tiles
# Note: we use a unicoded filenames
dirs = manager.getSearchDirs(self, dirs = manager.getSearchDirs(self,
("tiles-*", os.path.join("tiles", 'stretch')), (u"tiles-*", os.path.join(u"tiles", u"stretch")),
"PYSOL_TILES") "PYSOL_TILES")
##print dirs ##print dirs
s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$" s = "((\\" + ")|(\\".join(IMAGE_EXTENSIONS) + "))$"
ext_re = re.compile(s, re.I) ext_re = re.compile(s, re.I | re.U)
found, t = [], {} found, t = [], {}
for dir in dirs: for dir in dirs:
dir = dir.strip()
try: try:
names = [] names = []
if dir and os.path.isdir(dir): if dir and os.path.isdir(dir):
names = os.listdir(dir) names = os.listdir(dir)
names.sort()
for name in names: for name in names:
if not name or not ext_re.search(name): if not name or not ext_re.search(name):
continue continue
if not isinstance(name, unicode):
try:
name = unicode(name)
except:
continue
f = os.path.join(dir, name) f = os.path.join(dir, name)
if not os.path.isfile(f): if not os.path.isfile(f):
continue continue
tile = Tile() tile = Tile()
tile.filename = f tile.filename = f
n = ext_re.sub("", name.strip()) n = ext_re.sub("", name)
if os.path.split(dir)[-1] == 'stretch': if os.path.split(dir)[-1] == 'stretch':
tile.stretch = 1 tile.stretch = 1
#n = re.sub("[-_]", " ", n) #n = re.sub("[-_]", " ", n)
n = n.replace('_', ' ') n = n.replace('_', ' ')
##n = unicode(n)
tile.name = n tile.name = n
key = n.lower() key = n.lower()
if key not in t: if key not in t:

View file

@ -1641,18 +1641,19 @@ class Game:
self.updateStatus(stats=self.app.stats.getStats(self.app.opt.player, self.id)) self.updateStatus(stats=self.app.stats.getStats(self.app.opt.player, self.id))
top_msg = '' top_msg = ''
if ret: if ret:
if ret[0]: # playing time if ret[0] and ret[1]:
top_msg = _(''' top_msg = _('''
You have reached You have reached
#%d in the %s of playing time''') % (ret[0], TOP_TITLE) #%d in the %s of playing time
if ret[1]: # moves and #%d in the %s of moves.''') % (ret[0], TOP_TITLE, ret[1], TOP_TITLE)
if top_msg: elif ret[0]: # playing time
top_msg += _('''
and #%d in the %s of moves''') % (ret[1], TOP_TITLE)
else:
top_msg = _(''' top_msg = _('''
You have reached You have reached
#%d in the %s of moves''') % (ret[1], TOP_TITLE) #%d in the %s of playing time.''') % (ret[0], TOP_TITLE)
elif ret[1]: # moves
top_msg = _('''
You have reached
#%d in the %s of moves.''') % (ret[1], TOP_TITLE)
return top_msg return top_msg
elif not demo: elif not demo:
# only update the session log # only update the session log

View file

@ -287,7 +287,7 @@ class GI:
("Albert Morehead and Geoffrey Mott-Smith", (25, 42, 48, 173, ("Albert Morehead and Geoffrey Mott-Smith", (25, 42, 48, 173,
303, 547, 738)), 303, 547, 738)),
("David Parlett", (64, 98, 294, 338, 654, 674,)), ("David Parlett", (64, 98, 294, 338, 654, 674,)),
("Capt. Jeffrey T. Spaulding", (400,)), ("Captain Jeffrey T. Spaulding", (400,)),
("John Stoneham", (201,)), ("John Stoneham", (201,)),
("Bryan Stout", (655,)), ("Bryan Stout", (655,)),
("Bill Taylor", (349,)), ("Bill Taylor", (349,)),

View file

@ -153,8 +153,7 @@ class Strategy_RowStack(BasicRowStack):
return 1 return 1
return BasicRowStack.doubleclickHandler(self, event) return BasicRowStack.doubleclickHandler(self, event)
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
return _('Tableau. Build regardless of rank and suit.') return _('Tableau. Build regardless of rank and suit.')
@ -219,7 +218,7 @@ class StrategyPlus(Strategy):
while c.rank == ACE: while c.rank == ACE:
self.moveMove(1, stack, self.s.foundations[c.suit]) self.moveMove(1, stack, self.s.foundations[c.suit])
if stack.canFlipCard(): if stack.canFlipCard():
stack.flipMove() stack.flipMove(animation=True)
if not stack.cards: if not stack.cards:
break break
c = stack.cards[-1] c = stack.cards[-1]

View file

@ -99,8 +99,7 @@ class Braid_RowStack(ReserveStack):
if not self.cards and self.game.s.braid.cards: if not self.cards and self.game.s.braid.cards:
self.game.moveMove(1, self.game.s.braid, self) self.game.moveMove(1, self.game.s.braid, self)
def getBottomImage(self): getBottomImage = Stack._getBraidBottomImage
return self.game.app.images.getBraidBottom()
class Braid_ReserveStack(ReserveStack): class Braid_ReserveStack(ReserveStack):
@ -109,8 +108,7 @@ class Braid_ReserveStack(ReserveStack):
return False return False
return ReserveStack.acceptsCards(self, from_stack, cards) return ReserveStack.acceptsCards(self, from_stack, cards)
def getBottomImage(self): getBottomImage = Stack._getTalonBottomImage
return self.game.app.images.getTalonBottom()
# /*********************************************************************** # /***********************************************************************
@ -399,8 +397,9 @@ class JewelsStack(OpenStack):
class Casket_RowStack(SS_RowStack): class Casket_RowStack(SS_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom() getBottomImage = Stack._getReserveBottomImage
def acceptsCards(self, from_stack, cards): def acceptsCards(self, from_stack, cards):
if not SS_RowStack.acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards):
return False return False
@ -532,11 +531,6 @@ class Well_TalonStack(DealRowRedealTalonStack):
return num_cards return num_cards
class Well_RowStack(SS_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class Well(Game): class Well(Game):
Hint_Class = CautiousDefaultHint Hint_Class = CautiousDefaultHint
@ -570,13 +564,15 @@ class Well(Game):
(4,2), (4,2),
(2,4)): (2,4)):
x, y = x0+xx*l.XS, y0+yy*l.YS x, y = x0+xx*l.XS, y0+yy*l.YS
stack = Well_RowStack(x, y, self, dir=1, max_move=1) stack = SS_RowStack(x, y, self, dir=1, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
s.rows.append(stack) s.rows.append(stack)
# left stack # left stack
x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT
stack = Well_RowStack(x, y, self, base_rank=ACE, dir=1, max_move=1) stack = SS_RowStack(x, y, self, base_rank=ACE, dir=1, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
s.rows.append(stack) s.rows.append(stack)

View file

@ -86,8 +86,7 @@ class BetsyRoss_Foundation(RK_FoundationStack):
class Calculation_Foundation(BetsyRoss_Foundation): class Calculation_Foundation(BetsyRoss_Foundation):
def getBottomImage(self): getBottomImage = Stack._getLetterImage
return self.game.app.images.getLetter(self.cap.base_rank)
class Calculation_RowStack(BasicRowStack): class Calculation_RowStack(BasicRowStack):
@ -97,8 +96,7 @@ class Calculation_RowStack(BasicRowStack):
# this stack accepts any one card from the Waste pile # this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste and len(cards) == 1 return from_stack is self.game.s.waste and len(cards) == 1
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
return _('Tableau. Build regardless of rank and suit.') return _('Tableau. Build regardless of rank and suit.')

View file

@ -209,9 +209,6 @@ class Canfield(Game):
if not self.s.reserves[0].cards[-1].face_up: if not self.s.reserves[0].cards[-1].face_up:
self.s.reserves[0].flipMove() self.s.reserves[0].flipMove()
self.s.reserves[0].moveMove(1, stack) self.s.reserves[0].moveMove(1, stack)
elif stack in self.s.reserves:
if stack.canFlipCard():
stack.flipMove()
shallHighlightMatch = Game._shallHighlightMatch_ACW shallHighlightMatch = Game._shallHighlightMatch_ACW

View file

@ -621,8 +621,7 @@ class Troika(Fan):
class Quads_RowStack(RK_RowStack): class Quads_RowStack(RK_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Quads(Troika): class Quads(Troika):
RowStack_Class = StackWrapper(Quads_RowStack, dir=0, RowStack_Class = StackWrapper(Quads_RowStack, dir=0,

View file

@ -953,8 +953,7 @@ class TheSpark(Game):
# ************************************************************************/ # ************************************************************************/
class DoubleGoldMine_RowStack(AC_RowStack): class DoubleGoldMine_RowStack(AC_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class DoubleGoldMine(Streets): class DoubleGoldMine(Streets):

View file

@ -442,8 +442,7 @@ class Repair(FreeCell):
# ************************************************************************/ # ************************************************************************/
class FourColours_RowStack(AC_RowStack): class FourColours_RowStack(AC_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class FourColours(FreeCell): class FourColours(FreeCell):
Solver_Class = None Solver_Class = None
@ -484,8 +483,7 @@ class FourColours(FreeCell):
class GermanFreeCell_Reserve(ReserveStack): class GermanFreeCell_Reserve(ReserveStack):
def getBottomImage(self): getBottomImage = Stack._getSuitBottomImage
return self.game.app.images.getSuitBottom(self.cap.base_suit)
class GermanFreeCell(SevenByFour): class GermanFreeCell(SevenByFour):

View file

@ -415,8 +415,11 @@ class FourLeafClovers(Game):
for i in range(6): for i in range(6):
x = l.XM + i*l.XS x = l.XM + i*l.XS
s.rows.append(UD_RK_RowStack(x, y, self, mod=13, base_rank=NO_RANK)) s.rows.append(UD_RK_RowStack(x, y, self, mod=13, base_rank=NO_RANK))
stack = FourLeafClovers_Foundation(l.XM+6*l.XS, self.height-l.YS, self,
s.foundations.append(FourLeafClovers_Foundation(l.XM+6*l.XS, self.height-l.YS, self, ANY_SUIT, dir=0, mod=13, max_move=0, max_cards=52)) suit=ANY_SUIT, dir=0, mod=13,
max_move=0, max_cards=52)
s.foundations.append(stack)
l.createText(stack, 'n')
x, y = l.XM + 7*l.XS, self.height - l.YS x, y = l.XM + 7*l.XS, self.height - l.YS
s.talon = InitialDealTalonStack(x, y, self) s.talon = InitialDealTalonStack(x, y, self)

View file

@ -220,8 +220,7 @@ class MissMilligan_ReserveStack(AC_RowStack):
# the reserve stack and the Talon are empty. # the reserve stack and the Talon are empty.
return len(self.cards) == 0 and len(self.game.s.talon.cards) == 0 return len(self.cards) == 0 and len(self.game.s.talon.cards) == 0
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class MissMilligan(Gypsy): class MissMilligan(Gypsy):
@ -532,6 +531,9 @@ class Elba(Gypsy):
class Millie(Gypsy): class Millie(Gypsy):
Layout_Method = Layout.klondikeLayout Layout_Method = Layout.klondikeLayout
def createGame(self):
Gypsy.createGame(self, playcards=24)
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
@ -590,8 +592,7 @@ class RightTriangle_Talon(OpenStack, DealRowTalonStack):
def canFlipCard(self): def canFlipCard(self):
return False return False
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
return DealRowTalonStack.getHelp(self) return DealRowTalonStack.getHelp(self)

View file

@ -1145,8 +1145,7 @@ class GoldRush(Klondike):
# ************************************************************************/ # ************************************************************************/
class GoldMine_RowStack(AC_RowStack): class GoldMine_RowStack(AC_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class GoldMine(Klondike): class GoldMine(Klondike):

View file

@ -184,8 +184,7 @@ class LarasGame_Reserve(OpenStack):
return False return False
return from_stack in self.game.s.rows return from_stack in self.game.s.rows
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
# /*********************************************************************** # /***********************************************************************

View file

@ -141,8 +141,7 @@ class Matriarchy_UpRowStack(SS_RowStack):
min_cards=1, max_cards=12) min_cards=1, max_cards=12)
self.CARD_YOFFSET = -self.CARD_YOFFSET self.CARD_YOFFSET = -self.CARD_YOFFSET
def getBottomImage(self): getBottomImage = Stack._getSuitBottomImage
return self.game.app.images.getSuitBottom(self.cap.suit)
class Matriarchy_DownRowStack(SS_RowStack): class Matriarchy_DownRowStack(SS_RowStack):
@ -151,8 +150,7 @@ class Matriarchy_DownRowStack(SS_RowStack):
base_rank=QUEEN, mod=13, dir=-1, base_rank=QUEEN, mod=13, dir=-1,
min_cards=1, max_cards=12) min_cards=1, max_cards=12)
def getBottomImage(self): getBottomImage = Stack._getSuitBottomImage
return self.game.app.images.getSuitBottom(self.cap.suit)
# /*********************************************************************** # /***********************************************************************

View file

@ -158,8 +158,7 @@ class Montana_RowStack(BasicRowStack):
# bottom to get events for an empty stack # bottom to get events for an empty stack
prepareBottom = Stack.prepareInvisibleBottom prepareBottom = Stack.prepareInvisibleBottom
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Montana(Game): class Montana(Game):

View file

@ -119,25 +119,26 @@ class MonteCarlo(Game):
# game layout # game layout
# #
def createGame(self): def createGame(self, rows=5, cols=5):
# create layout # create layout
l, s = Layout(self), self.s l, s = Layout(self), self.s
# set window # set window
self.setSize(l.XM + 6.5*l.XS, l.YM + 5*l.YS) self.setSize(l.XM + (cols+1.5)*l.XS, l.YM + rows*l.YS)
# create stacks # create stacks
for i in range(5): for i in range(rows):
for j in range(5): for j in range(cols):
x, y = l.XM + j*l.XS, l.YM + i*l.YS x, y = l.XM + j*l.XS, l.YM + i*l.YS
s.rows.append(self.RowStack_Class(x, y, self, s.rows.append(self.RowStack_Class(x, y, self,
max_accept=1, max_cards=2, max_accept=1, max_cards=2,
dir=0, base_rank=NO_RANK)) dir=0, base_rank=NO_RANK))
x, y = l.XM + 11*l.XS/2, l.YM x, y = self.width - l.XS, l.YM
s.foundations.append(self.Foundation_Class(x, y, self, suit=ANY_SUIT, s.foundations.append(self.Foundation_Class(x, y, self, suit=ANY_SUIT,
max_move=0, max_cards=self.gameinfo.ncards, base_rank=ANY_RANK)) max_move=0, base_rank=ANY_RANK,
max_cards=self.gameinfo.ncards))
l.createText(s.foundations[0], "s") l.createText(s.foundations[0], "s")
y = y + 2*l.YS y += 2*l.YS
s.talon = self.Talon_Class(x, y, self, max_rounds=1) s.talon = self.Talon_Class(x, y, self, max_rounds=1)
l.createText(s.talon, "s", text_format="%D") l.createText(s.talon, "s", text_format="%D")
@ -831,7 +832,7 @@ class DoubletsII(Game):
def fillStack(self, stack): def fillStack(self, stack):
if stack in self.s.rows: if stack in self.s.rows:
if stack.cards: if stack.cards:
stack.flipMove() stack.flipMove(animation=True)
else: else:
if self.s.talon.cards: if self.s.talon.cards:
old_state = self.enterState(self.S_FILL) old_state = self.enterState(self.S_FILL)

View file

@ -53,8 +53,7 @@ from braid import Braid_Foundation
class Napoleon_RowStack(UD_SS_RowStack): class Napoleon_RowStack(UD_SS_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Napoleon_ReserveStack(BasicRowStack): class Napoleon_ReserveStack(BasicRowStack):

View file

@ -85,8 +85,7 @@ class Numerica_RowStack(BasicRowStack):
# this stack accepts any one card from the Waste pile # this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste and len(cards) == 1 return from_stack is self.game.s.waste and len(cards) == 1
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
##return _('Tableau. Accepts any one card from the Waste.') ##return _('Tableau. Accepts any one card from the Waste.')
@ -263,13 +262,15 @@ class PussInTheCorner_Foundation(SS_FoundationStack):
class PussInTheCorner_RowStack(BasicRowStack): class PussInTheCorner_RowStack(BasicRowStack):
def acceptsCards(self, from_stack, cards): def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards): if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False return False
# this stack accepts any one card from the Talon # this stack accepts any one card from the Talon
return from_stack is self.game.s.talon and len(cards) == 1 return from_stack is self.game.s.talon and len(cards) == 1
def getBottomImage(self):
return self.game.app.images.getReserveBottom() getBottomImage = Stack._getReserveBottomImage
def getHelp(self): def getHelp(self):
##return _('Tableau. Accepts any one card from the Waste.') ##return _('Tableau. Accepts any one card from the Waste.')
return _('Tableau. Build regardless of rank and suit.') return _('Tableau. Build regardless of rank and suit.')
@ -659,8 +660,7 @@ class Strategerie_RowStack(BasicRowStack):
return True return True
return False return False
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
return _('Tableau. Build regardless of rank and suit.') return _('Tableau. Build regardless of rank and suit.')

View file

@ -166,8 +166,7 @@ class PictureGallery_TableauStack(SS_RowStack):
return False return False
return True return True
def getBottomImage(self): getBottomImage = Stack._getLetterImage
return self.game.app.images.getLetter(self.cap.base_rank)
class PictureGallery_RowStack(BasicRowStack): class PictureGallery_RowStack(BasicRowStack):
@ -179,8 +178,7 @@ class PictureGallery_RowStack(BasicRowStack):
return False return False
return True return True
def getBottomImage(self): getBottomImage = Stack._getTalonBottomImage
return self.game.app.images.getTalonBottom()
# /*********************************************************************** # /***********************************************************************
@ -313,8 +311,7 @@ class GreatWheel_RowStack(BasicRowStack):
c1, c2 = self.cards[-1], cards[0] c1, c2 = self.cards[-1], cards[0]
return c1.suit == c2.suit and c1.rank == c2.rank+1 return c1.suit == c2.suit and c1.rank == c2.rank+1
def getBottomImage(self): getBottomImage = Stack._getTalonBottomImage
return self.game.app.images.getTalonBottom()
class GreatWheel(PictureGallery): class GreatWheel(PictureGallery):
@ -374,10 +371,6 @@ class GreatWheel(PictureGallery):
# ************************************************************************/ # ************************************************************************/
class MountOlympus_Foundation(SS_FoundationStack): class MountOlympus_Foundation(SS_FoundationStack):
#def getBottomImage(self):
# return self.game.app.images.getLetter(self.cap.base_rank)
def getHelp(self): def getHelp(self):
return 'Build up in suit by twos.' return 'Build up in suit by twos.'

View file

@ -49,8 +49,7 @@ from pysollib.pysoltk import MfxCanvasText
# ************************************************************************/ # ************************************************************************/
class PileOn_RowStack(RK_RowStack): class PileOn_RowStack(RK_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def closeStack(self): def closeStack(self):
if len(self.cards) == 4 and isRankSequence(self.cards, dir=0): if len(self.cards) == 4 and isRankSequence(self.cards, dir=0):
@ -255,11 +254,6 @@ class FourByFour_Foundation(AbstractFoundationStack):
return _('Foundation. Build up regardless of suit.') return _('Foundation. Build up regardless of suit.')
class FourByFour_RowStack(UD_RK_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class FourByFour(Game): class FourByFour(Game):
Hint_Class = FourByFour_Hint Hint_Class = FourByFour_Hint
@ -287,7 +281,9 @@ class FourByFour(Game):
x, y = l.XM+3*l.XS, l.YM+l.YS x, y = l.XM+3*l.XS, l.YM+l.YS
for i in range(4): for i in range(4):
s.rows.append(FourByFour_RowStack(x, y, self, mod=13)) stack = UD_RK_RowStack(x, y, self, mod=13)
stack.getBottomImage = stack._getReserveBottomImage
s.rows.append(stack)
x += l.XS x += l.XS
l.defaultStackGroups() l.defaultStackGroups()

View file

@ -62,8 +62,7 @@ class PushPin_Talon(DealRowTalonStack):
if not r.cards: if not r.cards:
return self.dealRowAvail(rows=[r], sound=sound) return self.dealRowAvail(rows=[r], sound=sound)
return self.dealRowAvail(rows=[self.game.s.rows[0]], sound=sound) return self.dealRowAvail(rows=[self.game.s.rows[0]], sound=sound)
def getBottomImage(self): getBottomImage = Stack._getBlankBottomImage
return self.game.app.images.getBlankBottom()
class PushPin_RowStack(ReserveStack): class PushPin_RowStack(ReserveStack):
@ -117,8 +116,7 @@ class PushPin_RowStack(ReserveStack):
game.updateStackMove(game.s.talon, 1|16) # for redo game.updateStackMove(game.s.talon, 1|16) # for redo
game.leaveState(old_state) game.leaveState(old_state)
def getBottomImage(self): getBottomImage = Stack._getBlankBottomImage
return self.game.app.images.getBlankBottom()
class PushPin(Game): class PushPin(Game):

View file

@ -232,8 +232,7 @@ class Alhambra_Hint(CautiousDefaultHint):
class Alhambra_RowStack(UD_SS_RowStack): class Alhambra_RowStack(UD_SS_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Alhambra_Talon(DealRowTalonStack): class Alhambra_Talon(DealRowTalonStack):
@ -930,11 +929,6 @@ class ShadyLanes(Game):
# // Boxing the Compass # // Boxing the Compass
# ************************************************************************/ # ************************************************************************/
class FourWinds_RowStack(ReserveStack):
def getBottomImage(self):
return self.game.app.images.getSuitBottom(self.cap.base_suit)
class FourWinds(Game): class FourWinds(Game):
def createGame(self): def createGame(self):
@ -946,7 +940,9 @@ class FourWinds(Game):
for i in (0, 1): for i in (0, 1):
y = l.YM+l.YS y = l.YM+l.YS
for j in range(4): for j in range(4):
s.rows.append(FourWinds_RowStack(x, y, self, base_suit=i)) stack = ReserveStack(x, y, self, base_suit=i)
stack.getBottomImage = stack._getSuitBottomImage
s.rows.append(stack)
y += l.YS y += l.YS
x += 6*l.XS x += 6*l.XS
# horizontal rows # horizontal rows
@ -954,7 +950,9 @@ class FourWinds(Game):
for i in (2, 3): for i in (2, 3):
x = l.XM+2.5*l.XS x = l.XM+2.5*l.XS
for j in range(4): for j in range(4):
s.rows.append(FourWinds_RowStack(x, y, self, base_suit=i)) stack = ReserveStack(x, y, self, base_suit=i)
stack.getBottomImage = stack._getSuitBottomImage
s.rows.append(stack)
x += l.XS x += l.XS
y += 3*l.YS y += 3*l.YS
# foundations # foundations
@ -1055,8 +1053,7 @@ class Colonel_RowStack(SS_RowStack):
return False return False
return SS_RowStack.canMoveCards(self, cards) return SS_RowStack.canMoveCards(self, cards)
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Colonel(Game): class Colonel(Game):
@ -1122,10 +1119,6 @@ class TheRedAndTheBlack_Reserve(ReserveStack):
return True return True
return False return False
class TheRedAndTheBlack_RowStack(AC_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class TheRedAndTheBlack(Game): class TheRedAndTheBlack(Game):
Hint_Class = CautiousDefaultHint Hint_Class = CautiousDefaultHint
@ -1142,7 +1135,8 @@ class TheRedAndTheBlack(Game):
x += l.XS x += l.XS
x, y = l.XM+2*l.XS, l.YM+l.YS x, y = l.XM+2*l.XS, l.YM+l.YS
for i in range(4): for i in range(4):
stack = TheRedAndTheBlack_RowStack(x, y, self, max_move=1) stack = AC_RowStack(x, y, self, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
s.rows.append(stack) s.rows.append(stack)
x += l.XS x += l.XS

View file

@ -108,8 +108,7 @@ class SiebenBisAs_RowStack(BasicRowStack):
# bottom to get events for an empty stack # bottom to get events for an empty stack
###prepareBottom = Stack.prepareInvisibleBottom ###prepareBottom = Stack.prepareInvisibleBottom
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class SiebenBisAs(Game): class SiebenBisAs(Game):
@ -195,8 +194,7 @@ class Maze_RowStack(BasicRowStack):
# bottom to get events for an empty stack # bottom to get events for an empty stack
prepareBottom = Stack.prepareInvisibleBottom prepareBottom = Stack.prepareInvisibleBottom
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Maze(Game): class Maze(Game):

View file

@ -687,8 +687,7 @@ class CornerSuite_RowStack(RK_RowStack):
if not self.cards: if not self.cards:
return from_stack is self.game.s.waste return from_stack is self.game.s.waste
return True return True
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class CornerSuite(Game): class CornerSuite(Game):
@ -791,11 +790,6 @@ class Marshal(Game):
# // Royal Aids # // Royal Aids
# ************************************************************************/ # ************************************************************************/
class RoyalAids_RowStack(KingAC_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class RoyalAids(Game): class RoyalAids(Game):
Hint_Class = CautiousDefaultHint Hint_Class = CautiousDefaultHint
@ -823,7 +817,8 @@ class RoyalAids(Game):
x, y = l.XM+3.75*l.XS, l.YM+2*l.YS x, y = l.XM+3.75*l.XS, l.YM+2*l.YS
for i in (0,1): for i in (0,1):
stack = RoyalAids_RowStack(x, y, self, max_move=1) stack = KingAC_RowStack(x, y, self, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage
s.rows.append(stack) s.rows.append(stack)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
x += l.XS x += l.XS

View file

@ -49,6 +49,9 @@ class TakeAway_Foundation(AbstractFoundationStack):
def closeStack(self): def closeStack(self):
pass pass
def getHelp(self):
return _('Foundation. Build up or down regardless of suit.')
class TakeAway(Game): class TakeAway(Game):
@ -127,8 +130,8 @@ class Striptease_RowStack(UD_RK_RowStack):
(r2 == JACK and r1 == KING)): (r2 == JACK and r1 == KING)):
return True return True
return ((r1+1) % 13 == r2 or (r2+1) % 13 == r1) return ((r1+1) % 13 == r2 or (r2+1) % 13 == r1)
def getBottomImage(self):
return self.game.app.images.getReserveBottom() getBottomImage = Stack._getReserveBottomImage
class Striptease_Reserve(OpenStack): class Striptease_Reserve(OpenStack):

View file

@ -111,9 +111,7 @@ class Terrace_RowStack(AC_RowStack):
self.game.s.talon.dealRow(rows=freerows, sound=True) self.game.s.talon.dealRow(rows=freerows, sound=True)
self.game.s.talon.dealCards() # deal first card to WasteStack self.game.s.talon.dealCards() # deal first card to WasteStack
getBottomImage = Stack._getReserveBottomImage
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
# /*********************************************************************** # /***********************************************************************

View file

@ -164,10 +164,6 @@ class KingsdownEights_Talon(DealRowTalonStack):
self.game.stopSamples() self.game.stopSamples()
return n return n
class KingsdownEights_Row(AC_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class KingsdownEights(Game): class KingsdownEights(Game):
Hint_Class = CautiousDefaultHint Hint_Class = CautiousDefaultHint
@ -191,7 +187,8 @@ class KingsdownEights(Game):
x += l.XS x += l.XS
x, y = l.XM+2*l.XS, l.YM x, y = l.XM+2*l.XS, l.YM
for i in range(8): for i in range(8):
stack = KingsdownEights_Row(x, y, self, max_move=1) stack = AC_RowStack(x, y, self, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
s.rows.append(stack) s.rows.append(stack)
x += l.XS x += l.XS
@ -220,8 +217,7 @@ class KingsdownEights(Game):
# ************************************************************************/ # ************************************************************************/
class Saxony_Reserve(SS_RowStack): class Saxony_Reserve(SS_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
return _('Reserve. Build down by suit.') return _('Reserve. Build down by suit.')

View file

@ -78,8 +78,7 @@ class UnionSquare_RowStack(OpenStack):
stack_dir = (self.cards[1].rank - self.cards[0].rank) % self.cap.mod stack_dir = (self.cards[1].rank - self.cards[0].rank) % self.cap.mod
return (self.cards[-1].rank + stack_dir) % self.cap.mod == cards[0].rank return (self.cards[-1].rank + stack_dir) % self.cap.mod == cards[0].rank
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
# /*********************************************************************** # /***********************************************************************

View file

@ -33,36 +33,36 @@ from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
# /*********************************************************************** # /***********************************************************************
# // Wave Motion # // Wave Motion
# ************************************************************************/ # ************************************************************************/
class WaveMotion_RowStack(SS_RowStack):
def getBottomImage(self):
return self.game.app.images.getReserveBottom()
class WaveMotion(Game): class WaveMotion(Game):
RowStack_Class = SS_RowStack
# #
# game layout # game layout
# #
def createGame(self): def createGame(self, rows=8, reserves=8, playcards=7):
# create layout # create layout
l, s = Layout(self), self.s l, s = Layout(self), self.s
# set window # set window
w, h = l.XM+8*l.XS, l.YM+2*l.YS+19*l.YOFFSET max_rows = max(rows, reserves)
w, h = l.XM + max_rows*l.XS, l.YM + 2*l.YS + (12+playcards)*l.YOFFSET
self.setSize(w, h) self.setSize(w, h)
# create stacks # create stacks
x, y = l.XM, l.YM x, y = l.XM + (max_rows-rows)*l.XS/2, l.YM
for i in range(8): for i in range(rows):
stack = WaveMotion_RowStack(x, y, self, base_rank=ANY_RANK) stack = self.RowStack_Class(x, y, self, base_rank=ANY_RANK)
stack.getBottomImage = stack._getReserveBottomImage
s.rows.append(stack) s.rows.append(stack)
x += l.XS x += l.XS
x, y = l.XM, l.YM+l.YS+12*l.YOFFSET x, y = l.XM + (max_rows-reserves)*l.XS/2, l.YM+l.YS+12*l.YOFFSET
for i in range(8): for i in range(reserves):
stack = OpenStack(x, y, self, max_accept=0) stack = OpenStack(x, y, self, max_accept=0)
s.reserves.append(stack) s.reserves.append(stack)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET

View file

@ -154,8 +154,7 @@ class Windmill(Game):
class DutchSolitaire_RowStack(UD_RK_RowStack): class DutchSolitaire_RowStack(UD_RK_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class DutchSolitaire(Windmill): class DutchSolitaire(Windmill):
@ -330,8 +329,7 @@ class Corners(Game):
# ************************************************************************/ # ************************************************************************/
class Czarina_RowStack(RK_RowStack): class Czarina_RowStack(RK_RowStack):
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
class Czarina(Corners): class Czarina(Corners):

View file

@ -427,6 +427,8 @@ class Options:
# general # general
for key, t in self.GENERAL_OPTIONS: for key, t in self.GENERAL_OPTIONS:
val = getattr(self, key) val = getattr(self, key)
if isinstance(val, str):
val = unicode(val, 'utf-8')
config['general'][key] = val config['general'][key] = val
config['general']['recent_gameid'] = self.recent_gameid config['general']['recent_gameid'] = self.recent_gameid
@ -537,7 +539,9 @@ class Options:
# general # general
for key, t in self.GENERAL_OPTIONS: for key, t in self.GENERAL_OPTIONS:
val = self._getOption('general', key, t) val = self._getOption('general', key, t)
if val is not None: if val == 'None':
setattr(self, key, None)
elif val is not None:
setattr(self, key, val) setattr(self, key, val)
recent_gameid = self._getOption('general', 'recent_gameid', 'list') recent_gameid = self._getOption('general', 'recent_gameid', 'list')

View file

@ -734,8 +734,21 @@ class Stack:
# Appearance {view} # Appearance {view}
# #
def getBottomImage(self): def _getBlankBottomImage(self):
return self.game.app.images.getBlankBottom() return self.game.app.images.getBlankBottom()
def _getReserveBottomImage(self):
return self.game.app.images.getReserveBottom()
def _getSuitBottomImage(self):
return self.game.app.images.getSuitBottom(self.cap.base_suit)
def _getNoneBottomImage(self):
return None
def _getTalonBottomImage(self):
return self.game.app.images.getTalonBottom()
def _getBraidBottomImage(self):
return self.game.app.images.getBraidBottom()
def _getLetterImage(self):
return self.game.app.images.getLetter(self.cap.base_rank)
getBottomImage = _getBlankBottomImage
def getPositionFor(self, card): def getPositionFor(self, card):
model, view = self, self model, view = self, self
@ -1774,8 +1787,7 @@ class TalonStack(Stack,
pass pass
self.top_bottom = self.texts.redeal self.top_bottom = self.texts.redeal
def getBottomImage(self): getBottomImage = Stack._getTalonBottomImage
return self.game.app.images.getTalonBottom()
def getRedealImages(self): def getRedealImages(self):
# returns a tuple of two PhotoImages # returns a tuple of two PhotoImages
@ -1807,8 +1819,7 @@ class InitialDealTalonStack(TalonStack):
def initBindings(self): def initBindings(self):
pass pass
# no bottom # no bottom
def getBottomImage(self): getBottomImage = Stack._getNoneBottomImage
return None
class RedealTalonStack(TalonStack, RedealCards_StackMethods): class RedealTalonStack(TalonStack, RedealCards_StackMethods):
@ -2081,8 +2092,7 @@ class AbstractFoundationStack(OpenStack):
def quickPlayHandler(self, event, from_stacks=None, to_stacks=None): def quickPlayHandler(self, event, from_stacks=None, to_stacks=None):
return 0 return 0
def getBottomImage(self): getBottomImage = Stack._getSuitBottomImage
return self.game.app.images.getSuitBottom(self.cap.base_suit)
def getBaseCard(self): def getBaseCard(self):
return self._getBaseCard() return self._getBaseCard()
@ -2695,8 +2705,7 @@ class ReserveStack(OpenStack):
kwdefault(cap, max_accept=1, max_cards=1) kwdefault(cap, max_accept=1, max_cards=1)
OpenStack.__init__(self, x, y, game, **cap) OpenStack.__init__(self, x, y, game, **cap)
def getBottomImage(self): getBottomImage = Stack._getReserveBottomImage
return self.game.app.images.getReserveBottom()
def getHelp(self): def getHelp(self):
if self.cap.max_accept == 0: if self.cap.max_accept == 0:
@ -2725,8 +2734,7 @@ class InvisibleStack(Stack):
pass pass
# no bottom # no bottom
def getBottomImage(self): getBottomImage = Stack._getNoneBottomImage
return None
# /*********************************************************************** # /***********************************************************************