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

+ 6 new game

* fixed game `Arachnida'
+ expanded debug support


git-svn-id: https://pysolfc.svn.sourceforge.net/svnroot/pysolfc/PySolFC/trunk@20 39dd0a4e-7c14-0410-91b3-c4f2d318f732
This commit is contained in:
skomoroh 2006-07-16 21:05:30 +00:00
parent 3c25e97e13
commit e97a944692
9 changed files with 234 additions and 45 deletions

View file

@ -91,7 +91,7 @@ class StreetsAndAlleys(Game):
y += l.YS
x = x1
for i in range(4):
s.foundations.append(self.Foundation_Class(x, y, self, i, max_move=0))
s.foundations.append(self.Foundation_Class(x, y, self, suit=i, max_move=0))
y = y + l.YS
if texts:
tx, ty, ta, tf = l.getTextAttr(None, "ss")
@ -148,6 +148,7 @@ class BeleagueredCastle(StreetsAndAlleys):
# /***********************************************************************
# // Citadel
# // Exiled Kings
# ************************************************************************/
class Citadel(StreetsAndAlleys):
@ -174,6 +175,10 @@ class Citadel(StreetsAndAlleys):
break
class ExiledKings(Citadel):
RowStack_Class = StackWrapper(RK_RowStack, base_rank=KING)
# /***********************************************************************
# // Fortress
# ************************************************************************/
@ -750,3 +755,5 @@ registerGame(GameInfo(508, CastleMount, "Castle Mount",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(524, SelectiveCastle, "Selective Castle",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(535, ExiledKings, "Exiled Kings",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))

View file

@ -47,9 +47,11 @@ class CurdsAndWhey_RowStack(BasicRowStack):
if not self.cards:
return True
c1, c2 = self.cards[-1], cards[0]
if c1.rank == c2.rank:
return True
if c1.suit == c2.suit:
return c1.rank == c2.rank+1
return c1.rank == c2.rank
return False
def canMoveCards(self, cards):
return isSameSuitSequence(cards) or isRankSequence(cards, dir=0)
@ -197,6 +199,7 @@ class Robin(Dumfries):
# /***********************************************************************
# // Arachnida
# // Harvestman
# ************************************************************************/
class Arachnida_RowStack(BasicRowStack):
@ -216,13 +219,14 @@ class Arachnida_RowStack(BasicRowStack):
class Arachnida(CurdsAndWhey):
RowStack_Class = Arachnida_RowStack
def createGame(self):
# create layout
l, s = Layout(self), self.s
# set window
w, h = l.XM+11*l.XS, l.YM+l.YS+16*l.YOFFSET
w, h = l.XM+12*l.XS, l.YM+l.YS+16*l.YOFFSET
self.setSize(w, h)
# create stacks
@ -231,11 +235,14 @@ class Arachnida(CurdsAndWhey):
l.createText(s.talon, "ss")
x += l.XS
for i in range(10):
stack = Arachnida_RowStack(x, y, self, base_rank=ANY_RANK,
max_move=UNLIMITED_MOVES,
max_accept=UNLIMITED_ACCEPTS)
stack = self.RowStack_Class(x, y, self, base_rank=ANY_RANK,
max_move=UNLIMITED_MOVES,
max_accept=UNLIMITED_ACCEPTS)
s.rows.append(stack)
x += l.XS
s.foundations.append(AbstractFoundationStack(x, y, self, suit=ANY_SUIT,
max_accept=0))
l.createText(s.foundations[0], "ss")
# define stack-groups
l.defaultStackGroups()
@ -247,10 +254,31 @@ class Arachnida(CurdsAndWhey):
self.startDealSample()
self.s.talon.dealRow()
def canDealCards(self):
if not CurdsAndWhey.canDealCards(self):
return False
# no row may be empty
for r in self.s.rows:
if not r.cards:
return False
return True
def fillStack(self, stack):
for r in self.s.rows:
if len(r.cards) >= 13 and isSameSuitSequence(r.cards[-13:]):
old_state = self.enterState(self.S_FILL)
self.playSample("drop", priority=200)
self.moveMove(13, r, self.s.foundations[0])
self.leaveState(old_state)
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return card1.rank == card2.rank or abs(card1.rank-card2.rank) == 1
class Harvestman(Arachnida):
RowStack_Class = CurdsAndWhey_RowStack
# /***********************************************************************
# // German Patience
# // Bavarian Patience
@ -412,4 +440,7 @@ registerGame(GameInfo(481, KnottyNines, "Knotty Nines",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(482, SweetSixteen, "Sweet Sixteen",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(534, Harvestman, "Harvestman",
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))

View file

@ -43,7 +43,7 @@ from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.games.gypsy import DieKoenigsbergerin_Talon, DieRussische_Foundation
from gypsy import DieKoenigsbergerin_Talon, DieRussische_Foundation
# /***********************************************************************
# // Die böse Sieben

View file

@ -251,9 +251,14 @@ class Carnation(Limited):
class SanJuanHill(FortyThieves):
def createGame(self):
FortyThieves.createGame(self, XOFFSET=0)
def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards,
lambda c: (c.rank == ACE, c.suit))
def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
FortyThieves.startGame(self)
# /***********************************************************************

View file

@ -44,20 +44,13 @@ from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
from pysollib.games.braid import Braid_Foundation
from braid import Braid_Foundation
# /***********************************************************************
# // stacks
# ************************************************************************/
class Napoleon_Talon(InitialDealTalonStack):
pass
class Napoleon_Foundation(Braid_Foundation):
pass
class Napoleon_RowStack(UD_SS_RowStack):
def getBottomImage(self):
@ -96,13 +89,14 @@ class Napoleon_FreeCell(ReserveStack):
class DerKleineNapoleon(Game):
Foundation_Class = Braid_Foundation
RowStack_Class = StackWrapper(Napoleon_RowStack, mod=13)
#
# game layout
#
def createGame(self, reserves=1):
def createGame(self, cells=1):
# create layout
l, s = Layout(self), self.s
@ -119,7 +113,7 @@ class DerKleineNapoleon(Game):
s.rows.append(self.RowStack_Class(x2, y, self))
y = y + l.YS
y = self.height - l.YS
if reserves == 1:
if cells == 1:
s.rows.append(Napoleon_ReserveStack(x0, y, self))
s.rows.append(Napoleon_ReserveStack(x2, y, self))
s.reserves.append(Napoleon_SingleFreeCell(x1, y, self))
@ -131,15 +125,15 @@ class DerKleineNapoleon(Game):
# foundations
x, y = x1, l.YM
for i in range(4):
s.foundations.append(Napoleon_Foundation(x, y, self, i))
s.foundations.append(self.Foundation_Class(x, y, self, i))
y = y + l.YS
# talon
if reserves == 1:
if cells == 1:
##x, y = l.XM, self.height - l.YS
y = self.height + l.YS
else:
y = self.height - l.YS
s.talon = Napoleon_Talon(x, y, self)
s.talon = InitialDealTalonStack(x, y, self)
# update stack building direction
for r in s.rows:
@ -200,12 +194,16 @@ class DerKleineNapoleon(Game):
class DerFreieNapoleon(DerKleineNapoleon):
Foundation_Class = Braid_Foundation
RowStack_Class = StackWrapper(Napoleon_RowStack, mod=13)
ReserveStack_Class = Napoleon_ReserveStack
FreeCell_Class = Napoleon_SingleFreeCell
#
# game layout
#
def createGame(self, reserves=1):
def createGame(self, cells=1, reserves=2, texts=True):
# create layout
l, s = Layout(self), self.s
@ -213,7 +211,8 @@ class DerFreieNapoleon(DerKleineNapoleon):
# set size so that at least 2/3 of a card is visible with 15 cards
h = l.CH*2/3 + (15-1)*l.YOFFSET
h = l.YS + max(h, 3*l.YS)
self.setSize(l.XM + 2*l.XM + 10*l.XS, l.YM + h)
max_rows = 8+max(cells, reserves)
self.setSize(l.XM + 2*l.XM + max_rows*l.XS, l.YM + h)
x1 = l.XM + 8*l.XS + 2*l.XM
# create stacks
@ -221,27 +220,32 @@ class DerFreieNapoleon(DerKleineNapoleon):
for j in range(8):
x = l.XM + j*l.XS
s.rows.append(self.RowStack_Class(x, y, self))
for j in range(2):
for j in range(reserves):
x = x1 + j*l.XS
s.rows.append(Napoleon_ReserveStack(x, y, self))
s.rows.append(self.ReserveStack_Class(x, y, self))
self.setRegion(s.rows, (-999, y - l.YM/2, 999999, 999999))
y = l.YM
if reserves == 1:
s.reserves.append(Napoleon_SingleFreeCell(x1 + l.XS/2, y, self))
else:
s.reserves.append(Napoleon_FreeCell(x1, y, self))
s.reserves.append(Napoleon_FreeCell(x1 + l.XS, y, self))
x = x1+(max(cells, reserves)-cells)*l.XS/2
for i in range(cells):
s.reserves.append(self.FreeCell_Class(x, y, self))
x += l.XS
## if cells == 1:
## s.reserves.append(Napoleon_SingleFreeCell(x1 + l.XS/2, y, self))
## else:
## s.reserves.append(Napoleon_FreeCell(x1, y, self))
## s.reserves.append(Napoleon_FreeCell(x1 + l.XS, y, self))
# foundations
x = l.XM + 2*l.XS
for i in range(4):
s.foundations.append(Napoleon_Foundation(x, y, self, i))
s.foundations.append(self.Foundation_Class(x, y, self, i))
x = x + l.XS
tx, ty, ta, tf = l.getTextAttr(s.foundations[-1], "se")
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
if texts:
tx, ty, ta, tf = l.getTextAttr(s.foundations[-1], "se")
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
# talon
x, y = l.XM, self.height - l.YS
s.talon = Napoleon_Talon(x, y, self)
s.talon = InitialDealTalonStack(x, y, self)
# define stack-groups
l.defaultStackGroups()
@ -253,12 +257,101 @@ class DerFreieNapoleon(DerKleineNapoleon):
class Napoleon(DerKleineNapoleon):
def createGame(self):
DerKleineNapoleon.createGame(self, reserves=2)
DerKleineNapoleon.createGame(self, cells=2)
class FreeNapoleon(DerFreieNapoleon):
FreeCell_Class = Napoleon_FreeCell
def createGame(self):
DerFreieNapoleon.createGame(self, reserves=2)
DerFreieNapoleon.createGame(self, cells=2)
# /***********************************************************************
# // Master
# ************************************************************************/
class Master(DerFreieNapoleon):
Foundation_Class = SS_FoundationStack
def createGame(self):
DerFreieNapoleon.createGame(self, cells=2, texts=False)
def _shuffleHook(self, cards):
return self._shuffleHookMoveToBottom(cards,
lambda c: (c.rank == ACE, c.suit))
# /***********************************************************************
# // The Little Corporal
# // Bonaparte
# ************************************************************************/
class TheLittleCorporal_RowStack(UD_SS_RowStack):
def acceptsCards(self, from_stack, cards):
if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
return False
if from_stack in self.game.s.reserves:
return not self.cards
return True
class TheLittleCorporal(DerFreieNapoleon):
def createGame(self, rows=10):
l, s = Layout(self), self.s
# set size so that at least 2/3 of a card is visible with 15 cards
h = l.CH*2/3 + (15-1)*l.YOFFSET
h = l.YS + max(h, 3*l.YS)
self.setSize(l.XM+rows*l.XS, l.YM + h)
x, y = l.XM+(rows-8)*l.XS, l.YM
for i in range(4):
s.foundations.append(Braid_Foundation(x, y, self, suit=i))
x += l.XS
tx, ty, ta, tf = l.getTextAttr(s.foundations[-1], "se")
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
x += 2*l.XS
stack = ReserveStack(x, y, self, max_cards=UNLIMITED_CARDS)
s.reserves.append(stack)
l.createText(stack, 'se')
x, y = l.XM, l.YM+l.YS
for i in range(rows):
s.rows.append(TheLittleCorporal_RowStack(x, y, self, mod=13))
x += l.XS
# talon
x, y = l.XM, self.height - l.YS
s.talon = InitialDealTalonStack(x, y, self)
# define stack-groups
l.defaultStackGroups()
def startGame(self):
for i in range(4):
self.s.talon.dealRow(rows=self.s.rows, frames=0)
self.startDealSample()
self.s.talon.dealRow(rows=self.s.rows[1:-1])
self.s.talon.dealBaseCards(ncards=4)
def getQuickPlayScore(self, ncards, from_stack, to_stack):
if to_stack in self.s.reserves:
return 0
return int(len(to_stack.cards) != 0)+1
class Bonaparte(TheLittleCorporal):
def createGame(self):
TheLittleCorporal.createGame(self, rows=8)
def startGame(self):
for i in range(5):
self.s.talon.dealRow(rows=self.s.rows, frames=0)
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealBaseCards(ncards=4)
# register the game
@ -270,4 +363,10 @@ registerGame(GameInfo(169, Napoleon, "Napoleon",
GI.GT_NAPOLEON | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(170, FreeNapoleon, "Free Napoleon",
GI.GT_NAPOLEON | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(536, Master, "Master",
GI.GT_NAPOLEON | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(537, TheLittleCorporal, "The Little Corporal",
GI.GT_NAPOLEON | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(538, Bonaparte, "Bonaparte",
GI.GT_NAPOLEON | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL))

View file

@ -178,7 +178,7 @@ class Spider2Suits(Spider):
pass
class OpenSpider(Spider):
def startGame(self, flip=0):
def startGame(self):
Spider.startGame(self, flip=1)

View file

@ -121,6 +121,7 @@ class Terrace_RowStack(AC_RowStack):
# ************************************************************************/
class Terrace(Game):
Talon_Class = Terrace_Talon
Foundation_Class = Terrace_AC_Foundation
RowStack_Class = Terrace_RowStack
ReserveStack_Class = OpenStack
@ -149,7 +150,7 @@ class Terrace(Game):
# create stacks
x, y = l.XM + w1, l.YM
s.talon = Terrace_Talon(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, "sw")
x = x + l.XS
s.waste = WasteStack(x, y, self)
@ -288,6 +289,46 @@ class Madame(Terrace):
Terrace.startGame(self, nrows=10)
# /***********************************************************************
# // Mamy Susan
# ************************************************************************/
class MamySusan_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if from_stack in self.game.s.reserves:
return False
return AC_RowStack.acceptsCards(self, from_stack, cards)
class MamySusan(Terrace):
Talon_Class = WasteTalonStack
Foundation_Class = StackWrapper(SS_FoundationStack, max_move=0)
RowStack_Class = StackWrapper(MamySusan_RowStack, max_move=1)
def createGame(self):
Terrace.createGame(self, rows=10)
def startGame(self, nrows=4):
for i in range(6):
self.s.talon.dealRow(rows=self.s.reserves, flip=0, frames=0)
self.flipMove(self.s.reserves[0])
for i in range(3):
self.s.talon.dealRow(frames=0)
self.startDealSample()
self.s.talon.dealRow()
self.s.talon.dealCards()
def fillStack(self, stack):
pass
def _restoreGameHook(self, game):
pass
def _loadGameHook(self, p):
pass
def _saveGameHook(self, p):
pass
# register the game
registerGame(GameInfo(135, Terrace, "Terrace",
@ -304,4 +345,6 @@ registerGame(GameInfo(499, Signora, "Signora",
GI.GT_TERRACE, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(500, Madame, "Madame",
GI.GT_TERRACE, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(533, MamySusan, "Mamy Susan",
GI.GT_TERRACE, 2, 0, GI.SL_BALANCED))

View file

@ -183,7 +183,7 @@ class ResourceManager:
self._addDir(result, os.path.join(dir, s))
except EnvError, ex:
pass
if app.debug >= 2:
if app.debug >= 5:
print "getSearchDirs", env, search, "->", result
return result
@ -210,7 +210,7 @@ class ResourceManager:
except:
pass
#
if app.debug >= 2:
if app.debug >= 5:
print "getRegistryDirs", category, "->", result
return result

View file

@ -1194,10 +1194,14 @@ class Stack:
return s
def getNumCards(self):
if self.game.app.debug >= 3:
t = repr(self)+' '
else:
t = ''
n = len(self.cards)
if n == 0 : return _('No cards')
elif n == 1 : return _('1 card')
else : return str(n)+_(' cards')
if n == 0 : return t+_('No cards')
elif n == 1 : return t+_('1 card')
else : return t+str(n)+_(' cards')
# /***********************************************************************