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

+ 1 new game

* small improvements


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@17 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2006-07-08 21:25:35 +00:00
parent 5b8b7f26e7
commit b81f93473a
14 changed files with 77 additions and 34 deletions

View file

@ -1561,6 +1561,7 @@ Please select a %s type %s.
tile.text_color = "#" + m.group(2).lower()
#n = re.sub("[-_]", " ", n)
n = n.replace('_', ' ')
##n = unicode(n)
tile.name = n
key = n.lower()
if not t.has_key(key):

View file

@ -182,7 +182,6 @@ class GoodMeasure(BakersDozen):
assert c.rank == ACE
self.flipMove(self.s.talon)
self.moveMove(1, self.s.talon, self.s.foundations[c.suit])
assert len(self.s.talon.cards) == 0
# /***********************************************************************

View file

@ -113,7 +113,6 @@ class BakersGame(Game):
r = self.s.rows
##self.s.talon.dealRow(rows=(r[0], r[1], r[6], r[7]))
self.s.talon.dealRow(rows=r[:4])
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.suit == card2.suit and
@ -179,7 +178,6 @@ class EightOff(KingOnlyBakersGame):
self.s.talon.dealRow()
r = self.s.reserves
self.s.talon.dealRow(rows=[r[0],r[2],r[4],r[6]])
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -231,7 +229,6 @@ class SeahavenTowers(KingOnlyBakersGame):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=(self.s.reserves[1:3]))
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -314,7 +311,6 @@ class Penguin(Game):
self.s.talon.dealRow(frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.suit == card2.suit and

View file

@ -114,7 +114,6 @@ class StreetsAndAlleys(Game):
self.startDealSample()
for i in range(3):
self.s.talon.dealRowAvail()
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return abs(card1.rank - card2.rank) == 1
@ -136,7 +135,6 @@ class BeleagueredCastle(StreetsAndAlleys):
for i in range(2):
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.foundations)
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -211,7 +209,6 @@ class Fortress(Game):
self.startDealSample()
for i in range(3):
self.s.talon.dealRowAvail()
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.suit == card2.suit and
@ -502,14 +499,16 @@ class CastleOfIndolence(Game):
# set window
# (set size so that at least 13 cards are fully playable)
w = max(3*l.XS, l.XS+13*l.XOFFSET)
self.setSize(l.XM+2*w+2*l.XS, l.YM + 5*l.YS)
self.setSize(l.XM+2*w+2*l.XS, l.YM + 5*l.YS + l.TEXT_HEIGHT)
# create stacks
x, y = l.XM, l.YM+4*l.YS
s.talon = InitialDealTalonStack(x, y, self)
x, y = l.XM+w-l.XS, l.YM+4*l.YS
for i in range(4):
s.reserves.append(OpenStack(x, y, self, max_accept=0))
stack = OpenStack(x, y, self, max_accept=0)
s.reserves.append(stack)
l.createText(stack, 's')
x += l.XS
x = l.XM + w

View file

@ -119,7 +119,6 @@ class Fan(Game):
self.s.talon.dealRow(rows=self.s.rows[:17], frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.suit == card2.suit and
@ -440,7 +439,6 @@ class HouseInTheWood(Fan):
self.s.talon.dealRow(rows=self.s.rows[:35], frames=0)
self.startDealSample()
self.s.talon.dealRow(rows=self.s.rows[:35])
assert len(self.s.talon.cards) == 0
class HouseOnTheHill(HouseInTheWood):

View file

@ -80,6 +80,7 @@ class FreeCell(Game):
Talon_Class = InitialDealTalonStack
Foundation_Class = SS_FoundationStack
RowStack_Class = FreeCell_RowStack
ReserveStack_Class = ReserveStack
Hint_Class = FreeCellSolverWrapper(FreeCellType_Hint, {})
@ -100,7 +101,7 @@ class FreeCell(Game):
for r in l.s.rows:
s.rows.append(self.RowStack_Class(r.x, r.y, self))
for r in l.s.reserves:
s.reserves.append(ReserveStack(r.x, r.y, self))
s.reserves.append(self.ReserveStack_Class(r.x, r.y, self))
# default
l.defaultAll()
@ -116,7 +117,6 @@ class FreeCell(Game):
r = self.s.rows
##self.s.talon.dealRow(rows=(r[0], r[2], r[4], r[6]))
self.s.talon.dealRow(rows=r[:4])
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.color != card2.color and
@ -146,7 +146,6 @@ class ForeCell(FreeCell):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.reserves)
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -183,7 +182,6 @@ class Stalactites(FreeCell):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.foundations)
assert len(self.s.talon.cards) == 0
self._restoreGameHook(None)
def _restoreGameHook(self, game):
@ -243,7 +241,6 @@ class DoubleFreecell(FreeCell):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.foundations)
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -461,6 +458,7 @@ class Repair(FreeCell):
# /***********************************************************************
# // Four Colours
# // German FreeCell
# ************************************************************************/
class FourColours_RowStack(AC_RowStack):
@ -505,6 +503,24 @@ class FourColours(FreeCell):
self.dealOne(frames=-1)
class GermanFreeCell_Reserve(ReserveStack):
def getBottomImage(self):
return self.game.app.images.getSuitBottom(self.cap.base_suit)
class GermanFreeCell(SevenByFour):
Hint_Class = FreeCellType_Hint
RowStack_Class = AC_RowStack
ReserveStack_Class = GermanFreeCell_Reserve
def createGame(self):
FreeCell.createGame(self, rows=7)
suit = 0
for r in self.s.reserves:
r.cap.base_suit = suit
suit += 1
# /***********************************************************************
# // Ocean Towers
# ************************************************************************/
@ -567,4 +583,6 @@ registerGame(GameInfo(509, BigCell, "Big Cell",
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(513, OceanTowers, "Ocean Towers",
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(520, GermanFreeCell, "German FreeCell",
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_SKILL))

View file

@ -449,7 +449,6 @@ class Stonewall(Klondike):
else:
self.s.talon.dealRow(flip=flip, frames=frames)
self.s.talon.dealRow(rows=self.s.reserves)
assert len(self.s.talon.cards) == 0
class FlowerGarden(Stonewall):

View file

@ -203,7 +203,6 @@ class Montana(Game):
self.startDealSample()
frames = 4
self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames)
assert len(self.s.talon.cards) == 0
def isGameWon(self):
rows = self.s.rows
@ -272,7 +271,6 @@ class BlueMoon(Montana):
frames = 4
self.s.talon.dealRow(rows=(self.s.rows[j],), frames=frames)
j = j + 1
assert len(self.s.talon.cards) == 0
ace_rows = filter(lambda r: r.cards and r.cards[-1].rank == ACE, self.s.rows)
j = 0
for r in ace_rows:

View file

@ -103,7 +103,6 @@ class PileOn(Game):
self.s.talon.dealRow(rows=r, frames=0)
self.startDealSample()
self.s.talon.dealRow(rows=r)
assert len(self.s.talon.cards) == 0
def isGameWon(self):
for r in self.s.rows:

View file

@ -231,7 +231,6 @@ class Maze(Game):
self.startDealSample()
frames = -1
self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames)
assert len(self.s.talon.cards) == 0
def isGameWon(self):
rows = filter(lambda s: s.cards, self.s.rows)

View file

@ -402,6 +402,44 @@ class LadyOfTheManor(Game):
# // Matrimony
# ************************************************************************/
class Matrimony_Talon(DealRowTalonStack):
def canDealCards(self):
if self.round == self.max_rounds and not self.cards:
return False
return not self.game.isGameWon()
def _redeal(self):
lr = len(self.game.s.rows)
num_cards = 0
assert len(self.cards) == 0
rows = self.game.s.rows
r = self.game.s.rows[-self.round]
for i in range(len(r.cards)):
num_cards = num_cards + 1
self.game.moveMove(1, r, self, frames=4)
self.game.flipMove(self)
assert len(self.cards) == num_cards
self.game.nextRoundMove(self)
def dealCards(self, sound=0):
if sound:
self.game.startDealSample()
if len(self.cards) == 0:
self._redeal()
if self.round == 1:
n = self.dealRowAvail(sound=sound)
else:
rows = []
for r in self.game.s.rows:
if r.cards:
rows.append(r)
n = self.dealRowAvail(rows=rows, sound=sound)
if sound:
self.game.stopSamples()
return n
class Matrimony(Game):
def createGame(self):
@ -409,8 +447,13 @@ class Matrimony(Game):
l, s = Layout(self), self.s
self.setSize(l.XM+8*l.XS, l.YM+4*l.YS)
s.talon = DealRowTalonStack(l.XM, l.YM, self)
l.createText(s.talon, 'ss')
s.talon = Matrimony_Talon(l.XM, l.YM, self, max_rounds=17)
l.createText(s.talon, 'se')
tx, ty, ta, tf = l.getTextAttr(s.talon, "ne")
s.talon.texts.rounds = MfxCanvasText(self.canvas, tx, ty,
anchor=ta,
font=self.app.getFont("canvas_default"))
x, y = l.XM+2*l.XS, l.YM
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
@ -707,7 +750,7 @@ registerGame(GameInfo(423, LadyOfTheManor, "Lady of the Manor",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK,
altnames=("Vassal", "La Chatelaine") ))
registerGame(GameInfo(424, Matrimony, "Matrimony",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK))
GI.GT_2DECK_TYPE, 2, 16, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(429, Patriarchs, "Patriarchs",
GI.GT_2DECK_TYPE, 2, 1, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(437, Simplicity, "Simplicity",

View file

@ -238,8 +238,7 @@ registerGame(GameInfo(303, Tournament, "Tournament",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(304, LaNivernaise, "La Nivernaise",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
altnames = ("Napoleon's Flank", ),
rules_filename = "tournament.html"))
altnames = ("Napoleon's Flank", ),))
registerGame(GameInfo(386, KingsdownEights, "Kingsdown Eights",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))

View file

@ -112,7 +112,6 @@ class Yukon(Game):
self.s.talon.dealRow(rows=self.s.rows[1:], flip=1, frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
def getHighlightPilesStacks(self):
return ()
@ -167,7 +166,6 @@ class Odessa(RussianSolitaire):
self.s.talon.dealRow(rows=self.s.rows[1:6], frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -185,7 +183,6 @@ class Grandfather(RussianSolitaire):
for i in (1,5,5,5,5,5,5):
self.s.talon.dealRow(rows=[self.s.rows[n]]*i)
n += 1
assert len(self.s.talon.cards) == 0
# /***********************************************************************
@ -361,7 +358,6 @@ class DoubleYukon(Yukon):
self.s.talon.dealRow(flip=1, frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
class DoubleRussianSolitaire(DoubleYukon):
@ -387,7 +383,6 @@ class TripleYukon(Yukon):
self.s.talon.dealRow(rows=self.s.rows, flip=1, frames=0)
self.startDealSample()
self.s.talon.dealRow()
assert len(self.s.talon.cards) == 0
class TripleRussianSolitaire(TripleYukon):
@ -443,7 +438,6 @@ class TenAcross(Yukon):
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.reserves)
assert len(self.s.talon.cards) == 0
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.suit == card2.suit and

View file

@ -63,7 +63,8 @@ class Resource(Struct):
apply(Struct.__init__, (self,), kw.getKw())
def getSortKey(self):
return latin1_to_ascii(self.name).lower()
return self.name.lower()
#return latin1_to_ascii(self.name).lower()
class ResourceManager: