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

+ 3 new game

* fixed game `Matrimony'
* improved toolbar


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@18 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2006-07-10 21:20:35 +00:00
parent b81f93473a
commit 2aa38bdda5
6 changed files with 107 additions and 22 deletions

View file

@ -92,6 +92,7 @@ class Canfield_RK_RowStack(RK_RowStack):
# ************************************************************************/
class Canfield(Game):
Talon_Class = WasteTalonStack
Foundation_Class = SS_FoundationStack
RowStack_Class = StackWrapper(Canfield_AC_RowStack, mod=13)
ReserveStack_Class = OpenStack
@ -126,7 +127,7 @@ class Canfield(Game):
# create stacks
x, y = l.XM, l.YM
s.talon = WasteTalonStack(x, y, self, max_rounds=max_rounds, num_deal=num_deal)
s.talon = self.Talon_Class(x, y, self, max_rounds=max_rounds, num_deal=num_deal)
l.createText(s.talon, "s")
x = x + l.XS
s.waste = WasteStack(x, y, self)
@ -668,6 +669,22 @@ class Demon(Canfield):
Canfield.createGame(self, rows=8, max_rounds=UNLIMITED_REDEALS, num_deal=1)
# /***********************************************************************
# // Canfield Rush
# ************************************************************************/
class CanfieldRush_Talon(WasteTalonStack):
def dealCards(self, sound=0):
self.num_deal = 4-self.round
WasteTalonStack.dealCards(self, sound=sound)
class CanfieldRush(Canfield):
Talon_Class = CanfieldRush_Talon
#RowStack_Class = StackWrapper(AC_RowStack, mod=13)
def createGame(self):
Canfield.createGame(self, max_rounds=3)
# register the game
registerGame(GameInfo(105, Canfield, "Canfield", # was: 262
GI.GT_CANFIELD | GI.GT_CONTRIB, 1, -1, GI.SL_BALANCED))
@ -709,4 +726,6 @@ registerGame(GameInfo(476, Demon, "Demon",
GI.GT_CANFIELD, 2, -1, GI.SL_BALANCED))
registerGame(GameInfo(494, Mystique, "Mystique",
GI.GT_CANFIELD, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(521, CanfieldRush, "Canfield Rush",
GI.GT_CANFIELD, 1, 2, GI.SL_BALANCED))

View file

@ -213,6 +213,10 @@ class Arabella(DoubleKlondike):
DoubleKlondike.startGame(self, flip=1)
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return abs(card1.rank-card2.rank) == 1
def getQuickPlayScore(self, ncards, from_stack, to_stack):
if to_stack.cards:
return int(from_stack.cards[-1].suit == to_stack.cards[-1].suit)+1
return 0
# register the game

View file

@ -40,7 +40,7 @@ from pysollib.util import *
from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import DefaultHint, FreeCellType_Hint
from pysollib.hint import DefaultHint, FreeCellType_Hint, CautiousDefaultHint
# /***********************************************************************
# //
@ -195,7 +195,7 @@ class Retinue(DieSchlange, Kings):
# // Salic Law
# ************************************************************************/
class SalicLaw_Hint(DefaultHint):
class SalicLaw_Hint(CautiousDefaultHint):
# Score for dropping ncards from stack r to stack t.
def _getDropCardScore(self, score, color, r, t, ncards):
@ -213,11 +213,12 @@ class SalicLaw_Talon(OpenTalonStack):
def dealCards(self, sound=0):
if len(self.cards) == 0:
return 0
base_rank=self.game.ROW_BASE_RANK
old_state = self.game.enterState(self.game.S_DEAL)
rows = self.game.s.rows
c = self.cards[-1]
ri = len([r for r in rows if r.cards])
if c.rank == KING:
if c.rank == base_rank:
to_stack = rows[ri]
else:
to_stack = rows[ri-1]
@ -225,8 +226,8 @@ class SalicLaw_Talon(OpenTalonStack):
frames = 3
if not self.game.demo:
self.game.startDealSample()
self.game.flipMove(self)
self.game.moveMove(1, self, to_stack, frames=frames)
self.game.flipMove(to_stack)
if not self.game.demo:
self.game.stopSamples()
self.game.leaveState(old_state)
@ -237,6 +238,14 @@ class SalicLaw(DerKatzenschwanz):
Hint_Class = SalicLaw_Hint
Foundation_Classes = [
StackWrapper(AbstractFoundationStack, max_cards=1, base_rank=QUEEN),
StackWrapper(RK_FoundationStack, base_rank=ACE, max_cards=11),
]
RowStack_Class = OpenStack
ROW_BASE_RANK = KING
#
# game layout
#
@ -259,21 +268,19 @@ class SalicLaw(DerKatzenschwanz):
yoffset.append(0)
# create stacks
x, y = l.XM, l.YM
for i in range(8):
s.foundations.append(AbstractFoundationStack(x, y, self,
suit=ANY_SUIT, max_cards=1, max_move=0, base_rank=QUEEN))
x += l.XS
x, y = l.XM, l.YM+l.YS
for i in range(8):
s.foundations.append(RK_FoundationStack(x, y, self,
suit=ANY_SUIT, base_rank=ACE, max_cards=11))
x += l.XS
y = l.YM
for found_class in self.Foundation_Classes:
x = l.XM
for i in range(8):
s.foundations.append(found_class(x, y, self,
suit=ANY_SUIT, max_move=0))
x += l.XS
y += l.YS
x, y = l.XM, l.YM+2*l.YS
self.setRegion(s.foundations[8:], (-999, -999, 999999, y - l.XM / 2))
for i in range(8):
stack = OpenStack(x, y, self, max_move=1)
stack = self.RowStack_Class(x, y, self, max_move=1)
stack.CARD_XOFFSET = xoffset
stack.CARD_YOFFSET = yoffset
s.rows.append(stack)
@ -332,6 +339,49 @@ class Deep(DerKatzenschwanz):
self.s.talon.dealRow()
# /***********************************************************************
# // Laggard Lady
# ************************************************************************/
class LaggardLady_RowStack(OpenStack):
def acceptsCards(self, from_stack, cards):
if not OpenStack.acceptsCards(self, from_stack, cards):
return False
return len(self.game.s.talon.cards) == 0 and len(self.cards) == 1
def canMoveCards(self, cards):
if not OpenStack.canMoveCards(self, cards):
return False
return len(self.cards) > 1
class LaggardLady(SalicLaw):
Foundation_Classes = [
StackWrapper(RK_FoundationStack, base_rank=5, max_cards=6),
StackWrapper(RK_FoundationStack, base_rank=4, max_cards=6, dir=-1, mod=13),
]
RowStack_Class = StackWrapper(LaggardLady_RowStack, max_accept=1)
ROW_BASE_RANK = QUEEN
def _shuffleHook(self, cards):
for c in cards[:]:
if c.rank == QUEEN:
cards.remove(c)
break
cards.append(c)
return cards
def isGameWon(self):
if self.s.talon.cards:
return False
for s in self.s.foundations:
if len(s.cards) != 6:
return False
return True
# register the game
registerGame(GameInfo(141, DerKatzenschwanz, "Cat's Tail",
@ -348,5 +398,7 @@ registerGame(GameInfo(299, SalicLaw, "Salic Law",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(442, Deep, "Deep",
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(523, LaggardLady, "Laggard Lady",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))

View file

@ -854,18 +854,24 @@ class Q_C_(Klondike):
# /***********************************************************************
# // Northwest Territory
# // Artic Garden
# ************************************************************************/
class NorthwestTerritory(KingAlbert):
RowStack_Class = StackWrapper(AC_RowStack, base_rank=KING)
RESERVES = (4, 4, 4, 4)
ROWS = 8
def startGame(self):
Klondike.startGame(self, flip=0, reverse=0)
self.s.talon.dealRow(rows=self.s.reserves)
class ArticGarden(NorthwestTerritory):
def startGame(self):
Klondike.startGame(self, flip=1, reverse=0)
self.s.talon.dealRow(rows=self.s.reserves)
# /***********************************************************************
# // Aunt Mary
# ************************************************************************/
@ -1174,4 +1180,6 @@ registerGame(GameInfo(491, Whitehorse, "Whitehorse",
GI.GT_KLONDIKE, 1, -1, GI.SL_BALANCED))
registerGame(GameInfo(518, Boost, "Boost",
GI.GT_KLONDIKE, 1, 2, GI.SL_BALANCED))
registerGame(GameInfo(522, ArticGarden, "Artic Garden",
GI.GT_RAGLAN, 1, 0, GI.SL_MOSTLY_SKILL))

View file

@ -430,11 +430,10 @@ class Matrimony_Talon(DealRowTalonStack):
if self.round == 1:
n = self.dealRowAvail(sound=sound)
else:
rows = []
for r in self.game.s.rows:
if r.cards:
rows.append(r)
rows = self.game.s.rows[-self.round+1:]
n = self.dealRowAvail(rows=rows, sound=sound)
while self.cards:
n += self.dealRowAvail(rows=self.game.s.rows, sound=sound)
if sound:
self.game.stopSamples()
return n

View file

@ -326,12 +326,14 @@ class PysolToolbar(PysolToolbarActions):
name = label.lower()
image = self._loadImage(name)
position = len(self._widgets)
bd = self.button_relief == 'flat' and 1 or 2
button = ToolbarButton(self.frame,
position=position,
toolbar=self,
toolbar_name=name,
command=command, takefocus=0,
text=gettext(label),
bd=bd,
relief=self.button_relief,
overrelief='raised',
padx=self.button_pad,
@ -475,7 +477,8 @@ class PysolToolbar(PysolToolbarActions):
self.frame.config(relief=self.frame_relief)
for w in self._widgets:
if isinstance(w, ToolbarButton):
w.config(relief=self.button_relief)
bd = relief == 'flat' and 1 or 2
w.config(relief=self.button_relief, bd=bd)
elif w.__class__ is ToolbarSeparator: # not ToolbarFlatSeparator
w.config(relief=self.separator_relief)
return True