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

flake8 - games/s*

This commit is contained in:
Shlomi Fish 2017-04-18 10:09:28 +03:00
parent 1d71da6bac
commit a32fc12218
7 changed files with 340 additions and 221 deletions

View file

@ -24,23 +24,25 @@
__all__ = [] __all__ = []
# imports # imports
import sys
# PySol imports # PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI 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.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint, Yukon_Hint from pysollib.hint import Yukon_Hint
from pysollib.games.gypsy import Gypsy from pysollib.games.gypsy import Gypsy
from pysollib.stack import \
Yukon_AC_RowStack, \
StackWrapper, \
WasteTalonStack, \
SS_FoundationStack
# ************************************************************************ # ************************************************************************
# * Sanibel # * Sanibel
# * play similar to Yukon # * play similar to Yukon
# ************************************************************************ # ************************************************************************
class Sanibel(Gypsy): class Sanibel(Gypsy):
Layout_Method = Layout.klondikeLayout Layout_Method = Layout.klondikeLayout
Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1) Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1)
@ -65,5 +67,5 @@ class Sanibel(Gypsy):
registerGame(GameInfo(201, Sanibel, "Sanibel", registerGame(GameInfo(201, Sanibel, "Sanibel",
GI.GT_YUKON | GI.GT_CONTRIB | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_YUKON | GI.GT_CONTRIB | GI.GT_ORIGINAL, 2, 0,
GI.SL_MOSTLY_SKILL))

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*- # -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
# #
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer # Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co. # Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,25 +19,35 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
__all__ = [] __all__ = []
# imports # imports
import sys
# PySol imports # PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.stack import *
from pysollib.game import Game from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint from pysollib.hint import CautiousDefaultHint
from pysollib.util import ACE, KING, QUEEN
from pysollib.stack import \
BasicRowStack, \
InitialDealTalonStack, \
InvisibleStack, \
ReserveStack, \
Stack, \
getPileFromStacks, \
isSameSuitSequence, \
SS_FoundationStack
# ************************************************************************ # ************************************************************************
# * # *
# ************************************************************************ # ************************************************************************
class SiebenBisAs_Hint(CautiousDefaultHint): class SiebenBisAs_Hint(CautiousDefaultHint):
def computeHints(self): def computeHints(self):
game = self.game game = self.game
@ -47,12 +57,13 @@ class SiebenBisAs_Hint(CautiousDefaultHint):
if not r.cards: if not r.cards:
continue continue
assert len(r.cards) == 1 and r.cards[-1].face_up assert len(r.cards) == 1 and r.cards[-1].face_up
c, pile, rpile = r.cards[0], r.cards, [] pile, rpile = r.cards, []
# try if we can drop the card # try if we can drop the card
t, ncards = r.canDropCards(self.game.s.foundations) t, ncards = r.canDropCards(self.game.s.foundations)
if t: if t:
score, color = 0, None score, color = 0, None
score, color = self._getDropCardScore(score, color, r, t, ncards) score, color = self._getDropCardScore(
score, color, r, t, ncards)
self.addHint(score, ncards, r, t, color) self.addHint(score, ncards, r, t, color)
# try if we can move the card # try if we can move the card
for t in freerows: for t in freerows:
@ -62,7 +73,8 @@ class SiebenBisAs_Hint(CautiousDefaultHint):
self.addHint(score, 1, r, t) self.addHint(score, 1, r, t)
def shallMovePile(self, from_stack, to_stack, pile, rpile): def shallMovePile(self, from_stack, to_stack, pile, rpile):
if from_stack is to_stack or not to_stack.acceptsCards(from_stack, pile): if from_stack is to_stack or \
not to_stack.acceptsCards(from_stack, pile):
return 0 return 0
# now check for loops # now check for loops
rr = self.ClonedStack(from_stack, stackcards=rpile) rr = self.ClonedStack(from_stack, stackcards=rpile)
@ -76,13 +88,14 @@ class SiebenBisAs_Hint(CautiousDefaultHint):
# * Sieben bis As (Seven to Ace) # * Sieben bis As (Seven to Ace)
# ************************************************************************ # ************************************************************************
class SiebenBisAs_Foundation(SS_FoundationStack): class SiebenBisAs_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards): def acceptsCards(self, from_stack, cards):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards): if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return False return False
# this stack accepts only a card from a rowstack with an empty # this stack accepts only a card from a rowstack with an empty
# left neighbour # left neighbour
if not from_stack in self.game.s.rows: if from_stack not in self.game.s.rows:
return False return False
if from_stack.id % 10 == 0: if from_stack.id % 10 == 0:
return False return False
@ -96,17 +109,19 @@ class SiebenBisAs_RowStack(BasicRowStack):
if self.id % 10 != 0: if self.id % 10 != 0:
# left neighbour # left neighbour
s = self.game.s.rows[self.id - 1] s = self.game.s.rows[self.id - 1]
if s.cards and s.cards[-1].suit == cards[0].suit and (s.cards[-1].rank + 1) % 13 == cards[0].rank: if s.cards and s.cards[-1].suit == cards[0].suit \
and (s.cards[-1].rank + 1) % 13 == cards[0].rank:
return True return True
if self.id % 10 != 10 - 1: if self.id % 10 != 10 - 1:
# right neighbour # right neighbour
s = self.game.s.rows[self.id + 1] s = self.game.s.rows[self.id + 1]
if s.cards and s.cards[-1].suit == cards[0].suit and (s.cards[-1].rank - 1) % 13 == cards[0].rank: if s.cards and s.cards[-1].suit == cards[0].suit \
and (s.cards[-1].rank - 1) % 13 == cards[0].rank:
return True return True
return False return False
# bottom to get events for an empty stack # bottom to get events for an empty stack
###prepareBottom = Stack.prepareInvisibleBottom # prepareBottom = Stack.prepareInvisibleBottom
getBottomImage = Stack._getReserveBottomImage getBottomImage = Stack._getReserveBottomImage
@ -129,13 +144,18 @@ class SiebenBisAs(Game):
for i in range(3): for i in range(3):
for j in range(10): for j in range(10):
x, y, = l.XM + j*l.XS, l.YM + (i+1)*l.YS x, y, = l.XM + j*l.XS, l.YM + (i+1)*l.YS
s.rows.append(SiebenBisAs_RowStack(x, y, self, max_accept=1, max_cards=1)) s.rows.append(
SiebenBisAs_RowStack(
x, y, self, max_accept=1, max_cards=1))
for i in range(2): for i in range(2):
x, y, = l.XM + (i+4)*l.XS, l.YM x, y, = l.XM + (i+4)*l.XS, l.YM
s.reserves.append(ReserveStack(x, y, self, max_accept=0)) s.reserves.append(ReserveStack(x, y, self, max_accept=0))
for i in range(4): for i in range(4):
x, y, = l.XM + (i+3)*l.XS, l.YM + 4*l.YS x, y, = l.XM + (i+3)*l.XS, l.YM + 4*l.YS
s.foundations.append(SiebenBisAs_Foundation(x, y, self, i, base_rank=6, mod=13, max_move=0, max_cards=8)) s.foundations.append(
SiebenBisAs_Foundation(
x, y, self, i, base_rank=6, mod=13,
max_move=0, max_cards=8))
s.talon = InitialDealTalonStack(l.XM, self.height-l.YS, self) s.talon = InitialDealTalonStack(l.XM, self.height-l.YS, self)
# define stack-groups # define stack-groups
@ -162,7 +182,8 @@ class SiebenBisAs(Game):
class Maze_Hint(SiebenBisAs_Hint): class Maze_Hint(SiebenBisAs_Hint):
def shallMovePile(self, from_stack, to_stack, pile, rpile): def shallMovePile(self, from_stack, to_stack, pile, rpile):
if from_stack is to_stack or not to_stack.acceptsCards(from_stack, pile): if from_stack is to_stack or \
not to_stack.acceptsCards(from_stack, pile):
return False return False
# now check for loops # now check for loops
rr = self.ClonedStack(from_stack, stackcards=rpile) rr = self.ClonedStack(from_stack, stackcards=rpile)
@ -180,14 +201,16 @@ class Maze_RowStack(BasicRowStack):
# left neighbour # left neighbour
s = self.game.s.rows[(self.id - 1) % 54] s = self.game.s.rows[(self.id - 1) % 54]
if s.cards: if s.cards:
if s.cards[-1].suit == cards[0].suit and s.cards[-1].rank + 1 == cards[0].rank: if s.cards[-1].suit == cards[0].suit and \
s.cards[-1].rank + 1 == cards[0].rank:
return True return True
if s.cards[-1].rank == QUEEN and cards[0].rank == ACE: if s.cards[-1].rank == QUEEN and cards[0].rank == ACE:
return True return True
# right neighbour # right neighbour
s = self.game.s.rows[(self.id + 1) % 54] s = self.game.s.rows[(self.id + 1) % 54]
if s.cards: if s.cards:
if s.cards[-1].suit == cards[0].suit and s.cards[-1].rank - 1 == cards[0].rank: if s.cards[-1].suit == cards[0].suit and \
s.cards[-1].rank - 1 == cards[0].rank:
return True return True
return False return False
@ -200,7 +223,7 @@ class Maze_RowStack(BasicRowStack):
class Maze(Game): class Maze(Game):
GAME_VERSION = 2 GAME_VERSION = 2
Hint_Class = Maze_Hint #SiebenBisAs_Hint Hint_Class = Maze_Hint # SiebenBisAs_Hint
# #
# game layout # game layout
@ -217,9 +240,11 @@ class Maze(Game):
for i in range(6): for i in range(6):
for j in range(9): for j in range(9):
x, y, = l.XM + j*l.XS, l.YM + i*l.YS x, y, = l.XM + j*l.XS, l.YM + i*l.YS
s.rows.append(Maze_RowStack(x, y, self, max_accept=1, max_cards=1)) s.rows.append(
##s.talon = InitialDealTalonStack(-2*l.XS, l.YM+5*l.YS/2, self) Maze_RowStack(x, y, self, max_accept=1, max_cards=1))
s.talon = InitialDealTalonStack(self.width-l.XS+1, self.height-l.YS, self) # s.talon = InitialDealTalonStack(-2*l.XS, l.YM+5*l.YS/2, self)
s.talon = InitialDealTalonStack(
self.width-l.XS+1, self.height-l.YS, self)
# create an invisble stack to hold the four Kings # create an invisble stack to hold the four Kings
s.internals.append(InvisibleStack(self)) s.internals.append(InvisibleStack(self))
@ -233,7 +258,7 @@ class Maze(Game):
def startGame(self): def startGame(self):
frames = 0 frames = 0
for i in range(54): for i in range(54):
## if i == 8 or i == 17: # these stay empty # if i == 8 or i == 17: # these stay empty
if i >= 52: # these stay empty if i >= 52: # these stay empty
continue continue
c = self.s.talon.cards[-1] c = self.s.talon.cards[-1]
@ -277,4 +302,3 @@ registerGame(GameInfo(118, SiebenBisAs, "Sieben bis As",
registerGame(GameInfo(144, Maze, "Maze", registerGame(GameInfo(144, Maze, "Maze",
GI.GT_MONTANA | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL, GI.GT_MONTANA | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL,
si={"ncards": 48})) si={"ncards": 48}))

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*- # -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
# #
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer # Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co. # Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,27 +19,30 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
__all__ = [] __all__ = []
# imports # imports
import sys
# PySol imports # PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.mfxutil import kwdefault
from pysollib.stack import *
from pysollib.game import Game from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.util import ANY_RANK, ANY_SUIT
from pysollib.stack import \
SequenceRowStack, \
WasteStack, \
WasteTalonStack, \
AbstractFoundationStack
# ************************************************************************ # ************************************************************************
# * Simplex # * Simplex
# ************************************************************************ # ************************************************************************
def isSameRankSequence(cards): def isSameRankSequence(cards):
c0 = cards[0] c0 = cards[0]
for c in cards[1:]: for c in cards[1:]:
@ -63,6 +66,7 @@ class Simplex_RowStack(SequenceRowStack):
if s is not self and s.acceptsCards(self, self.cards): if s is not self and s.acceptsCards(self, self.cards):
return (s, 4) return (s, 4)
return (None, 0) return (None, 0)
def _isSequence(self, cards): def _isSequence(self, cards):
return isSameRankSequence(cards) return isSameRankSequence(cards)
@ -85,8 +89,9 @@ class Simplex(Game):
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
l.createText(s.waste, 's') l.createText(s.waste, 's')
x += l.XS x += l.XS
stack = Simplex_Foundation(x, y, self, stack = Simplex_Foundation(
suit=ANY_SUIT, base_rank=ANY_RANK, max_cards=52) x, y, self,
suit=ANY_SUIT, base_rank=ANY_RANK, max_cards=52)
xoffset = (self.width-3*l.XS)/51 xoffset = (self.width-3*l.XS)/51
stack.CARD_XOFFSET, stack.CARD_YOFFSET = xoffset, 0 stack.CARD_XOFFSET, stack.CARD_YOFFSET = xoffset, 0
s.foundations.append(stack) s.foundations.append(stack)
@ -98,13 +103,11 @@ class Simplex(Game):
# define stack-groups # define stack-groups
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
self.s.talon.dealCards() # deal first card to WasteStack self.s.talon.dealCards() # deal first card to WasteStack
def shallHighlightMatch(self, stack1, card1, stack2, card2): def shallHighlightMatch(self, stack1, card1, stack2, card2):
return card1.rank == card2.rank return card1.rank == card2.rank

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*- # -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
# #
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer # Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co. # Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,24 +19,53 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
__all__ = [] __all__ = []
# imports # imports
# PySol imports # PySol imports
from pysollib.mygettext import _, n_ from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.mfxutil import kwdefault from pysollib.mfxutil import kwdefault
from pysollib.stack import *
from pysollib.game import Game from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint from pysollib.hint import CautiousDefaultHint
from pysollib.hint import SpiderType_Hint, YukonType_Hint from pysollib.hint import SpiderType_Hint, YukonType_Hint
from pysollib.hint import FreeCellSolverWrapper from pysollib.hint import FreeCellSolverWrapper
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, KING, \
UNLIMITED_ACCEPTS, UNLIMITED_CARDS, UNLIMITED_MOVES
from pysollib.stack import \
AC_FoundationStack, \
AC_RowStack, \
AbstractFoundationStack, \
BasicRowStack, \
DealRowTalonStack, \
InitialDealTalonStack, \
KingAC_RowStack, \
OpenStack, \
RK_RowStack, \
ReserveStack, \
Spider_AC_Foundation, \
Spider_SS_Foundation, \
Spider_SS_RowStack, \
StackWrapper, \
SuperMoveStack_StackMethods, \
TalonStack, \
UD_SS_RowStack, \
WasteStack, \
WasteTalonStack, \
Yukon_AC_RowStack, \
Yukon_SS_RowStack, \
isAlternateColorSequence, \
isRankSequence, \
isSameColorSequence, \
isSameSuitSequence, \
SS_FoundationStack
# ************************************************************************ # ************************************************************************
# * # *
@ -85,6 +114,7 @@ class SuperMoveSpider_RowStack(SuperMoveStack_StackMethods, Spider_RowStack):
num_seq = self._getNumSSSeq(cards) num_seq = self._getNumSSSeq(cards)
max_move = self._getMaxMove(len(self.cards)) max_move = self._getMaxMove(len(self.cards))
return num_seq <= max_move return num_seq <= max_move
def canMoveCards(self, cards): def canMoveCards(self, cards):
if not self.basicCanMoveCards(cards): if not self.basicCanMoveCards(cards):
return False return False
@ -117,7 +147,8 @@ class RelaxedSpider(Game):
if l.s.waste: if l.s.waste:
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self) s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self)
for r in l.s.foundations: for r in l.s.foundations:
s.foundations.append(self.Foundation_Class(r.x, r.y, self, suit=ANY_SUIT)) s.foundations.append(
self.Foundation_Class(r.x, r.y, self, suit=ANY_SUIT))
for r in l.s.rows: for r in l.s.rows:
s.rows.append(self.RowStack_Class(r.x, r.y, self)) s.rows.append(self.RowStack_Class(r.x, r.y, self))
# default # default
@ -150,11 +181,15 @@ class Spider(RelaxedSpider):
return False return False
return True return True
class Spider1Suit(Spider): class Spider1Suit(Spider):
pass pass
class Spider2Suits(Spider): class Spider2Suits(Spider):
pass pass
class OpenSpider(Spider): class OpenSpider(Spider):
def startGame(self): def startGame(self):
Spider.startGame(self, flip=1) Spider.startGame(self, flip=1)
@ -192,7 +227,8 @@ class GroundsForADivorce_Talon(TalonStack):
class GroundsForADivorce(RelaxedSpider): class GroundsForADivorce(RelaxedSpider):
Layout_Method = Layout.harpLayout Layout_Method = Layout.harpLayout
Talon_Class = GroundsForADivorce_Talon Talon_Class = GroundsForADivorce_Talon
Foundation_Class = StackWrapper(Spider_SS_Foundation, base_rank=ANY_RANK, mod=13) Foundation_Class = StackWrapper(
Spider_SS_Foundation, base_rank=ANY_RANK, mod=13)
RowStack_Class = StackWrapper(Spider_RowStack, mod=13) RowStack_Class = StackWrapper(Spider_RowStack, mod=13)
def createGame(self): def createGame(self):
@ -277,6 +313,7 @@ class SimpleSimon(Spider):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
class SimpleSimonII(SimpleSimon): class SimpleSimonII(SimpleSimon):
Solver_Class = None Solver_Class = None
Foundation_Class = StackWrapper(Spider_SS_Foundation, Foundation_Class = StackWrapper(Spider_SS_Foundation,
@ -309,6 +346,7 @@ class Rachel(RelaxedSpider):
class Scorpion_RowStack(Yukon_SS_RowStack, Spider_RowStack): class Scorpion_RowStack(Yukon_SS_RowStack, Spider_RowStack):
canDropCards = Spider_RowStack.canDropCards canDropCards = Spider_RowStack.canDropCards
class Scorpion(RelaxedSpider): class Scorpion(RelaxedSpider):
Hint_Class = YukonType_Hint Hint_Class = YukonType_Hint
@ -333,6 +371,7 @@ class Scorpion(RelaxedSpider):
class ScorpionTail_RowStack(Yukon_AC_RowStack, Spider_RowStack): class ScorpionTail_RowStack(Yukon_AC_RowStack, Spider_RowStack):
canDropCards = Spider_RowStack.canDropCards canDropCards = Spider_RowStack.canDropCards
class ScorpionTail(Scorpion): class ScorpionTail(Scorpion):
Foundation_Class = Spider_AC_Foundation Foundation_Class = Spider_AC_Foundation
RowStack_Class = StackWrapper(ScorpionTail_RowStack, base_rank=KING) RowStack_Class = StackWrapper(ScorpionTail_RowStack, base_rank=KING)
@ -342,8 +381,10 @@ class ScorpionTail(Scorpion):
class DoubleScorpion(Scorpion): class DoubleScorpion(Scorpion):
Talon_Class = InitialDealTalonStack Talon_Class = InitialDealTalonStack
def createGame(self): def createGame(self):
RelaxedSpider.createGame(self, rows=10, playcards=26, texts=0) RelaxedSpider.createGame(self, rows=10, playcards=26, texts=0)
def startGame(self): def startGame(self):
for i in (5, 5, 5, 5, 0, 0, 0, 0, 0): for i in (5, 5, 5, 5, 0, 0, 0, 0, 0):
self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0) self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0)
@ -355,8 +396,10 @@ class DoubleScorpion(Scorpion):
class TripleScorpion(Scorpion): class TripleScorpion(Scorpion):
Talon_Class = InitialDealTalonStack Talon_Class = InitialDealTalonStack
def createGame(self): def createGame(self):
RelaxedSpider.createGame(self, rows=13, playcards=30, texts=0) RelaxedSpider.createGame(self, rows=13, playcards=30, texts=0)
def startGame(self): def startGame(self):
for i in (5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0): for i in (5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0):
self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0) self.s.talon.dealRow(rows=self.s.rows[:i], flip=0, frames=0)
@ -400,7 +443,8 @@ class ThreeBlindMice(Scorpion):
s.talon = self.Talon_Class(w-l.XS, h-l.YS, self) s.talon = self.Talon_Class(w-l.XS, h-l.YS, self)
x, y = l.XM+6*l.XS, l.YM x, y = l.XM+6*l.XS, l.YM
for i in range(4): for i in range(4):
s.foundations.append(self.Foundation_Class(x, y, self, suit=ANY_SUIT)) s.foundations.append(
self.Foundation_Class(x, y, self, suit=ANY_SUIT))
x += l.XS x += l.XS
x, y = l.XM, l.YM+l.YS x, y = l.XM, l.YM+l.YS
for i in range(10): for i in range(10):
@ -464,7 +508,8 @@ class RougeEtNoir(Game):
s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self) s.waste = WasteStack(l.s.waste.x, l.s.waste.y, self)
for i in range(4): for i in range(4):
r = l.s.foundations[i] r = l.s.foundations[i]
s.foundations.append(AC_FoundationStack(r.x, r.y, self, suit=i, max_move=0)) s.foundations.append(
AC_FoundationStack(r.x, r.y, self, suit=i, max_move=0))
for i in range(4): for i in range(4):
r = l.s.foundations[i+4] r = l.s.foundations[i+4]
s.foundations.append(Spider_AC_Foundation(r.x, r.y, self)) s.foundations.append(Spider_AC_Foundation(r.x, r.y, self))
@ -476,7 +521,8 @@ class RougeEtNoir(Game):
def startGame(self, flip=0, reverse=1): def startGame(self, flip=0, reverse=1):
for i in range(3, len(self.s.rows)): for i in range(3, 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.startDealSample()
self.s.talon.dealRow(rows=self.s.rows[:-1], reverse=reverse) self.s.talon.dealRow(rows=self.s.rows[:-1], reverse=reverse)
@ -537,7 +583,8 @@ class Cicely(Game):
y += l.YS y += l.YS
x, y = l.XM+10*l.XS, l.YM+l.YS x, y = l.XM+10*l.XS, l.YM+l.YS
for i in range(4): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) s.foundations.append(
SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
y += l.YS y += l.YS
x, y = l.XM+1.5*l.XS, l.YM x, y = l.XM+1.5*l.XS, l.YM
for i in range(8): for i in range(8):
@ -555,7 +602,6 @@ class Cicely(Game):
# define stack-groups # define stack-groups
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.reserves, frames=0) self.s.talon.dealRow(rows=self.s.reserves, frames=0)
for i in range(3): for i in range(3):
@ -563,7 +609,6 @@ class Cicely(Game):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
shallHighlightMatch = Game._shallHighlightMatch_SS shallHighlightMatch = Game._shallHighlightMatch_SS
@ -734,7 +779,7 @@ class ScorpionHead(Scorpion):
def startGame(self): def startGame(self):
rows = self.s.rows rows = self.s.rows
for i in (3,3,3,3,7,7): for i in (3, 3, 3, 3, 7, 7):
self.s.talon.dealRow(rows=rows[:i], flip=1, frames=0) self.s.talon.dealRow(rows=rows[:i], flip=1, frames=0)
self.s.talon.dealRow(rows=rows[i:], flip=0, frames=0) self.s.talon.dealRow(rows=rows[i:], flip=0, frames=0)
self.startDealSample() self.startDealSample()
@ -774,7 +819,6 @@ class SpiderWeb(RelaxedSpider):
# define stack-groups # define stack-groups
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.s.talon.dealRow(frames=0) self.s.talon.dealRow(frames=0)
self.s.talon.dealRow(frames=0) self.s.talon.dealRow(frames=0)
@ -817,7 +861,8 @@ class Applegate(Game):
s.talon = InitialDealTalonStack(x, y, self) s.talon = InitialDealTalonStack(x, y, self)
x += l.XS x += l.XS
for i in range(7): for i in range(7):
s.rows.append(Yukon_SS_RowStack(x, y, self, base_rank=KING, mod=13)) s.rows.append(
Yukon_SS_RowStack(x, y, self, base_rank=KING, mod=13))
x += l.XS x += l.XS
x, y = l.XM, l.YM+l.YS x, y = l.XM, l.YM+l.YS
for i in range(3): for i in range(3):
@ -863,6 +908,7 @@ class Applegate(Game):
class BigSpider(Spider): class BigSpider(Spider):
def createGame(self): def createGame(self):
Spider.createGame(self, rows=13, playcards=28) Spider.createGame(self, rows=13, playcards=28)
def startGame(self): def startGame(self):
for i in range(5): for i in range(5):
self.s.talon.dealRow(frames=0, flip=0) self.s.talon.dealRow(frames=0, flip=0)
@ -872,6 +918,8 @@ class BigSpider(Spider):
class BigSpider1Suit(BigSpider): class BigSpider1Suit(BigSpider):
pass pass
class BigSpider2Suits(BigSpider): class BigSpider2Suits(BigSpider):
pass pass
@ -886,8 +934,10 @@ class Spider3x3(BigSpider):
class GroundsForADivorce3Decks(BigSpider): class GroundsForADivorce3Decks(BigSpider):
Talon_Class = GroundsForADivorce_Talon Talon_Class = GroundsForADivorce_Talon
Foundation_Class = StackWrapper(Spider_SS_Foundation, base_rank=ANY_RANK, mod=13) Foundation_Class = StackWrapper(
Spider_SS_Foundation, base_rank=ANY_RANK, mod=13)
RowStack_Class = StackWrapper(Spider_RowStack, mod=13) RowStack_Class = StackWrapper(Spider_RowStack, mod=13)
def canDealCards(self): def canDealCards(self):
return Game.canDealCards(self) return Game.canDealCards(self)
shallHighlightMatch = Game._shallHighlightMatch_RKW shallHighlightMatch = Game._shallHighlightMatch_RKW
@ -924,10 +974,13 @@ class Spider4Decks(BigSpider):
class GroundsForADivorce4Decks(Spider4Decks): class GroundsForADivorce4Decks(Spider4Decks):
Talon_Class = GroundsForADivorce_Talon Talon_Class = GroundsForADivorce_Talon
Foundation_Class = StackWrapper(Spider_SS_Foundation, base_rank=ANY_RANK, mod=13) Foundation_Class = StackWrapper(
Spider_SS_Foundation, base_rank=ANY_RANK, mod=13)
RowStack_Class = StackWrapper(Spider_RowStack, mod=13) RowStack_Class = StackWrapper(Spider_RowStack, mod=13)
def createGame(self): def createGame(self):
Spider4Decks.createGame(self, rows=12) Spider4Decks.createGame(self, rows=12)
def canDealCards(self): def canDealCards(self):
return Game.canDealCards(self) return Game.canDealCards(self)
shallHighlightMatch = Game._shallHighlightMatch_RKW shallHighlightMatch = Game._shallHighlightMatch_RKW
@ -936,6 +989,7 @@ class GroundsForADivorce4Decks(Spider4Decks):
class ChineseSpider(Spider): class ChineseSpider(Spider):
def createGame(self): def createGame(self):
Spider.createGame(self, rows=12, playcards=28) Spider.createGame(self, rows=12, playcards=28)
def startGame(self): def startGame(self):
for i in range(5): for i in range(5):
self.s.talon.dealRow(frames=0, flip=0) self.s.talon.dealRow(frames=0, flip=0)
@ -950,7 +1004,8 @@ class ChineseSpider(Spider):
class York(RelaxedSpider): class York(RelaxedSpider):
Talon_Class = InitialDealTalonStack Talon_Class = InitialDealTalonStack
Foundation_Class = StackWrapper(Spider_SS_Foundation, base_rank=ANY_RANK, mod=13) Foundation_Class = StackWrapper(
Spider_SS_Foundation, base_rank=ANY_RANK, mod=13)
RowStack_Class = StackWrapper(Spider_RowStack, mod=13) RowStack_Class = StackWrapper(Spider_RowStack, mod=13)
def createGame(self): def createGame(self):
@ -975,13 +1030,14 @@ class BigYork(York):
self.s.talon.dealRow(frames=0) self.s.talon.dealRow(frames=0)
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
self.s.talon.dealRow(rows=[self.s.rows[0],self.s.rows[-1]]) self.s.talon.dealRow(rows=[self.s.rows[0], self.s.rows[-1]])
# ************************************************************************ # ************************************************************************
# * Spidike # * Spidike
# * Fred's Spider # * Fred's Spider
# ************************************************************************ # ************************************************************************
class Spidike(RelaxedSpider): class Spidike(RelaxedSpider):
RowStack_Class = StackWrapper(Spider_SS_RowStack, base_rank=KING) RowStack_Class = StackWrapper(Spider_SS_RowStack, base_rank=KING)
@ -991,7 +1047,8 @@ class Spidike(RelaxedSpider):
self.setSize(l.size[0], l.size[1]) self.setSize(l.size[0], l.size[1])
s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self) s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self)
for r in l.s.foundations: for r in l.s.foundations:
s.foundations.append(SS_FoundationStack(r.x, r.y, self, suit=r.suit)) s.foundations.append(
SS_FoundationStack(r.x, r.y, self, suit=r.suit))
for r in l.s.rows: for r in l.s.rows:
s.rows.append(self.RowStack_Class(r.x, r.y, self)) s.rows.append(self.RowStack_Class(r.x, r.y, self))
l.defaultAll() l.defaultAll()
@ -1059,17 +1116,16 @@ class LongTail(RelaxedSpider):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.reserves*2) self.s.talon.dealRow(rows=self.s.reserves*2)
def getQuickPlayScore(self, ncards, from_stack, to_stack): def getQuickPlayScore(self, ncards, from_stack, to_stack):
if to_stack in self.s.reserves: if to_stack in self.s.reserves:
return 0 return 0
return 1+RelaxedSpider.getQuickPlayScore(self, ncards, from_stack, to_stack) return 1+RelaxedSpider.getQuickPlayScore(
self, ncards, from_stack, to_stack)
class ShortTail(LongTail): class ShortTail(LongTail):
@ -1116,10 +1172,13 @@ class ScorpionII(Scorpion):
class Tarantula_RowStack(Spider_RowStack): class Tarantula_RowStack(Spider_RowStack):
def _isSequence(self, cards): def _isSequence(self, cards):
return isSameColorSequence(cards, self.cap.mod, self.cap.dir) return isSameColorSequence(cards, self.cap.mod, self.cap.dir)
def _isAcceptableSequence(self, cards): def _isAcceptableSequence(self, cards):
return isRankSequence(cards, self.cap.mod, self.cap.dir) return isRankSequence(cards, self.cap.mod, self.cap.dir)
def getHelp(self): def getHelp(self):
return _('Tableau. Build down regardless of suit. Sequences of cards in the same color can be moved as a unit.') return _('Tableau. Build down regardless of suit. Sequences of cards '
'in the same color can be moved as a unit.')
class Tarantula(Spider): class Tarantula(Spider):
@ -1170,9 +1229,11 @@ class FechtersGame_RowStack(AC_RowStack):
return (s, 13) return (s, 13)
return (None, 0) return (None, 0)
class FechtersGame(RelaxedSpider): class FechtersGame(RelaxedSpider):
Talon_Class = FechtersGame_Talon Talon_Class = FechtersGame_Talon
Foundation_Class = StackWrapper(Spider_AC_Foundation, base_rank=KING, mod=13) Foundation_Class = StackWrapper(
Spider_AC_Foundation, base_rank=KING, mod=13)
RowStack_Class = StackWrapper(FechtersGame_RowStack, base_rank=KING) RowStack_Class = StackWrapper(FechtersGame_RowStack, base_rank=KING)
def createGame(self): def createGame(self):
@ -1324,8 +1385,10 @@ class TheJollyRoger(Game):
x, y = l.XM, l.YM+2*l.YS x, y = l.XM, l.YM+2*l.YS
for i in range(13): for i in range(13):
s.rows.append(TheJollyRoger_RowStack(x, y, self, dir=2, s.rows.append(
max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS)) TheJollyRoger_RowStack(
x, y, self, dir=2,
max_move=UNLIMITED_MOVES, max_accept=UNLIMITED_ACCEPTS))
x += l.XS x += l.XS
s.talon = DealRowTalonStack(l.XM, l.YM, self) s.talon = DealRowTalonStack(l.XM, l.YM, self)
l.createText(s.talon, 's') l.createText(s.talon, 's')
@ -1348,7 +1411,6 @@ class TheJollyRoger(Game):
getQuickPlayScore = Game._getSpiderQuickPlayScore getQuickPlayScore = Game._getSpiderQuickPlayScore
# register the game # register the game
registerGame(GameInfo(10, RelaxedSpider, "Relaxed Spider", registerGame(GameInfo(10, RelaxedSpider, "Relaxed Spider",
GI.GT_SPIDER | GI.GT_RELAXED, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER | GI.GT_RELAXED, 2, 0, GI.SL_MOSTLY_SKILL))
@ -1356,10 +1418,10 @@ registerGame(GameInfo(11, Spider, "Spider",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(49, BlackWidow, "Black Widow", registerGame(GameInfo(49, BlackWidow, "Black Widow",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL, GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=("Scarab",) )) altnames=("Scarab",)))
registerGame(GameInfo(14, GroundsForADivorce, "Grounds for a Divorce", registerGame(GameInfo(14, GroundsForADivorce, "Grounds for a Divorce",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL, GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=('Scheidungsgrund',) )) altnames=('Scheidungsgrund',)))
registerGame(GameInfo(114, GrandmothersGame, "Grandmother's Game", registerGame(GameInfo(114, GrandmothersGame, "Grandmother's Game",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(24, Spiderette, "Spiderette", registerGame(GameInfo(24, Spiderette, "Spiderette",
@ -1371,7 +1433,8 @@ registerGame(GameInfo(48, WillOTheWisp, "Will o' the Wisp",
registerGame(GameInfo(50, SimpleSimon, "Simple Simon", registerGame(GameInfo(50, SimpleSimon, "Simple Simon",
GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(194, Rachel, "Rachel", registerGame(GameInfo(194, Rachel, "Rachel",
GI.GT_SPIDER | GI.GT_XORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER | GI.GT_XORIGINAL, 1, 0,
GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(29, Scorpion, "Scorpion", registerGame(GameInfo(29, Scorpion, "Scorpion",
GI.GT_SPIDER, 1, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(185, Wasp, "Wasp", registerGame(GameInfo(185, Wasp, "Wasp",
@ -1413,9 +1476,11 @@ registerGame(GameInfo(384, BigSpider, "Big Spider",
registerGame(GameInfo(401, GroundsForADivorce3Decks, "Big Divorce", registerGame(GameInfo(401, GroundsForADivorce3Decks, "Big Divorce",
GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(441, York, "York", registerGame(GameInfo(441, York, "York",
GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0, GI.SL_SKILL)) GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 2, 0,
GI.SL_SKILL))
registerGame(GameInfo(444, BigYork, "Big York", registerGame(GameInfo(444, BigYork, "Big York",
GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0, GI.SL_SKILL)) GI.GT_SPIDER | GI.GT_OPEN | GI.GT_ORIGINAL, 3, 0,
GI.SL_SKILL))
registerGame(GameInfo(445, BigSpider1Suit, "Big Spider (1 suit)", registerGame(GameInfo(445, BigSpider1Suit, "Big Spider (1 suit)",
GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL, GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL,
suits=(0, 0, 0, 0), suits=(0, 0, 0, 0),
@ -1433,14 +1498,14 @@ registerGame(GameInfo(454, Spider4Decks, "Spider (4 decks)",
registerGame(GameInfo(455, GroundsForADivorce4Decks, "Very Big Divorce", registerGame(GameInfo(455, GroundsForADivorce4Decks, "Very Big Divorce",
GI.GT_SPIDER, 4, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 4, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(458, Spidike, "Spidike", registerGame(GameInfo(458, Spidike, "Spidike",
GI.GT_SPIDER, 1, 0, GI.SL_BALANCED)) # GT_GYPSY ? GI.GT_SPIDER, 1, 0, GI.SL_BALANCED)) # GT_GYPSY ?
registerGame(GameInfo(459, FredsSpider, "Fred's Spider", registerGame(GameInfo(459, FredsSpider, "Fred's Spider",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(460, FredsSpider3Decks, "Fred's Spider (3 decks)", registerGame(GameInfo(460, FredsSpider3Decks, "Fred's Spider (3 decks)",
GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 3, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(461, OpenSpider, "Open Spider", registerGame(GameInfo(461, OpenSpider, "Open Spider",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL, GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=('Beetle',) )) altnames=('Beetle',)))
registerGame(GameInfo(501, WakeRobin, "Wake-Robin", registerGame(GameInfo(501, WakeRobin, "Wake-Robin",
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(502, TripleWakeRobin, "Wake-Robin (3 decks)", registerGame(GameInfo(502, TripleWakeRobin, "Wake-Robin (3 decks)",
@ -1469,9 +1534,9 @@ registerGame(GameInfo(680, Tarantula, "Tarantula",
registerGame(GameInfo(685, FechtersGame, "Fechter's Game", registerGame(GameInfo(685, FechtersGame, "Fechter's Game",
GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(710, Bebop, "Bebop", registerGame(GameInfo(710, Bebop, "Bebop",
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0,
#registerGame(GameInfo(000, SimpleSimonII, "Simple Simon II", GI.SL_MOSTLY_SKILL))
# registerGame(GameInfo(000, SimpleSimonII, "Simple Simon II",
# GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)) # GI.GT_SPIDER | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(711, TheJollyRoger, "The Jolly Roger", registerGame(GameInfo(711, TheJollyRoger, "The Jolly Roger",
GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL)) GI.GT_SPIDER | GI.GT_ORIGINAL, 2, 0, GI.SL_MOSTLY_SKILL))

View file

@ -24,16 +24,24 @@
__all__ = [] __all__ = []
# imports # imports
import sys, types
# PySol imports # PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.mfxutil import kwdefault
from pysollib.stack import *
from pysollib.game import Game from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint from pysollib.hint import CautiousDefaultHint
from pysollib.util import ACE, JACK, KING, NO_RANK
from pysollib.stack import \
DealRowTalonStack, \
InitialDealTalonStack, \
RedealTalonStack, \
StackWrapper, \
TalonStack, \
UD_RK_RowStack, \
UD_SS_RowStack, \
SS_FoundationStack
# ************************************************************************ # ************************************************************************
@ -79,10 +87,10 @@ class StHelena_FoundationStack(SS_FoundationStack):
return False return False
if self.game.s.talon.round == 1: if self.game.s.talon.round == 1:
if (self.cap.base_rank == KING and if (self.cap.base_rank == KING and
from_stack in self.game.s.rows[6:10:]): from_stack in self.game.s.rows[6:10:]):
return False return False
if (self.cap.base_rank == ACE and if (self.cap.base_rank == ACE and
from_stack in self.game.s.rows[:4]): from_stack in self.game.s.rows[:4]):
return False return False
return True return True
@ -146,7 +154,9 @@ class StHelena(Game):
# #
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToBottom(cards, lambda c: (c.deck == 0 and c.rank in (0, 12), (-c.rank, c.suit)), 8) return self._shuffleHookMoveToBottom(
cards, lambda c: (c.deck == 0 and c.rank in (0, 12),
(-c.rank, c.suit)), 8)
def startGame(self): def startGame(self):
for i in range(7): for i in range(7):
@ -161,6 +171,7 @@ class StHelena(Game):
# * Box Kite # * Box Kite
# ************************************************************************ # ************************************************************************
class BoxKite(StHelena): class BoxKite(StHelena):
Talon_Class = InitialDealTalonStack Talon_Class = InitialDealTalonStack
Foundation_Class = SS_FoundationStack Foundation_Class = SS_FoundationStack
@ -169,7 +180,6 @@ class BoxKite(StHelena):
shallHighlightMatch = Game._shallHighlightMatch_RKW shallHighlightMatch = Game._shallHighlightMatch_RKW
# ************************************************************************ # ************************************************************************
# * Les Quatre Coins # * Les Quatre Coins
# ************************************************************************ # ************************************************************************
@ -223,7 +233,7 @@ class LesQuatreCoins(Game):
l, s = Layout(self), self.s l, s = Layout(self), self.s
self.setSize(l.XM+7*l.XS, l.YM+5*l.YS) self.setSize(l.XM+7*l.XS, l.YM+5*l.YS)
for i, j in ((0,0),(5,0),(0,4),(5,4)): for i, j in ((0, 0), (5, 0), (0, 4), (5, 4)):
x, y = l.XM+l.XS+i*l.XS, l.YM+j*l.YS x, y = l.XM+l.XS+i*l.XS, l.YM+j*l.YS
stack = LesQuatreCoins_RowStack(x, y, self, stack = LesQuatreCoins_RowStack(x, y, self,
max_move=1, base_rank=NO_RANK) max_move=1, base_rank=NO_RANK)
@ -254,7 +264,6 @@ class LesQuatreCoins(Game):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealCards() self.s.talon.dealCards()
@ -281,10 +290,10 @@ class RegalFamily(Game):
l, s = Layout(self), self.s l, s = Layout(self), self.s
self.setSize(l.XM+8*l.XS, l.YM+5*l.YS) self.setSize(l.XM+8*l.XS, l.YM+5*l.YS)
for i, j in ((0,0),(1,0),(2,0),(3,0),(4,0),(5,0),(6,0), for i, j in ((0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0),
(6,1),(6,2),(6,3), (6, 1), (6, 2), (6, 3),
(6,4),(5,4),(4,4),(3,4),(2,4),(1,4),(0,4), (6, 4), (5, 4), (4, 4), (3, 4), (2, 4), (1, 4), (0, 4),
(0,3),(0,2),(0,1) (0, 3), (0, 2), (0, 1)
): ):
x, y = l.XM+l.XS+i*l.XS, l.YM+j*l.YS x, y = l.XM+l.XS+i*l.XS, l.YM+j*l.YS
stack = RegalFamily_RowStack(x, y, self, stack = RegalFamily_RowStack(x, y, self,
@ -312,16 +321,13 @@ class RegalFamily(Game):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
shallHighlightMatch = Game._shallHighlightMatch_SS shallHighlightMatch = Game._shallHighlightMatch_SS
# register the game # register the game
registerGame(GameInfo(302, StHelena, "St. Helena", registerGame(GameInfo(302, StHelena, "St. Helena",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED, GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED,
@ -334,4 +340,3 @@ registerGame(GameInfo(620, LesQuatreCoins, "Les Quatre Coins",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_SKILL)) GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(621, RegalFamily, "Regal Family", registerGame(GameInfo(621, RegalFamily, "Regal Family",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED)) GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*- # -*- mode: python; coding: utf-8; -*-
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
# #
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer # Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 2003 Mt. Hood Playing Card Co. # Copyright (C) 2003 Mt. Hood Playing Card Co.
@ -19,21 +19,42 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# ---------------------------------------------------------------------------## # ---------------------------------------------------------------------------
__all__ = [] __all__ = []
# imports # imports
import sys
# PySol imports # PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.util import *
from pysollib.mfxutil import kwdefault
from pysollib.stack import *
from pysollib.game import Game from pysollib.game import Game
from pysollib.layout import Layout from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint from pysollib.hint import CautiousDefaultHint
from pysollib.util import ACE, ANY_SUIT, JACK, KING, NO_RANK, QUEEN, \
UNLIMITED_REDEALS
from pysollib.stack import \
AC_FoundationStack, \
AbstractFoundationStack, \
BasicRowStack, \
DealRowRedealTalonStack, \
DealRowTalonStack, \
InitialDealTalonStack, \
KingAC_RowStack, \
OpenStack, \
RK_FoundationStack, \
RK_RowStack, \
ReserveStack, \
SS_RowStack, \
Stack, \
StackWrapper, \
TalonStack, \
UD_AC_RowStack, \
UD_SS_RowStack, \
WasteStack, \
WasteTalonStack, \
SS_FoundationStack
# ************************************************************************ # ************************************************************************
@ -55,20 +76,21 @@ class Sultan(Game):
self.setSize(w, h) self.setSize(w, h)
# create stacks # create stacks
lay = ((0,0,0,1,13), lay = ((0, 0, 0, 1, 13),
(2,0,0,1,13), (2, 0, 0, 1, 13),
(0,1,1,1,13), (0, 1, 1, 1, 13),
(2,1,1,1,13), (2, 1, 1, 1, 13),
(1,1,2,0,1), (1, 1, 2, 0, 1),
(1,2,2,1,13), (1, 2, 2, 1, 13),
(0,2,3,1,13), (0, 2, 3, 1, 13),
(2,2,3,1,13), (2, 2, 3, 1, 13),
(1,0,2,1,12), (1, 0, 2, 1, 12),
) )
for i, j, suit, max_accept, max_cards in lay: for i, j, suit, max_accept, max_cards in lay:
x, y = 2*l.XM+l.XS+i*l.XS, l.YM+j*l.YS x, y = 2*l.XM+l.XS+i*l.XS, l.YM+j*l.YS
stack = SS_FoundationStack(x, y, self, suit=suit, stack = SS_FoundationStack(
max_move=0, max_accept=max_accept, max_cards=max_cards, mod=13) x, y, self, suit=suit,
max_move=0, max_accept=max_accept, max_cards=max_cards, mod=13)
s.foundations.append(stack) s.foundations.append(stack)
x, y = l.XM, l.YM x, y = l.XM, l.YM
@ -97,10 +119,12 @@ class Sultan(Game):
# #
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
cards = self._shuffleHookMoveToTop(cards, cards = self._shuffleHookMoveToTop(
lambda c: (c.rank == ACE and c.suit == 2 and c.deck == 0, c.suit)) cards,
cards = self._shuffleHookMoveToTop(cards, lambda c: (c.rank == ACE and c.suit == 2 and c.deck == 0, c.suit))
lambda c: (c.rank == KING, c.suit)) cards = self._shuffleHookMoveToTop(
cards,
lambda c: (c.rank == KING, c.suit))
return cards return cards
def startGame(self): def startGame(self):
@ -168,8 +192,9 @@ class Boudoir(Game):
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move 4 Queens to top of the Talon (i.e. first cards to be dealt) # move 4 Queens to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank == QUEEN and c.deck == 0, c.suit)) cards,
lambda c: (c.rank == QUEEN and c.deck == 0, c.suit))
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
@ -259,12 +284,11 @@ class Contradance(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move 5's and 6's to top of the Talon (i.e. first cards to be dealt) # move 5's and 6's to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank in (4, 5), (c.rank, c.suit))) cards,
lambda c: (c.rank in (4, 5), (c.rank, c.suit)))
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
@ -300,16 +324,20 @@ class IdleAces(Game):
k = 0 k = 0
for i, j in((2, 0), (0, 1.5), (4, 1.5), (2, 3)): for i, j in((2, 0), (0, 1.5), (4, 1.5), (2, 3)):
x, y = x0+i*l.XS, y0+j*l.YS x, y = x0+i*l.XS, y0+j*l.YS
s.foundations.append(RK_FoundationStack(x, y, self, s.foundations.append(
##suit=ANY_SUIT, RK_FoundationStack(
base_rank=KING, dir=-1, max_move=0)) x, y, self,
# suit=ANY_SUIT,
base_rank=KING, dir=-1, max_move=0))
k += 1 k += 1
k = 0 k = 0
for i, j in((2, 1), (1, 1.5), (3, 1.5), (2, 2)): for i, j in((2, 1), (1, 1.5), (3, 1.5), (2, 2)):
x, y = x0+i*l.XS, y0+j*l.YS x, y = x0+i*l.XS, y0+j*l.YS
s.foundations.append(RK_FoundationStack(x, y, self, s.foundations.append(
##suit=ANY_SUIT, RK_FoundationStack(
base_rank=1, max_move=0, max_cards=12)) x, y, self,
# suit=ANY_SUIT,
base_rank=1, max_move=0, max_cards=12))
k += 1 k += 1
k = 0 k = 0
for i, j in((1, 0.2), (3, 0.2), (1, 2.8), (3, 2.8)): for i, j in((1, 0.2), (3, 0.2), (1, 2.8), (3, 2.8)):
@ -320,11 +348,10 @@ class IdleAces(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank in (1, KING) and c.deck == 0, (-c.rank, c.suit))) cards,
lambda c: (c.rank in (1, KING) and c.deck == 0, (-c.rank, c.suit)))
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
@ -357,34 +384,38 @@ class LadyOfTheManor(Game):
x, y = l.XM, self.height-l.YS x, y = l.XM, self.height-l.YS
for i in range(4): for i in range(4):
suit = i suit = i
if self.Foundation_Class_1 is RK_FoundationStack: suit = ANY_SUIT if self.Foundation_Class_1 is RK_FoundationStack:
s.foundations.append(self.Foundation_Class_1(x, y, self, suit=suit)) suit = ANY_SUIT
s.foundations.append(
self.Foundation_Class_1(x, y, self, suit=suit))
x += l.XS x += l.XS
for i in range(4): for i in range(4):
suit = i suit = i
if self.Foundation_Class_1 is RK_FoundationStack: suit = ANY_SUIT if self.Foundation_Class_1 is RK_FoundationStack:
s.foundations.append(self.Foundation_Class_2(x, y, self, suit=suit)) suit = ANY_SUIT
s.foundations.append(
self.Foundation_Class_2(x, y, self, suit=suit))
x += l.XS x += l.XS
x, y = l.XM+2*l.XS, l.YM+l.YS x, y = l.XM+2*l.XS, l.YM+l.YS
for i in range(4): for i in range(4):
s.rows.append(LadyOfTheManor_RowStack(x, y, self, max_accept=0)) s.rows.append(LadyOfTheManor_RowStack(x, y, self, max_accept=0))
x += l.XS x += l.XS
for i, j in ((0,2), (0,1), (0,0), for i, j in ((0, 2), (0, 1), (0, 0),
(1,0), (2,0), (3,0), (4,0), (5,0), (6,0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0),
(7,0), (7,1), (7,2),): (7, 0), (7, 1), (7, 2), ):
x, y = l.XM+i*l.XS, l.YM+j*l.YS x, y = l.XM+i*l.XS, l.YM+j*l.YS
s.reserves.append(LadyOfTheManor_Reserve(x, y, self, max_accept=0)) s.reserves.append(LadyOfTheManor_Reserve(x, y, self, max_accept=0))
s.talon = InitialDealTalonStack(self.width-l.XS, self.height-2*l.YS, self) s.talon = InitialDealTalonStack(
self.width-l.XS, self.height-2*l.YS, self)
l.defaultAll() l.defaultAll()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Aces to top of the Talon (i.e. first cards to be dealt) # move Aces to top of the Talon (i.e. first cards to be dealt)
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank == ACE, c.suit)) cards,
lambda c: (c.rank == ACE, c.suit))
def startGame(self, flip=False): def startGame(self, flip=False):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -411,10 +442,8 @@ class Matrimony_Talon(DealRowTalonStack):
return not self.game.isGameWon() return not self.game.isGameWon()
def _redeal(self): def _redeal(self):
lr = len(self.game.s.rows)
num_cards = 0 num_cards = 0
assert len(self.cards) == 0 assert len(self.cards) == 0
rows = self.game.s.rows
r = self.game.s.rows[-self.round] r = self.game.s.rows[-self.round]
for i in range(len(r.cards)): for i in range(len(r.cards)):
num_cards += 1 num_cards += 1
@ -436,7 +465,8 @@ class Matrimony_Talon(DealRowTalonStack):
rows = self.game.s.rows[-self.round+1:] rows = self.game.s.rows[-self.round+1:]
num_cards += self.dealRowAvail(rows=rows, sound=False) num_cards += self.dealRowAvail(rows=rows, sound=False)
while self.cards: while self.cards:
num_cards += self.dealRowAvail(rows=self.game.s.rows, sound=False) num_cards += self.dealRowAvail(
rows=self.game.s.rows, sound=False)
if sound: if sound:
self.game.stopSamples() self.game.stopSamples()
return num_cards return num_cards
@ -475,13 +505,12 @@ class Matrimony(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
cards,
lambda c: (c.rank in (JACK, QUEEN) and c.deck == 0 and c.suit == 3, lambda c: (c.rank in (JACK, QUEEN) and c.deck == 0 and c.suit == 3,
(c.rank, c.suit))) (c.rank, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=[self.s.foundations[3], self.s.talon.dealRow(rows=[self.s.foundations[3],
self.s.foundations[7]], frames=0) self.s.foundations[7]], frames=0)
@ -535,13 +564,11 @@ class PicturePatience(Game):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
self.s.talon.dealCards() self.s.talon.dealCards()
def fillStack(self, stack): def fillStack(self, stack):
if stack in self.s.rows and not stack.cards: if stack in self.s.rows and not stack.cards:
if not self.s.waste.cards: if not self.s.waste.cards:
@ -555,9 +582,10 @@ class Patriarchs(PicturePatience):
PicturePatience.createGame(self, max_rounds=2) PicturePatience.createGame(self, max_rounds=2)
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank in (ACE, KING) and c.deck == 0, cards,
(c.rank, c.suit))) lambda c: (c.rank in (ACE, KING) and c.deck == 0,
(c.rank, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -609,12 +637,11 @@ class SixesAndSevens(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
cards,
lambda c: (c.rank in (5, 6), (-c.rank, c.deck, c.suit))) lambda c: (c.rank in (5, 6), (-c.rank, c.deck, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
self.startDealSample() self.startDealSample()
@ -630,7 +657,7 @@ class TwoRings(Game):
self.setSize(l.XM+10*l.XS, l.YM+5*l.YS) self.setSize(l.XM+10*l.XS, l.YM+5*l.YS)
lay = ( lay = (
(1.5, 0 ), (1.5, 0),
(2.5, 0.3), (2.5, 0.3),
(3, 1.3), (3, 1.3),
(2.5, 2.3), (2.5, 2.3),
@ -669,12 +696,11 @@ class TwoRings(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
cards,
lambda c: (c.rank in (5, 6), (-c.rank, c.suit))) lambda c: (c.rank in (5, 6), (-c.rank, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
self.startDealSample() self.startDealSample()
@ -703,7 +729,7 @@ class CornerSuite(Game):
self.setSize(l.XM+5*l.XS, l.YM+5*l.YS) self.setSize(l.XM+5*l.XS, l.YM+5*l.YS)
suit = 0 suit = 0
for x, y in ((0,0), (4,0), (0,4), (4,4)): for x, y in ((0, 0), (4, 0), (0, 4), (4, 4)):
x, y = l.XM+x*l.XS, l.YM+y*l.YS x, y = l.XM+x*l.XS, l.YM+y*l.YS
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit)) s.foundations.append(SS_FoundationStack(x, y, self, suit=suit))
suit += 1 suit += 1
@ -805,9 +831,9 @@ class RoyalAids(Game):
self.setSize(l.XM+8*l.XS, l.YM+4*l.YS+l.TEXT_HEIGHT) self.setSize(l.XM+8*l.XS, l.YM+4*l.YS+l.TEXT_HEIGHT)
x0 = l.XM+1.5*l.XS x0 = l.XM+1.5*l.XS
for k in (0,1): for k in (0, 1):
suit = 0 suit = 0
for i, j in ((1,0), (0,0.5), (2,0.5), (1,1)): for i, j in ((1, 0), (0, 0.5), (2, 0.5), (1, 1)):
x, y = x0+i*l.XS, l.YM+j*l.YS x, y = x0+i*l.XS, l.YM+j*l.YS
s.foundations.append(AC_FoundationStack(x, y, self, suit=suit)) s.foundations.append(AC_FoundationStack(x, y, self, suit=suit))
suit += 1 suit += 1
@ -821,7 +847,7 @@ class RoyalAids(Game):
l.createText(s.waste, 'se') l.createText(s.waste, 'se')
x, y = l.XM+3.75*l.XS, l.YM+2*l.YS x, y = l.XM+3.75*l.XS, l.YM+2*l.YS
for i in (0,1): for i in (0, 1):
stack = KingAC_RowStack(x, y, self, max_move=1) stack = KingAC_RowStack(x, y, self, max_move=1)
stack.getBottomImage = stack._getReserveBottomImage stack.getBottomImage = stack._getReserveBottomImage
s.rows.append(stack) s.rows.append(stack)
@ -837,11 +863,10 @@ class RoyalAids(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank == ACE, (c.deck, c.suit))) cards,
lambda c: (c.rank == ACE, (c.deck, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -852,7 +877,6 @@ class RoyalAids(Game):
self.s.talon.dealRow(rows=self.s.reserves) self.s.talon.dealRow(rows=self.s.reserves)
self.s.talon.dealCards() self.s.talon.dealCards()
shallHighlightMatch = Game._shallHighlightMatch_AC shallHighlightMatch = Game._shallHighlightMatch_AC
@ -867,14 +891,14 @@ class CircleEight(Game):
l, s = Layout(self), self.s l, s = Layout(self), self.s
self.setSize(l.XM+5*l.XS, l.YM+4*l.YS) self.setSize(l.XM+5*l.XS, l.YM+4*l.YS)
for i, j in ((1,0), for i, j in ((1, 0),
(2,0), (2, 0),
(3,0), (3, 0),
(4,1.5), (4, 1.5),
(3,3), (3, 3),
(2,3), (2, 3),
(1,3), (1, 3),
(0,1.5), (0, 1.5),
): ):
x, y = l.XM+i*l.XS, l.YM+j*l.YS x, y = l.XM+i*l.XS, l.YM+j*l.YS
stack = RK_RowStack(x, y, self, dir=1, mod=13, max_move=0) stack = RK_RowStack(x, y, self, dir=1, mod=13, max_move=0)
@ -911,7 +935,7 @@ class Adela_Foundation(SS_FoundationStack):
if not SS_FoundationStack.acceptsCards(self, from_stack, cards): if not SS_FoundationStack.acceptsCards(self, from_stack, cards):
return False return False
index = list(self.game.s.foundations).index(self) index = list(self.game.s.foundations).index(self)
index = index%8 index %= 8
return len(self.game.s.foundations[index].cards) > 0 return len(self.game.s.foundations[index].cards) > 0
@ -925,17 +949,17 @@ class Adela(Game):
x, y = l.XM+l.XS, l.YM x, y = l.XM+l.XS, l.YM
for i in range(8): for i in range(8):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i%4, s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4,
base_rank=JACK, dir=-1, max_cards=11)) base_rank=JACK, dir=-1, max_cards=11))
x += l.XS x += l.XS
x, y = l.XM+l.XS, l.YM+l.YS x, y = l.XM+l.XS, l.YM+l.YS
for i in range(8): for i in range(8):
s.foundations.append(Adela_Foundation(x, y, self, suit=i%4, s.foundations.append(Adela_Foundation(x, y, self, suit=i % 4,
base_rank=QUEEN, max_cards=1)) base_rank=QUEEN, max_cards=1))
x += l.XS x += l.XS
x, y = l.XM+l.XS, l.YM+2*l.YS x, y = l.XM+l.XS, l.YM+2*l.YS
for i in range(8): for i in range(8):
s.foundations.append(Adela_Foundation(x, y, self, suit=i%4, s.foundations.append(Adela_Foundation(x, y, self, suit=i % 4,
base_rank=KING, max_cards=1)) base_rank=KING, max_cards=1))
x += l.XS x += l.XS
x, y = l.XM, l.YM+l.YS x, y = l.XM, l.YM+l.YS
@ -950,7 +974,6 @@ class Adela(Game):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
@ -979,7 +1002,7 @@ class Toni(Game):
y = l.YM y = l.YM
suit = 0 suit = 0
for i in (0,1,3,4): for i in (0, 1, 3, 4):
x = l.XM+(2+i)*l.XS x = l.XM+(2+i)*l.XS
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit)) s.foundations.append(SS_FoundationStack(x, y, self, suit=suit))
suit += 1 suit += 1
@ -990,8 +1013,8 @@ class Toni(Game):
base_rank=KING, dir=-1)) base_rank=KING, dir=-1))
y += l.YS y += l.YS
for i, j in ((0,0),(1,0),(2,0),(5,0),(6,0),(7,0), for i, j in ((0, 0), (1, 0), (2, 0), (5, 0), (6, 0), (7, 0),
(0,1),(1,1),(2,1),(5,1),(6,1),(7,1), (0, 1), (1, 1), (2, 1), (5, 1), (6, 1), (7, 1),
): ):
x, y = l.XM+(0.5+i)*l.XS, l.YM+(1.5+j)*l.YS x, y = l.XM+(0.5+i)*l.XS, l.YM+(1.5+j)*l.YS
stack = BasicRowStack(x, y, self, max_accept=0) stack = BasicRowStack(x, y, self, max_accept=0)
@ -1005,11 +1028,11 @@ class Toni(Game):
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank in (ACE, KING) and c.deck == 0, (c.rank, c.suit))) cards,
lambda c: (c.rank in (ACE, KING) and c.deck == 0,
(c.rank, c.suit)))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -1036,12 +1059,11 @@ class Khedive(Game):
x, y = l.XM+4*l.XS, l.YM x, y = l.XM+4*l.XS, l.YM
r = range(11) r = range(11)
for i in range(5,0,-1): for i in range(5, 0, -1):
for j in r[i:-i]: for j in r[i:-i]:
x, y = l.XM+(j-0.5)*l.XS, l.YM+(5-i)*l.YS x, y = l.XM+(j-0.5)*l.XS, l.YM+(5-i)*l.YS
s.rows.append(BasicRowStack(x, y, self, max_accept=0)) s.rows.append(BasicRowStack(x, y, self, max_accept=0))
x, y = l.XM, l.YM+1.5*l.YS x, y = l.XM, l.YM+1.5*l.YS
s.talon = WasteTalonStack(x, y, self, max_rounds=1) s.talon = WasteTalonStack(x, y, self, max_rounds=1)
l.createText(s.talon, 'ne') l.createText(s.talon, 'ne')
@ -1103,14 +1125,12 @@ class Phalanx(Game):
l.defaultStackGroups() l.defaultStackGroups()
def startGame(self): def startGame(self):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow(frames=4) self.s.talon.dealRow(frames=4)
self.s.talon.dealCards() self.s.talon.dealCards()
# ************************************************************************ # ************************************************************************
# * Grandee # * Grandee
# * Turncoats # * Turncoats
@ -1235,7 +1255,7 @@ class DesertIsland(Game):
for i in range(3): for i in range(3):
x = l.XM x = l.XM
for j in range(8): for j in range(8):
##stack = SS_RowStack(x, y, self, max_move=1) # stack = SS_RowStack(x, y, self, max_move=1)
stack = ReserveStack(x, y, self) stack = ReserveStack(x, y, self)
stack.CARD_YOFFSET = 0 stack.CARD_YOFFSET = 0
s.rows.append(stack) s.rows.append(stack)
@ -1249,10 +1269,10 @@ class DesertIsland(Game):
# define stack-groups # define stack-groups
l.defaultStackGroups() l.defaultStackGroups()
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToTop(cards, return self._shuffleHookMoveToTop(
lambda c: (c.rank == ACE, c.suit)) cards,
lambda c: (c.rank == ACE, c.suit))
def startGame(self): def startGame(self):
self.s.talon.dealRow(rows=self.s.foundations, frames=0) self.s.talon.dealRow(rows=self.s.foundations, frames=0)
@ -1279,14 +1299,14 @@ class CatherineTheGreat(Game):
w, h = 3*l.XM+5*l.XS, l.YM+5*l.YS w, h = 3*l.XM+5*l.XS, l.YM+5*l.YS
self.setSize(w, h) self.setSize(w, h)
lay = ((0,2,0,QUEEN,-1), lay = ((0, 2, 0, QUEEN, -1),
(0,1,0,QUEEN,-1), (0, 1, 0, QUEEN, -1),
(0,0,1,QUEEN,-1), (0, 0, 1, QUEEN, -1),
(2,0,1,QUEEN,-1), (2, 0, 1, QUEEN, -1),
(1,0,2,QUEEN,-1), (1, 0, 2, QUEEN, -1),
(2,1,3,QUEEN,-1), (2, 1, 3, QUEEN, -1),
(2,2,3,QUEEN,-1), (2, 2, 3, QUEEN, -1),
(1,1,2,KING,1), (1, 1, 2, KING, 1),
) )
for xx, yy, suit, base_rank, dir in lay: for xx, yy, suit, base_rank, dir in lay:
x, y = 2*l.XM+l.XS+xx*l.XS, l.YM+yy*l.YS x, y = 2*l.XM+l.XS+xx*l.XS, l.YM+yy*l.YS
@ -1323,7 +1343,8 @@ class CatherineTheGreat(Game):
return (False, 0) return (False, 0)
return (True, card.suit) return (True, card.suit)
return (False, 0) return (False, 0)
cards = self._shuffleHookMoveToTop(cards, select_func) cards = self._shuffleHookMoveToTop(
cards, select_func)
return cards return cards
def startGame(self): def startGame(self):
@ -1344,26 +1365,25 @@ class CatherineTheGreat(Game):
shallHighlightMatch = Game._shallHighlightMatch_RKW shallHighlightMatch = Game._shallHighlightMatch_RKW
# register the game # register the game
registerGame(GameInfo(330, Sultan, "Sultan", registerGame(GameInfo(330, Sultan, "Sultan",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK, GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
altnames=("Sultan of Turkey",) )) altnames=("Sultan of Turkey",)))
registerGame(GameInfo(331, SultanPlus, "Sultan +", registerGame(GameInfo(331, SultanPlus, "Sultan +",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK)) GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(354, Boudoir, "Boudoir", registerGame(GameInfo(354, Boudoir, "Boudoir",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK)) GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(410, CaptiveQueens, "Captive Queens", registerGame(GameInfo(410, CaptiveQueens, "Captive Queens",
GI.GT_1DECK_TYPE, 1, 2, GI.SL_MOSTLY_LUCK, GI.GT_1DECK_TYPE, 1, 2, GI.SL_MOSTLY_LUCK,
altnames=("Quadrille",) )) altnames=("Quadrille",)))
registerGame(GameInfo(418, Contradance, "Contradance", registerGame(GameInfo(418, Contradance, "Contradance",
GI.GT_2DECK_TYPE, 2, 1, GI.SL_LUCK, GI.GT_2DECK_TYPE, 2, 1, GI.SL_LUCK,
altnames=("Cotillion",) )) altnames=("Cotillion",)))
registerGame(GameInfo(419, IdleAces, "Idle Aces", registerGame(GameInfo(419, IdleAces, "Idle Aces",
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK)) GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(423, LadyOfTheManor, "Lady of the Manor", registerGame(GameInfo(423, LadyOfTheManor, "Lady of the Manor",
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK, GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_LUCK,
altnames=("Vassal", "La Chatelaine") )) altnames=("Vassal", "La Chatelaine")))
registerGame(GameInfo(424, Matrimony, "Matrimony", registerGame(GameInfo(424, Matrimony, "Matrimony",
GI.GT_2DECK_TYPE, 2, 16, GI.SL_MOSTLY_LUCK)) GI.GT_2DECK_TYPE, 2, 16, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(429, Patriarchs, "Patriarchs", registerGame(GameInfo(429, Patriarchs, "Patriarchs",

View file

@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
# my $cmd = shell_quote( 'flake8', '.' ); # my $cmd = shell_quote( 'flake8', '.' );
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-ry-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-sy-z]*.py') );
# TEST # TEST
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." ); eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );