1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00
This commit is contained in:
Shlomi Fish 2017-04-18 00:01:44 +03:00
parent 6bac87f644
commit a6be4d22b6
3 changed files with 167 additions and 80 deletions

View file

@ -24,29 +24,47 @@
__all__ = []
# imports
import sys
# PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI
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, CautiousDefaultHint
from pysollib.hint import FreeCellType_Hint, CautiousDefaultHint
from pysollib.hint import FreeCellSolverWrapper
from pysollib.pysoltk import MfxCanvasText
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, KING, NO_RANK, RANKS, \
QUEEN, \
UNLIMITED_ACCEPTS
from pysollib.stack import \
AC_RowStack, \
AbstractFoundationStack, \
FreeCell_AC_RowStack, \
InitialDealTalonStack, \
OpenStack, \
RK_FoundationStack, \
RK_RowStack, \
ReserveStack, \
SS_FoundationStack, \
StackWrapper, \
TalonStack, \
WasteStack, \
WasteTalonStack
# ************************************************************************
# *
# ************************************************************************
class DerKatzenschwanz_Hint(FreeCellType_Hint):
def _getMovePileScore(self, score, color, r, t, pile, rpile):
if len(rpile) == 0:
# don't create empty row
return -1, color
return FreeCellType_Hint._getMovePileScore(self, score, color, r, t, pile, rpile)
return FreeCellType_Hint._getMovePileScore(
self, score, color, r, t, pile, rpile)
# ************************************************************************
@ -96,10 +114,13 @@ class DerKatzenschwanz(Game):
x, y = l.XM + maxrows*l.XS, l.YM
for suit in range(4):
for i in range(2):
s.foundations.append(SS_FoundationStack(x+i*l.XS, y, self, suit=suit))
s.foundations.append(
SS_FoundationStack(x+i*l.XS, y, self, suit=suit))
y = y + l.YS
self.setRegion(self.s.foundations, (x - l.CW / 2, -999, 999999, y), priority=1)
s.talon = InitialDealTalonStack(self.width-3*l.XS/2, self.height-l.YS, self)
self.setRegion(
self.s.foundations, (x - l.CW / 2, -999, 999999, y), priority=1)
s.talon = InitialDealTalonStack(
self.width-3*l.XS/2, self.height-l.YS, self)
# define stack-groups
l.defaultStackGroups()
@ -124,7 +145,8 @@ class DerKatzenschwanz(Game):
closest, cdist = None, 999999999
for stack in stacks:
if stack.cards and stack is not dragstack:
dist = (stack.cards[-1].x - cx)**2 + (stack.cards[-1].y - cy)**2
dist = (stack.cards[-1].x - cx)**2 + \
(stack.cards[-1].y - cy)**2
else:
dist = (stack.x - cx)**2 + (stack.y - cy)**2
if dist < cdist:
@ -192,8 +214,10 @@ class Retinue(DieSchlange, Kings):
def createGame(self):
return DerKatzenschwanz.createGame(self, rows=8, reserves=8)
def _shuffleHook(self, cards):
return Kings._shuffleHook(self, cards)
def startGame(self):
return DieSchlange.startGame(self)
@ -214,8 +238,8 @@ class SalicLaw_Talon(TalonStack):
def dealCards(self, sound=False):
if len(self.cards) == 0:
return 0
base_rank=self.game.ROW_BASE_RANK
old_state = self.game.enterState(self.game.S_DEAL)
base_rank = self.game.ROW_BASE_RANK
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])
@ -230,6 +254,7 @@ class SalicLaw_Talon(TalonStack):
self.game.stopSamples()
return 1
# all Aces go to the Foundations
class SalicLaw_Talon_2(SalicLaw_Talon):
def dealCards(self, sound=False):
@ -286,7 +311,7 @@ class SalicLaw(DerKatzenschwanz):
# game layout
#
def createGame(self): #, rows=9, reserves=8):
def createGame(self): # , rows=9, reserves=8):
# create layout
l, s = Layout(self), self.s
@ -343,8 +368,8 @@ class SalicLaw(DerKatzenschwanz):
def startGame(self):
self.startDealSample()
self.s.talon.dealRow(self.s.foundations[:8]) # deal Queens
self.s.talon.dealRow(self.s.rows[:1]) # deal King
self.s.talon.dealRow(self.s.foundations[:8]) # deal Queens
self.s.talon.dealRow(self.s.rows[:1]) # deal King
def isGameWon(self):
for s in self.s.foundations[8:]:
@ -390,7 +415,8 @@ class FaerieQueen(SalicLaw):
Foundation_Classes = [
StackWrapper(RK_FoundationStack, max_move=0, max_cards=12)
]
RowStack_Class = StackWrapper(FaerieQueen_RowStack, min_cards=1, max_move=1)
RowStack_Class = StackWrapper(
FaerieQueen_RowStack, min_cards=1, max_move=1)
def _shuffleHook(self, cards):
for c in cards[:]:
@ -402,7 +428,7 @@ class FaerieQueen(SalicLaw):
def startGame(self):
self.startDealSample()
self.s.talon.dealRow(self.s.rows[:1]) # deal King
self.s.talon.dealRow(self.s.rows[:1]) # deal King
def isGameWon(self):
if self.s.talon.cards:
@ -436,7 +462,8 @@ class Intrigue(SalicLaw):
Talon_Class = SalicLaw_Talon
Foundation_Classes = [
StackWrapper(RK_FoundationStack, base_rank=5, max_cards=6),
StackWrapper(RK_FoundationStack, base_rank=4, max_cards=6, dir=-1, mod=13),
StackWrapper(
RK_FoundationStack, base_rank=4, max_cards=6, dir=-1, mod=13),
]
RowStack_Class = StackWrapper(Intrigue_RowStack, max_accept=1, min_cards=1)
@ -452,7 +479,7 @@ class Intrigue(SalicLaw):
def startGame(self):
self.startDealSample()
self.s.talon.dealRow(self.s.rows[:1]) # deal King
self.s.talon.dealRow(self.s.rows[:1]) # deal King
def isGameWon(self):
if self.s.talon.cards:
@ -475,10 +502,12 @@ class LaggardLady_Foundation(RK_FoundationStack):
return False
return True
class LaggardLady(Intrigue):
Foundation_Classes = [
StackWrapper(LaggardLady_Foundation, base_rank=5, max_cards=6),
StackWrapper(LaggardLady_Foundation, base_rank=4, max_cards=6, dir=-1, mod=13),
StackWrapper(
LaggardLady_Foundation, base_rank=4, max_cards=6, dir=-1, mod=13),
]
@ -495,10 +524,12 @@ class Glencoe_Foundation(RK_FoundationStack):
return c.suit == r.cards[0].suit
return True
class Glencoe(Intrigue):
Foundation_Classes = [
StackWrapper(Glencoe_Foundation, base_rank=5, max_cards=6),
StackWrapper(Glencoe_Foundation, base_rank=4, max_cards=6, dir=-1, mod=13),
StackWrapper(
Glencoe_Foundation, base_rank=4, max_cards=6, dir=-1, mod=13),
]
@ -517,6 +548,7 @@ class StepUp_Foundation(SS_FoundationStack):
return True
return False
class StepUp_Talon(WasteTalonStack):
def canDealCards(self):
if not WasteTalonStack.canDealCards(self):
@ -526,12 +558,13 @@ class StepUp_Talon(WasteTalonStack):
return False
return True
class StepUp_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return False
if (from_stack in self.game.s.reserves or
from_stack in self.game.s.foundations):
from_stack in self.game.s.foundations):
return False
return True
@ -547,7 +580,7 @@ class StepUp(Game):
x, y = l.XM+2.5*l.XS, l.YM
for i in range(8):
s.foundations.append(StepUp_Foundation(x, y, self,
suit=i%4, mod=13, base_rank=ANY_RANK))
suit=i % 4, mod=13, base_rank=ANY_RANK))
x += l.XS
tx, ty, ta, tf = l.getTextAttr(s.foundations[0], "sw")
font = self.app.getFont("canvas_default")
@ -572,7 +605,6 @@ class StepUp(Game):
l.defaultStackGroups()
def startGame(self):
c = self.s.talon.cards[-1]
self.base_rank = c.rank
@ -676,22 +708,23 @@ class Kentish(Kings):
shallHighlightMatch = Game._shallHighlightMatch_RK
# register the game
registerGame(GameInfo(141, DerKatzenschwanz, "Cat's Tail",
GI.GT_FREECELL | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=("Der Katzenschwanz",) ))
altnames=("Der Katzenschwanz",)))
registerGame(GameInfo(142, DieSchlange, "Snake",
GI.GT_FREECELL | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=("Die Schlange",) ))
altnames=("Die Schlange",)))
registerGame(GameInfo(279, Kings, "Kings",
GI.GT_FREECELL | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(286, Retinue, "Retinue",
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0,
GI.SL_MOSTLY_SKILL))
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))
GI.GT_FREECELL | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(523, Intrigue, "Intrigue",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(611, FaerieQueen, "Faerie Queen",
@ -705,7 +738,5 @@ registerGame(GameInfo(616, LaggardLady, "Laggard Lady",
registerGame(GameInfo(624, StepUp, "Step-Up",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(766, Kentish, "Kentish",
GI.GT_2DECK_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
GI.GT_2DECK_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0,
GI.SL_MOSTLY_SKILL))

View file

@ -24,28 +24,50 @@
__all__ = []
# imports
import sys
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.mfxutil import kwdefault, Struct
from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.hint import CautiousDefaultHint
from pysollib.hint import KlondikeType_Hint
from pysollib.hint import FreeCellSolverWrapper
from pysollib.pysoltk import MfxCanvasText
from canfield import CanfieldRush_Talon
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, KING, NO_RANK
from pysollib.stack import \
AC_RowStack, \
BO_RowStack, \
DealRowTalonStack, \
InitialDealTalonStack, \
KingAC_RowStack, \
OpenStack, \
OpenTalonStack, \
RK_FoundationStack, \
RK_RowStack, \
RedealTalonStack, \
ReserveStack, \
SC_RowStack, \
SS_FoundationStack, \
Stack, \
StackWrapper, \
SuperMoveAC_RowStack, \
UD_SS_RowStack, \
WasteStack, \
WasteTalonStack, \
isSameColorSequence, \
SS_RowStack
# ************************************************************************
# * Klondike
# ************************************************************************
class Klondike(Game):
Layout_Method = Layout.klondikeLayout
Talon_Class = WasteTalonStack
@ -65,7 +87,8 @@ class Klondike(Game):
if l.s.waste:
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self)
for r in l.s.foundations:
s.foundations.append(self.Foundation_Class(r.x, r.y, self, suit=r.suit))
s.foundations.append(
self.Foundation_Class(r.x, r.y, self, suit=r.suit))
for r in l.s.rows:
s.rows.append(self.RowStack_Class(r.x, r.y, self))
# default
@ -74,7 +97,8 @@ class Klondike(Game):
def startGame(self, flip=0, reverse=1):
for i in range(1, len(self.s.rows)):
self.s.talon.dealRow(rows=self.s.rows[i:], flip=flip, frames=0, reverse=reverse)
self.s.talon.dealRow(
rows=self.s.rows[i:], flip=flip, frames=0, reverse=reverse)
self.startDealSample()
self.s.talon.dealRow(reverse=reverse)
if self.s.waste:
@ -163,8 +187,11 @@ class Chinaman(ThumbAndPouch):
class Whitehead_RowStack(SS_RowStack):
def _isAcceptableSequence(self, cards):
return isSameColorSequence(cards, self.cap.mod, self.cap.dir)
def getHelp(self):
return _('Tableau. Build down by color. Sequences of cards in the same suit can be moved as a unit.')
return _('Tableau. Build down by color. Sequences of cards '
'in the same suit can be moved as a unit.')
class Whitehead(Klondike):
RowStack_Class = Whitehead_RowStack
@ -217,13 +244,16 @@ class Eastcliff(Klondike):
class Easthaven(Eastcliff):
Talon_Class = DealRowTalonStack
def createGame(self):
Klondike.createGame(self, max_rounds=1, waste=0)
class DoubleEasthaven(Easthaven):
def createGame(self):
Klondike.createGame(self, rows=8, max_rounds=1, waste=0, playcards=20)
class TripleEasthaven(Easthaven):
def createGame(self):
Klondike.createGame(self, rows=12, max_rounds=1, waste=0, playcards=26)
@ -273,7 +303,8 @@ class BlindAlleys(Eastcliff):
def _shuffleHook(self, cards):
# move Aces to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards, lambda c: (c.rank == 0, c.suit))
return self._shuffleHookMoveToTop(
cards, lambda c: (c.rank == 0, c.suit))
def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -331,6 +362,7 @@ class Usk(Somerset):
# * British Canister
# ************************************************************************
class AmericanCanister(Klondike):
Talon_Class = InitialDealTalonStack
RowStack_Class = AC_RowStack
@ -364,7 +396,8 @@ class BritishCanister(AmericanCanister):
class AgnesSorel(Klondike):
Talon_Class = DealRowTalonStack
Foundation_Class = StackWrapper(SS_FoundationStack, mod=13, base_rank=NO_RANK, max_move=0)
Foundation_Class = StackWrapper(
SS_FoundationStack, mod=13, base_rank=NO_RANK, max_move=0)
RowStack_Class = StackWrapper(SC_RowStack, mod=13, base_rank=NO_RANK)
def createGame(self):
@ -372,7 +405,7 @@ class AgnesSorel(Klondike):
def startGame(self):
Klondike.startGame(self, flip=1)
c = self.s.talon.dealSingleBaseCard()
self.s.talon.dealSingleBaseCard()
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return (card1.color == card2.color and
@ -415,8 +448,9 @@ class EightByEight_RowStack(RK_RowStack):
return len(cards) == 1
return True
class EightByEight(EightTimesEight):
Layout_Method = Layout.klondikeLayout ##gypsyLayout
Layout_Method = Layout.klondikeLayout # gypsyLayout
Talon_Class = CanfieldRush_Talon
RowStack_Class = EightByEight_RowStack
@ -439,9 +473,11 @@ class Batsford_ReserveStack(ReserveStack):
return False
# must be a King
return cards[0].rank == KING
def getHelp(self):
return _('Reserve. Only Kings are acceptable.')
class Batsford(Klondike):
def createGame(self, **layout):
kwdefault(layout, rows=10, max_rounds=1, playcards=22)
@ -451,7 +487,9 @@ class Batsford(Klondike):
s = self.s
x, y = l.XM, self.height - l.YS
s.reserves.append(Batsford_ReserveStack(x, y, self, max_cards=3))
self.setRegion(s.reserves, (-999, y - l.YM - l.CH/2, x + l.XS - l.CW/2, 999999), priority=1)
self.setRegion(
s.reserves, (-999, y - l.YM - l.CH/2, x + l.XS - l.CW/2, 999999),
priority=1)
l.createText(s.reserves[0], "se")
if round_text:
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
@ -479,6 +517,7 @@ class Jumbo(Klondike):
self.s.talon.dealRow()
self.s.talon.dealCards() # deal first card to WasteStack
class OpenJumbo(Jumbo):
def startGame(self):
Jumbo.startGame(self, flip=1)
@ -542,7 +581,8 @@ class KingAlbert(Klondike):
RESERVES = (2, 2, 2, 1)
def createGame(self):
l = Klondike.createGame(self, max_rounds=1, rows=self.ROWS, waste=0, texts=0)
l = Klondike.createGame(
self, max_rounds=1, rows=self.ROWS, waste=0, texts=0)
s = self.s
rw, rh = max(self.RESERVES), len(self.RESERVES)
h = max(self.height, l.YM+rh*l.YS)
@ -563,7 +603,8 @@ class Raglan(KingAlbert):
def _shuffleHook(self, cards):
# move Aces to bottom of the Talon (i.e. last cards to be dealt)
return self._shuffleHookMoveToBottom(cards, lambda c: (c.rank == 0, c.suit))
return self._shuffleHookMoveToBottom(
cards, lambda c: (c.rank == 0, c.suit))
def startGame(self):
for i in range(6):
@ -622,10 +663,10 @@ class Jane_Talon(OpenTalonStack):
return c
class Jane(Klondike):
Talon_Class = Jane_Talon
Foundation_Class = StackWrapper(SS_FoundationStack, mod=13, base_rank=NO_RANK, min_cards=1)
Foundation_Class = StackWrapper(
SS_FoundationStack, mod=13, base_rank=NO_RANK, min_cards=1)
RowStack_Class = StackWrapper(AC_RowStack, mod=13, base_rank=NO_RANK)
def createGame(self, max_rounds=1, rows=7, reserves=7, playcards=16):
@ -659,13 +700,15 @@ class Jane(Klondike):
s.reserves.append(stack)
y = y + l.YS / 2
# not needed, as no cards may be placed on the reserves
##self.setRegion(s.reserves, (x0-l.XM/2, -999, 999999, 999999), priority=1)
# self.setRegion(s.reserves, (x0-l.XM/2, -999, 999999, 999999),
# priority=1)
l.defaultStackGroups()
self.sg.dropstacks.append(s.talon)
def startGame(self, flip=0, reverse=1):
for i in range(1, len(self.s.rows)):
self.s.talon.dealRow(rows=self.s.rows[i:], flip=flip, frames=0, reverse=reverse)
self.s.talon.dealRow(
rows=self.s.rows[i:], flip=flip, frames=0, reverse=reverse)
self.startDealSample()
self.s.talon.dealRow(reverse=reverse)
self.s.talon.dealRow(rows=self.s.reserves)
@ -689,7 +732,8 @@ class AgnesBernauer_Talon(DealRowTalonStack):
class AgnesBernauer(Jane):
Talon_Class = AgnesBernauer_Talon
Foundation_Class = StackWrapper(SS_FoundationStack, mod=13, base_rank=NO_RANK, max_move=0)
Foundation_Class = StackWrapper(
SS_FoundationStack, mod=13, base_rank=NO_RANK, max_move=0)
def startGame(self):
Jane.startGame(self, flip=1)
@ -741,8 +785,9 @@ class Senate(Jane):
def _shuffleHook(self, cards):
# move Aces to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards,
lambda c: (c.rank == ACE, (c.deck, c.suit)))
return self._shuffleHookMoveToTop(
cards,
lambda c: (c.rank == ACE, (c.deck, c.suit)))
shallHighlightMatch = Game._shallHighlightMatch_SS
@ -756,6 +801,7 @@ class SenatePlus(Senate):
# * Arizona
# ************************************************************************
class Phoenix(Klondike):
Hint_Class = CautiousDefaultHint
@ -777,10 +823,13 @@ class Phoenix(Klondike):
y = l.YM + j*(l.YS+l.YM)
s.reserves.append(OpenStack(x, y, self, max_accept=0))
for i in range(4):
s.foundations.append(SS_FoundationStack(l.XM+(3+i)*l.XS, l.YM, self, i))
s.foundations.append(
SS_FoundationStack(l.XM+(3+i)*l.XS, l.YM, self, i))
for i in range(6):
s.rows.append(self.RowStack_Class(l.XM+(2+i)*l.XS, l.YM+l.YS, self))
s.talon = InitialDealTalonStack(l.XM+int(4.5*l.XS), l.YM+3*(l.YS+l.YM), self)
s.rows.append(
self.RowStack_Class(l.XM+(2+i)*l.XS, l.YM+l.YS, self))
s.talon = InitialDealTalonStack(
l.XM+int(4.5*l.XS), l.YM+3*(l.YS+l.YM), self)
l.defaultStackGroups()
@ -907,7 +956,6 @@ class Q_C_(Klondike):
if waste.cards:
waste.moveMove(1, stack)
shallHighlightMatch = Game._shallHighlightMatch_SS
@ -920,6 +968,7 @@ 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)
@ -938,6 +987,7 @@ class ArticGarden(NorthwestTerritory):
class AuntMary(Klondike):
def createGame(self):
Klondike.createGame(self, rows=6, max_rounds=1)
def startGame(self):
for i in range(5):
j = i+1
@ -961,17 +1011,18 @@ class DoubleDot(Klondike):
Klondike.createGame(self, max_rounds=1, rows=8, waste=0)
def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards,
lambda c: ((c.rank == ACE and c.suit in (0,1)) or
(c.rank == 1 and c.suit in (2,3)), c.suit))
return self._shuffleHookMoveToTop(
cards,
lambda c: ((c.rank == ACE and c.suit in (0, 1)) or
(c.rank == 1 and c.suit in (2, 3)), c.suit))
def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
self.startDealSample()
self.s.talon.dealRow()
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return abs(card1.rank-card2.rank) == 2
# def shallHighlightMatch(self, stack1, card1, stack2, card2):
# return abs(card1.rank-card2.rank) == 2
shallHighlightMatch = Game._shallHighlightMatch_RKW
@ -984,7 +1035,7 @@ class SevenDevils_RowStack(AC_RowStack):
def acceptsCards(self, from_stack, cards):
if not AC_RowStack.acceptsCards(self, from_stack, cards):
return False
return not from_stack in self.game.s.reserves
return from_stack not in self.game.s.reserves
class SevenDevils(Klondike):
@ -1019,7 +1070,6 @@ class SevenDevils(Klondike):
l.defaultStackGroups()
def startGame(self, flip=0, reverse=1):
Klondike.startGame(self)
self.s.talon.dealRow(rows=self.s.reserves)
@ -1083,6 +1133,7 @@ class AliBaba(BigForty):
# move Aces to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards,
lambda c: (c.rank == ACE, c.suit))
def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0)
BigForty.startGame(self)
@ -1100,6 +1151,7 @@ class Cassim(AliBaba):
class Saratoga(Klondike):
def createGame(self):
Klondike.createGame(self, num_deal=3)
def startGame(self):
Klondike.startGame(self, flip=1)
@ -1145,6 +1197,7 @@ class Boost(Klondike):
class GoldRush(Klondike):
Talon_Class = CanfieldRush_Talon
def createGame(self):
l = Klondike.createGame(self, max_rounds=3, round_text=True)
l.createRoundText(self.s.talon, 'ne', dx=l.XS)
@ -1246,7 +1299,7 @@ class Legion(Klondike):
def startGame(self):
self.startDealSample()
self.s.talon.dealRow()
for i in (1,2,3):
for i in (1, 2, 3):
self.s.talon.dealRow(rows=self.s.rows[i:-i], flip=0)
self.s.talon.dealRow(rows=self.s.rows[i:-i])
self.s.talon.dealCards()
@ -1268,7 +1321,7 @@ class BigBertha(Game):
x, y = l.XM+3.5*l.XS, l.YM
for i in range(8):
s.foundations.append(SS_FoundationStack(x, y, self,
suit=i%4, max_cards=12))
suit=i % 4, max_cards=12))
x += l.XS
x, y = l.XM, l.YM+l.YS
@ -1286,7 +1339,6 @@ class BigBertha(Game):
l.defaultStackGroups()
def startGame(self):
for i in range(5):
self.s.talon.dealRow(frames=0)
@ -1350,6 +1402,7 @@ class EightSages_Row(AC_RowStack):
return False
return from_stack is self.game.s.waste
class EightSages(Klondike):
RowStack_Class = EightSages_Row
@ -1364,7 +1417,6 @@ class EightSages(Klondike):
self.s.talon.dealCards()
# register the game
registerGame(GameInfo(2, Klondike, "Klondike",
GI.GT_KLONDIKE, 1, -1, GI.SL_BALANCED))
@ -1380,7 +1432,7 @@ registerGame(GameInfo(67, Whitehead, "Whitehead",
GI.GT_KLONDIKE, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(39, SmallHarp, "Small Harp",
GI.GT_KLONDIKE, 1, -1, GI.SL_BALANCED,
altnames=("Die kleine Harfe",) ))
altnames=("Die kleine Harfe",)))
registerGame(GameInfo(66, Eastcliff, "Eastcliff",
GI.GT_KLONDIKE, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(224, Easthaven, "Easthaven",
@ -1394,26 +1446,28 @@ registerGame(GameInfo(107, PasSeul, "Pas Seul",
registerGame(GameInfo(81, BlindAlleys, "Blind Alleys",
GI.GT_KLONDIKE, 1, 1, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(215, Somerset, "Somerset",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(231, Canister, "Canister",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(229, AgnesSorel, "Agnes Sorel",
GI.GT_GYPSY, 1, 0, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(4, EightTimesEight, "8 x 8",
GI.GT_KLONDIKE, 2, -1, GI.SL_BALANCED))
registerGame(GameInfo(127, AchtmalAcht, "Eight Times Eight",
GI.GT_KLONDIKE, 2, 2, GI.SL_BALANCED,
altnames=("Achtmal Acht",) ))
altnames=("Achtmal Acht",)))
registerGame(GameInfo(133, Batsford, "Batsford",
GI.GT_KLONDIKE, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(221, Stonewall, "Stonewall",
GI.GT_RAGLAN, 1, 0, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(222, FlowerGarden, "Flower Garden",
GI.GT_RAGLAN | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL,
altnames=("The Bouquet", "The Garden",) ))
altnames=("The Bouquet", "The Garden",)))
registerGame(GameInfo(233, KingAlbert, "King Albert",
GI.GT_RAGLAN | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL,
altnames=("Idiot's Delight",) ))
altnames=("Idiot's Delight",)))
registerGame(GameInfo(232, Raglan, "Raglan",
GI.GT_RAGLAN | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(223, Brigade, "Brigade",
@ -1437,7 +1491,8 @@ registerGame(GameInfo(350, Q_C_, "Q.C.",
registerGame(GameInfo(361, NorthwestTerritory, "Northwest Territory",
GI.GT_RAGLAN, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(362, Morehead, "Morehead",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(388, Senate, "Senate",
GI.GT_RAGLAN, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(389, SenatePlus, "Senate +",
@ -1485,9 +1540,11 @@ registerGame(GameInfo(585, LuckyThirteen, "Lucky Thirteen",
registerGame(GameInfo(586, LuckyPiles, "Lucky Piles",
GI.GT_FAN_TYPE, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(601, AmericanCanister, "American Canister",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(602, BritishCanister, "British Canister",
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
GI.GT_BELEAGUERED_CASTLE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(607, Legion, "Legion",
GI.GT_KLONDIKE, 1, 0, GI.SL_BALANCED))
registerGame(GameInfo(627, QueenVictoria, "Queen Victoria",
@ -1506,4 +1563,3 @@ registerGame(GameInfo(669, Scarp, "Scarp",
GI.GT_GYPSY | GI.GT_ORIGINAL, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(726, EightSages, "Eight Sages",
GI.GT_KLONDIKE, 2, 1, GI.SL_MOSTLY_LUCK))

View file

@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
# my $cmd = shell_quote( 'flake8', '.' );
my $cmd = shell_quote( 'flake8',
grep { not($_ eq './pysollib/pysoltk.py' or $_ eq './pysollib/tile/ttk.py') } glob('./pysollib/*.py ./pysollib/[cmpuw]*/*.py ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py ./pysollib/games/[a-hy-z]*.py') );
grep { not($_ eq './pysollib/pysoltk.py' or $_ eq './pysollib/tile/ttk.py') } glob('./pysollib/*.py ./pysollib/[cmpuw]*/*.py ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py ./pysollib/games/[a-ky-z]*.py') );
# TEST
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );