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: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@161 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2007-05-07 22:12:54 +00:00
parent a7e7aab703
commit ccc11cb64d
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,
UD_RK_RowStack, UD_SC_RowStack):
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)
# layout
@ -181,6 +192,11 @@ class CustomGame(Game):
stack.acceptsCards = stack.varyAcceptsCards
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
# TODO
if s['rows_type'] in (Yukon_SS_RowStack,
@ -242,7 +258,8 @@ class CustomGame(Game):
self.startDealSample()
if frames == 0:
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):
while self.s.talon.cards:
self.s.talon.dealRowAvail(frames=anim_frames)

View file

@ -421,7 +421,11 @@ class Layout:
for i in range(rows):
self.s.rows.append(S(x, y))
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
x = w - decks*XS
@ -471,7 +475,7 @@ class Layout:
w = max(reserves*XS, rows*XS, (suits*decks+waste+1)*XS,
(suits*decks+1)*XS+2*XM)
w = XM + w
w += XM
# set size so that at least 19 cards are fully playable
h = YS + (playcards-1)*self.YOFFSET
@ -495,11 +499,15 @@ class Layout:
# bottom
x, y = XM, YM + h
self.setRegion(self.s.rows, (-999, -999, 999999, y - YS / 2))
for suit in range(suits):
for i in range(decks):
self.s.foundations.append(S(x, y, suit=suit))
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:
x = w - 2*XS
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
h = CH * 2 / 3 + (playcards - 1) * self.YOFFSET
h = max(h, 2 * YS)
h += YM + YS * foundrows
# top
##text_height = 0
@ -577,22 +586,26 @@ class Layout:
if rows < maxrows: x += (maxrows-rows) * XS/2
##y += YM * (3 - foundrows)
y += text_height
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, 999999))
for i in range(rows):
self.s.rows.append(S(x, y))
x += XS
if reserves:
yy = h - CH/2
else:
yy = 999999
self.setRegion(self.s.rows, (-999, y-CH/2, 999999, yy))
# bottom
if reserves:
x = (maxrows-reserves)*XS/2
y = h + YM + YS * foundrows
y = h
h += YS
for i in range(reserves):
self.s.reserves.append(S(x, y))
x += XS
# 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',
'SuperMoveAC_RowStack',
'SuperMoveRK_RowStack',
'SuperMoveSC_RowStack',
'SuperMoveBO_RowStack',
'InvisibleStack',
'StackWrapper',
'WeakStackWrapper',
@ -2254,6 +2256,8 @@ class BasicRowStack(OpenStack):
return (s, 13)
return (None, 0)
def getReserveBottomImage(self):
return self.game.app.images.getReserveBottom()
# Abstract class.
class SequenceRowStack(SequenceStack_StackMethods, BasicRowStack):
@ -2538,6 +2542,29 @@ class SuperMoveRK_RowStack(SuperMoveStack_StackMethods, RK_RowStack):
max_move = self._getMaxMove(len(self.cards))
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_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.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_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.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D")

View file

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