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

* improved solitaire wizard

git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@161 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2007-05-07 22:12:54 +00:00
parent 9fd4942f23
commit 4117e41bb0
6 changed files with 95 additions and 30 deletions

View file

@ -97,6 +97,17 @@ class CustomGame(Game):
if s['rows_type'] in (UD_SS_RowStack, UD_AC_RowStack, if s['rows_type'] in (UD_SS_RowStack, UD_AC_RowStack,
UD_RK_RowStack, UD_SC_RowStack): UD_RK_RowStack, UD_SC_RowStack):
kw['max_move'] = 1 kw['max_move'] = 1
# Super Move
if s['rows_super_move'] and kw['max_move'] == 1:
for s1, s2 in ((SS_RowStack, SuperMoveSS_RowStack),
(AC_RowStack, SuperMoveAC_RowStack),
(RK_RowStack, SuperMoveRK_RowStack),
(SC_RowStack, SuperMoveSC_RowStack),
(BO_RowStack, SuperMoveBO_RowStack)):
if s['rows_type'] is s1:
s['rows_type'] = s2
kw['max_move'] = UNLIMITED_MOVES
break
row = StackWrapper(s['rows_type'], **kw) row = StackWrapper(s['rows_type'], **kw)
# layout # layout
@ -181,6 +192,11 @@ class CustomGame(Game):
stack.acceptsCards = stack.varyAcceptsCards stack.acceptsCards = stack.varyAcceptsCards
stack.getBaseCard = stack.varyGetBaseCard stack.getBaseCard = stack.varyGetBaseCard
# getBottomImage
if s['deal_face_down'] + s['deal_face_up'] == 0:
for stack in self.s.rows:
stack.getBottomImage = stack.getReserveBottomImage
# Hint_Class # Hint_Class
# TODO # TODO
if s['rows_type'] in (Yukon_SS_RowStack, if s['rows_type'] in (Yukon_SS_RowStack,
@ -242,7 +258,8 @@ class CustomGame(Game):
self.startDealSample() self.startDealSample()
if frames == 0: if frames == 0:
self.startDealSample() self.startDealSample()
self.s.talon.dealRowAvail(frames=anim_frames) if s['deal_face_down'] + s['deal_face_up'] > 0:
self.s.talon.dealRowAvail(frames=anim_frames)
if isinstance(self.s.talon, InitialDealTalonStack): if isinstance(self.s.talon, InitialDealTalonStack):
while self.s.talon.cards: while self.s.talon.cards:
self.s.talon.dealRowAvail(frames=anim_frames) self.s.talon.dealRowAvail(frames=anim_frames)

View file

@ -421,7 +421,11 @@ class Layout:
for i in range(rows): for i in range(rows):
self.s.rows.append(S(x, y)) self.s.rows.append(S(x, y))
x += XS x += XS
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, 999999)) if reserves:
yy = h - YS - CH/2
else:
yy = 999999
self.setRegion(self.s.rows, (-999, -999, x - CW / 2, yy))
# create foundations # create foundations
x = w - decks*XS x = w - decks*XS
@ -471,7 +475,7 @@ class Layout:
w = max(reserves*XS, rows*XS, (suits*decks+waste+1)*XS, w = max(reserves*XS, rows*XS, (suits*decks+waste+1)*XS,
(suits*decks+1)*XS+2*XM) (suits*decks+1)*XS+2*XM)
w = XM + w w += XM
# set size so that at least 19 cards are fully playable # set size so that at least 19 cards are fully playable
h = YS + (playcards-1)*self.YOFFSET h = YS + (playcards-1)*self.YOFFSET
@ -495,11 +499,15 @@ class Layout:
# bottom # bottom
x, y = XM, YM + h x, y = XM, YM + h
self.setRegion(self.s.rows, (-999, -999, 999999, y - YS / 2))
for suit in range(suits): for suit in range(suits):
for i in range(decks): for i in range(decks):
self.s.foundations.append(S(x, y, suit=suit)) self.s.foundations.append(S(x, y, suit=suit))
x += XS x += XS
if reserves:
yy = YM + YS - CH/2
else:
yy = -999
self.setRegion(self.s.rows, (-999, yy, 999999, y - YS / 2))
if waste: if waste:
x = w - 2*XS x = w - 2*XS
self.s.waste = s = S(x, y) self.s.waste = s = S(x, y)
@ -540,6 +548,7 @@ class Layout:
# set size so that at least 2/3 of a card is visible with 16 cards # set size so that at least 2/3 of a card is visible with 16 cards
h = CH * 2 / 3 + (playcards - 1) * self.YOFFSET h = CH * 2 / 3 + (playcards - 1) * self.YOFFSET
h = max(h, 2 * YS) h = max(h, 2 * YS)
h += YM + YS * foundrows
# top # top
##text_height = 0 ##text_height = 0
@ -577,22 +586,26 @@ class Layout:
if rows < maxrows: x += (maxrows-rows) * XS/2 if rows < maxrows: x += (maxrows-rows) * XS/2
##y += YM * (3 - foundrows) ##y += YM * (3 - foundrows)
y += text_height y += text_height
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, 999999))
for i in range(rows): for i in range(rows):
self.s.rows.append(S(x, y)) self.s.rows.append(S(x, y))
x += XS x += XS
if reserves:
yy = h - CH/2
else:
yy = 999999
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, yy))
# bottom # bottom
if reserves: if reserves:
x = (maxrows-reserves)*XS/2 x = (maxrows-reserves)*XS/2
y = h + YM + YS * foundrows y = h
h += YS h += YS
for i in range(reserves): for i in range(reserves):
self.s.reserves.append(S(x, y)) self.s.reserves.append(S(x, y))
x += XS x += XS
# set window # set window
self.size = (XM + maxrows * XS, h + YM + YS * foundrows) self.size = (XM + maxrows * XS, h)
# #

View file

@ -92,6 +92,8 @@ __all__ = ['cardsFaceUp',
'SuperMoveSS_RowStack', 'SuperMoveSS_RowStack',
'SuperMoveAC_RowStack', 'SuperMoveAC_RowStack',
'SuperMoveRK_RowStack', 'SuperMoveRK_RowStack',
'SuperMoveSC_RowStack',
'SuperMoveBO_RowStack',
'InvisibleStack', 'InvisibleStack',
'StackWrapper', 'StackWrapper',
'WeakStackWrapper', 'WeakStackWrapper',
@ -2254,6 +2256,8 @@ class BasicRowStack(OpenStack):
return (s, 13) return (s, 13)
return (None, 0) return (None, 0)
def getReserveBottomImage(self):
return self.game.app.images.getReserveBottom()
# Abstract class. # Abstract class.
class SequenceRowStack(SequenceStack_StackMethods, BasicRowStack): class SequenceRowStack(SequenceStack_StackMethods, BasicRowStack):
@ -2538,6 +2542,29 @@ class SuperMoveRK_RowStack(SuperMoveStack_StackMethods, RK_RowStack):
max_move = self._getMaxMove(len(self.cards)) max_move = self._getMaxMove(len(self.cards))
return len(cards) <= max_move return len(cards) <= max_move
class SuperMoveSC_RowStack(SuperMoveStack_StackMethods, SC_RowStack):
def canMoveCards(self, cards):
if not SC_RowStack.canMoveCards(self, cards):
return False
max_move = self._getMaxMove(1)
return len(cards) <= max_move
def acceptsCards(self, from_stack, cards):
if not SC_RowStack.acceptsCards(self, from_stack, cards):
return False
max_move = self._getMaxMove(len(self.cards))
return len(cards) <= max_move
class SuperMoveBO_RowStack(SuperMoveStack_StackMethods, BO_RowStack):
def canMoveCards(self, cards):
if not BO_RowStack.canMoveCards(self, cards):
return False
max_move = self._getMaxMove(1)
return len(cards) <= max_move
def acceptsCards(self, from_stack, cards):
if not BO_RowStack.acceptsCards(self, from_stack, cards):
return False
max_move = self._getMaxMove(len(self.cards))
return len(cards) <= max_move
# /*********************************************************************** # /***********************************************************************

View file

@ -408,7 +408,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_separator() menu.add_separator()
menu.add_command(label=n_("Solitaire &Wizard"), command=self.mWizard) menu.add_command(label=n_("Solitaire &Wizard"), command=self.mWizard)
menu.add_command(label=n_("Edit current game"), command=self.mWizardEdit) menu.add_command(label=n_("&Edit current game"), command=self.mWizardEdit)
menu = MfxMenu(self.__menubar, label=n_("&Game")) menu = MfxMenu(self.__menubar, label=n_("&Game"))
menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D") menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D")

View file

@ -405,7 +405,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_separator() menu.add_separator()
menu.add_command(label=n_("Solitaire &Wizard"), command=self.mWizard) menu.add_command(label=n_("Solitaire &Wizard"), command=self.mWizard)
menu.add_command(label=n_("Edit current game"), command=self.mWizardEdit) menu.add_command(label=n_("&Edit current game"), command=self.mWizardEdit)
menu = MfxMenu(self.__menubar, label=n_("&Game")) menu = MfxMenu(self.__menubar, label=n_("&Game"))
menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D") menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D")

View file

@ -43,7 +43,6 @@ class WizSetting:
self.default = gettext(default) self.default = gettext(default)
##self.values_dict = dict(self.values_map) ##self.values_dict = dict(self.values_map)
self.translation_map = {} self.translation_map = {}
##self.values = [i[0] for i in self.values_map]
if widget == 'menu': if widget == 'menu':
self.values = [] self.values = []
for k, v in self.values_map: for k, v in self.values_map:
@ -98,9 +97,10 @@ LayoutType = WizSetting(
var_name = 'layout', var_name = 'layout',
) )
TalonType = WizSetting( TalonType = WizSetting(
values_map = ((n_('Initial dealing'), InitialDealTalonStack), values_map = ((n_('Initial dealing'), InitialDealTalonStack),
(n_('Deal to waste'), WasteTalonStack), (n_('Deal to waste'), WasteTalonStack),
(n_('Deal to rows'), DealRowRedealTalonStack), (n_('Deal to tableau'), DealRowRedealTalonStack),
(n_('Deal to reserves'), DealReserveRedealTalonStack),
), ),
default = n_('Initial dealing'), default = n_('Initial dealing'),
label = _('Type:'), label = _('Type:'),
@ -121,13 +121,13 @@ DealToWaste = WizSetting(
values_map = (1, 5), values_map = (1, 5),
default = 1, default = 1,
widget = 'spin', widget = 'spin',
label = _('Deal to waste:'), label = _('# of cards dealt to waste:'),
var_name = 'deal_to_waste', var_name = 'deal_to_waste',
) )
TalonShuffle = WizSetting( TalonShuffle = WizSetting(
values_map = (0, 1), values_map = (0, 1),
default = 0, default = 0,
label = _('Shuffle:'), label = _('Shuffle during redeal:'),
var_name = 'talon_shuffle', var_name = 'talon_shuffle',
widget = 'check', widget = 'check',
) )
@ -166,7 +166,7 @@ FoundWrap = WizSetting(
widget = 'check', widget = 'check',
) )
FoundMaxMove = WizSetting( FoundMaxMove = WizSetting(
values_map = ((n_('No move'), 0,), (n_('One card'), 1)), values_map = ((n_('None'), 0,), (n_('One card'), 1)),
default = n_('One card'), default = n_('One card'),
label = _('Max move cards:'), label = _('Max move cards:'),
var_name = 'found_max_move', var_name = 'found_max_move',
@ -174,7 +174,7 @@ FoundMaxMove = WizSetting(
FoundEqual = WizSetting( FoundEqual = WizSetting(
values_map = (0, 1), values_map = (0, 1),
default = 1, default = 1,
label = _('Equal base cards:'), label = _('First card sets first rank:'),
var_name = 'found_equal', var_name = 'found_equal',
widget = 'check', widget = 'check',
) )
@ -182,7 +182,7 @@ RowsNum = WizSetting(
values_map = (1, 20), values_map = (1, 20),
default = 8, default = 8,
widget = 'spin', widget = 'spin',
label = _('Number of rows:'), label = _('Number of tableau piles:'),
var_name = 'rows_num', var_name = 'rows_num',
) )
RowsType = WizSetting( RowsType = WizSetting(
@ -224,18 +224,25 @@ RowsDir = WizSetting(
label = _('Direction:'), label = _('Direction:'),
var_name = 'rows_dir', var_name = 'rows_dir',
) )
RowsMaxMove = WizSetting(
values_map = ((n_('One card'), 1), (n_('Unlimited'), UNLIMITED_MOVES)),
default = n_('Unlimited'),
label = _('Max # of moved cards:'),
var_name = 'rows_max_move',
)
RowsWrap = WizSetting( RowsWrap = WizSetting(
values_map = (True, False), values_map = (0, 1),
default = False, default = 0,
label = _('Wrapping:'), label = _('Wrapping:'),
var_name = 'rows_wrap', var_name = 'rows_wrap',
widget = 'check', widget = 'check',
) )
RowsMaxMove = WizSetting( RowsSuperMove = WizSetting(
values_map = ((n_('One card'), 1), (n_('Unlimited'), UNLIMITED_MOVES)), values_map = (0, 1),
default = n_('Unlimited'), default = 0,
label = _('Max move cards:'), label = _('Use "Super Move" feature:'),
var_name = 'rows_max_move', var_name = 'rows_super_move',
widget = 'check',
) )
ReservesNum = WizSetting( ReservesNum = WizSetting(
values_map = (0, 20), values_map = (0, 20),
@ -248,7 +255,7 @@ ReservesMaxAccept = WizSetting(
values_map = (0, 20), values_map = (0, 20),
default = 1, default = 1,
widget = 'spin', widget = 'spin',
label = _('Max accept:'), label = _('Max # of accepted cards:'),
var_name = 'reserves_max_accept', var_name = 'reserves_max_accept',
) )
DealType = WizSetting( DealType = WizSetting(
@ -263,21 +270,21 @@ DealFaceDown = WizSetting(
values_map = (0, 20), values_map = (0, 20),
default = 0, default = 0,
widget = 'spin', widget = 'spin',
label = _('# of face-down cards:'), label = _('# of face-down cards dealt to tableau pile:'),
var_name = 'deal_face_down', var_name = 'deal_face_down',
) )
DealFaceUp = WizSetting( DealFaceUp = WizSetting(
values_map = (1, 20), values_map = (0, 20),
default = 8, default = 8,
widget = 'spin', widget = 'spin',
label = _('# of face-up cards:'), label = _('# of face-up cards dealt to tableau pile:'),
var_name = 'deal_face_up', var_name = 'deal_face_up',
) )
DealToReseves = WizSetting( DealToReseves = WizSetting(
values_map = (0, 20), values_map = (0, 20),
default = 0, default = 0,
widget = 'spin', widget = 'spin',
label = _('Deal to reserves:'), label = _('# cards dealt to reserve:'),
var_name = 'deal_to_reserves', var_name = 'deal_to_reserves',
) )
DealMaxCards = WizSetting( DealMaxCards = WizSetting(
@ -313,6 +320,7 @@ WizardWidgets = (
RowsDir, RowsDir,
RowsMaxMove, RowsMaxMove,
RowsWrap, RowsWrap,
RowsSuperMove,
_('Reserves'), _('Reserves'),
ReservesNum, ReservesNum,
ReservesMaxAccept, ReservesMaxAccept,