mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8 - games/r*
This commit is contained in:
parent
84018dbfe2
commit
1d71da6bac
3 changed files with 130 additions and 87 deletions
|
@ -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,44 @@
|
||||||
# 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.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.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 DefaultHint, CautiousDefaultHint
|
||||||
|
|
||||||
from unionsquare import UnionSquare_Foundation
|
from unionsquare import UnionSquare_Foundation
|
||||||
|
|
||||||
|
from pysollib.util import ACE, ANY_RANK, ANY_SUIT, JACK, KING, NO_RANK
|
||||||
|
|
||||||
|
from pysollib.stack import \
|
||||||
|
AC_FoundationStack, \
|
||||||
|
AC_RowStack, \
|
||||||
|
AbstractFoundationStack, \
|
||||||
|
BasicRowStack, \
|
||||||
|
DealRowTalonStack, \
|
||||||
|
OpenStack, \
|
||||||
|
OpenTalonStack, \
|
||||||
|
RK_FoundationStack, \
|
||||||
|
RK_RowStack, \
|
||||||
|
ReserveStack, \
|
||||||
|
SS_RowStack, \
|
||||||
|
Stack, \
|
||||||
|
StackWrapper, \
|
||||||
|
UD_RK_RowStack, \
|
||||||
|
UD_SS_RowStack, \
|
||||||
|
WasteStack, \
|
||||||
|
WasteTalonStack, \
|
||||||
|
isSameSuitSequence, \
|
||||||
|
SS_FoundationStack
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Royal Cotillion
|
# * Royal Cotillion
|
||||||
|
@ -69,9 +89,12 @@ class RoyalCotillion(Game):
|
||||||
s.rows.append(BasicRowStack(x, y, self, max_accept=0))
|
s.rows.append(BasicRowStack(x, y, self, max_accept=0))
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
x, y, = l.XM + 4*l.XS, l.YM + i*l.YS
|
x, y, = l.XM + 4*l.XS, l.YM + i*l.YS
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, i, dir=2, mod=13))
|
s.foundations.append(
|
||||||
x = x + l.XS
|
self.Foundation_Class(x, y, self, i, dir=2, mod=13))
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, i, dir=2, mod=13, base_rank=1))
|
x += l.XS
|
||||||
|
s.foundations.append(
|
||||||
|
self.Foundation_Class(
|
||||||
|
x, y, self, i, dir=2, mod=13, base_rank=1))
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
for j in range(4):
|
for j in range(4):
|
||||||
x, y, = l.XM + (j+6)*l.XS, l.YM + i*l.YS
|
x, y, = l.XM + (j+6)*l.XS, l.YM + i*l.YS
|
||||||
|
@ -133,14 +156,17 @@ class OddAndEven(RoyalCotillion):
|
||||||
# create stacks
|
# create stacks
|
||||||
x, y, = l.XM, l.YM
|
x, y, = l.XM, l.YM
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, i, dir=2, mod=13))
|
s.foundations.append(
|
||||||
|
self.Foundation_Class(x, y, self, i, dir=2, mod=13))
|
||||||
x = x + l.XS
|
x = x + l.XS
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, i, dir=2, mod=13, base_rank=1))
|
s.foundations.append(
|
||||||
|
self.Foundation_Class(
|
||||||
|
x, y, self, i, dir=2, mod=13, base_rank=1))
|
||||||
x = x + l.XS
|
x = x + l.XS
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
x, y, = l.XM + ((4,3)[i])*l.XS, l.YM + (i+1)*l.YS
|
x, y, = l.XM + ((4, 3)[i])*l.XS, l.YM + (i+1)*l.YS
|
||||||
for j in range((4,5)[i]):
|
for j in range((4, 5)[i]):
|
||||||
s.reserves.append(ReserveStack(x, y, self, max_accept=0))
|
s.reserves.append(ReserveStack(x, y, self, max_accept=0))
|
||||||
x = x + l.XS
|
x = x + l.XS
|
||||||
x, y = l.XM, self.height - l.YS
|
x, y = l.XM, self.height - l.YS
|
||||||
|
@ -154,7 +180,6 @@ class OddAndEven(RoyalCotillion):
|
||||||
# define stack-groups
|
# define stack-groups
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# game overrides
|
# game overrides
|
||||||
#
|
#
|
||||||
|
@ -198,14 +223,14 @@ class Kingdom(RoyalCotillion):
|
||||||
# define stack-groups
|
# define stack-groups
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# game overrides
|
# game overrides
|
||||||
#
|
#
|
||||||
|
|
||||||
def _shuffleHook(self, cards):
|
def _shuffleHook(self, cards):
|
||||||
# move one Ace to top of the Talon (i.e. first card to be dealt)
|
# move one Ace to top of the Talon (i.e. first card to be dealt)
|
||||||
return self._shuffleHookMoveToTop(cards, lambda c: (c.rank == 0, c.suit), 1)
|
return self._shuffleHookMoveToTop(
|
||||||
|
cards, lambda c: (c.rank == 0, c.suit), 1)
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
self.startDealSample()
|
self.startDealSample()
|
||||||
|
@ -228,6 +253,7 @@ class Alhambra_Hint(CautiousDefaultHint):
|
||||||
|
|
||||||
class Alhambra_RowStack(UD_SS_RowStack):
|
class Alhambra_RowStack(UD_SS_RowStack):
|
||||||
getBottomImage = Stack._getReserveBottomImage
|
getBottomImage = Stack._getReserveBottomImage
|
||||||
|
|
||||||
def getHelp(self):
|
def getHelp(self):
|
||||||
return _('Waste. Build up or down by suit.')
|
return _('Waste. Build up or down by suit.')
|
||||||
|
|
||||||
|
@ -336,8 +362,11 @@ class Alhambra(Game):
|
||||||
#
|
#
|
||||||
|
|
||||||
def _shuffleHook(self, cards):
|
def _shuffleHook(self, cards):
|
||||||
# move one Aces and Kings of first deck to top of the Talon (i.e. first card to be dealt)
|
# move one Aces and Kings of first deck to top of the Talon (i.e. first
|
||||||
return self._shuffleHookMoveToTop(cards, lambda c: (c.deck == 0 and c.rank in (ACE, KING), (c.rank, c.suit)), 8)
|
# card to be dealt)
|
||||||
|
return self._shuffleHookMoveToTop(
|
||||||
|
cards, lambda c: (c.deck == 0 and
|
||||||
|
c.rank in (ACE, KING), (c.rank, c.suit)), 8)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -357,9 +386,11 @@ class Granada(Alhambra):
|
||||||
|
|
||||||
class Reserves_RowStack(UD_RK_RowStack):
|
class Reserves_RowStack(UD_RK_RowStack):
|
||||||
getBottomImage = Stack._getReserveBottomImage
|
getBottomImage = Stack._getReserveBottomImage
|
||||||
|
|
||||||
def getHelp(self):
|
def getHelp(self):
|
||||||
return _('Waste. Build up or down regardless of suit.')
|
return _('Waste. Build up or down regardless of suit.')
|
||||||
|
|
||||||
|
|
||||||
class Reserves(Alhambra):
|
class Reserves(Alhambra):
|
||||||
RowStack_Class = StackWrapper(Reserves_RowStack, base_rank=NO_RANK)
|
RowStack_Class = StackWrapper(Reserves_RowStack, base_rank=NO_RANK)
|
||||||
|
|
||||||
|
@ -417,7 +448,7 @@ class Carpet(Game):
|
||||||
x, y = l.XM + (j+3)*l.XS, l.YM + i*l.YS
|
x, y = l.XM + (j+3)*l.XS, l.YM + i*l.YS
|
||||||
s.rows.append(ReserveStack(x, y, self))
|
s.rows.append(ReserveStack(x, y, self))
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
dx, dy = ((2,1), (8,1), (2,2), (8,2))[i]
|
dx, dy = ((2, 1), (8, 1), (2, 2), (8, 2))[i]
|
||||||
x, y = l.XM + dx*l.XS, l.YM + dy*l.YS
|
x, y = l.XM + dx*l.XS, l.YM + dy*l.YS
|
||||||
s.foundations.append(self.Foundation_Class(x, y, self, i))
|
s.foundations.append(self.Foundation_Class(x, y, self, i))
|
||||||
x, y = l.XM, l.YM
|
x, y = l.XM, l.YM
|
||||||
|
@ -436,7 +467,8 @@ class Carpet(Game):
|
||||||
|
|
||||||
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, lambda c: (c.rank == 0, c.suit))
|
return self._shuffleHookMoveToTop(
|
||||||
|
cards, lambda c: (c.rank == 0, c.suit))
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
self.startDealSample()
|
self.startDealSample()
|
||||||
|
@ -451,27 +483,36 @@ class Carpet(Game):
|
||||||
|
|
||||||
class BritishConstitution_RowStackMethods:
|
class BritishConstitution_RowStackMethods:
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if self in self.game.s.rows[:8] and from_stack in self.game.s.rows[8:16]:
|
if self in self.game.s.rows[:8] and \
|
||||||
|
from_stack in self.game.s.rows[8:16]:
|
||||||
return True
|
return True
|
||||||
if self in self.game.s.rows[8:16] and from_stack in self.game.s.rows[16:24]:
|
if self in self.game.s.rows[8:16] and \
|
||||||
|
from_stack in self.game.s.rows[16:24]:
|
||||||
return True
|
return True
|
||||||
if self in self.game.s.rows[16:24] and from_stack in self.game.s.rows[24:]:
|
if self in self.game.s.rows[16:24] and \
|
||||||
|
from_stack in self.game.s.rows[24:]:
|
||||||
return True
|
return True
|
||||||
if self in self.game.s.rows[24:] and from_stack is self.game.s.waste:
|
if self in self.game.s.rows[24:] and from_stack is self.game.s.waste:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class BritishConstitution_RowStack(BritishConstitution_RowStackMethods, AC_RowStack):
|
|
||||||
|
class BritishConstitution_RowStack(BritishConstitution_RowStackMethods,
|
||||||
|
AC_RowStack):
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if not AC_RowStack.acceptsCards(self, from_stack, cards):
|
if not AC_RowStack.acceptsCards(self, from_stack, cards):
|
||||||
return False
|
return False
|
||||||
return BritishConstitution_RowStackMethods.acceptsCards(self, from_stack, cards)
|
return BritishConstitution_RowStackMethods.acceptsCards(
|
||||||
|
self, from_stack, cards)
|
||||||
|
|
||||||
class NewBritishConstitution_RowStack(BritishConstitution_RowStackMethods, RK_RowStack):
|
|
||||||
|
class NewBritishConstitution_RowStack(BritishConstitution_RowStackMethods,
|
||||||
|
RK_RowStack):
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if not RK_RowStack.acceptsCards(self, from_stack, cards):
|
if not RK_RowStack.acceptsCards(self, from_stack, cards):
|
||||||
return False
|
return False
|
||||||
return BritishConstitution_RowStackMethods.acceptsCards(self, from_stack, cards)
|
return BritishConstitution_RowStackMethods.acceptsCards(
|
||||||
|
self, from_stack, cards)
|
||||||
|
|
||||||
|
|
||||||
class BritishConstitution_Foundation(SS_FoundationStack):
|
class BritishConstitution_Foundation(SS_FoundationStack):
|
||||||
|
@ -528,7 +569,8 @@ class BritishConstitution(Game):
|
||||||
|
|
||||||
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, lambda c: (c.rank == ACE, c.suit))
|
return self._shuffleHookMoveToTop(
|
||||||
|
cards, lambda c: (c.rank == ACE, c.suit))
|
||||||
|
|
||||||
def fillStack(self, stack):
|
def fillStack(self, stack):
|
||||||
if not stack.cards:
|
if not stack.cards:
|
||||||
|
@ -545,7 +587,8 @@ class BritishConstitution(Game):
|
||||||
|
|
||||||
|
|
||||||
class NewBritishConstitution(BritishConstitution):
|
class NewBritishConstitution(BritishConstitution):
|
||||||
RowStack_Class = StackWrapper(NewBritishConstitution_RowStack, base_rank=JACK)
|
RowStack_Class = StackWrapper(
|
||||||
|
NewBritishConstitution_RowStack, base_rank=JACK)
|
||||||
|
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_RK
|
shallHighlightMatch = Game._shallHighlightMatch_RK
|
||||||
|
|
||||||
|
@ -559,9 +602,11 @@ class Twenty_RowStack(BasicRowStack):
|
||||||
if not BasicRowStack.acceptsCards(self, from_stack, cards):
|
if not BasicRowStack.acceptsCards(self, from_stack, cards):
|
||||||
return False
|
return False
|
||||||
return len(self.cards) == 0
|
return len(self.cards) == 0
|
||||||
|
|
||||||
def getHelp(self):
|
def getHelp(self):
|
||||||
return _('Tableau. Empty piles can be filled with any card.')
|
return _('Tableau. Empty piles can be filled with any card.')
|
||||||
|
|
||||||
|
|
||||||
class Twenty(Game):
|
class Twenty(Game):
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
# create layout
|
# create layout
|
||||||
|
@ -593,18 +638,17 @@ class Twenty(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 in (ACE, KING) and c.deck == 1, (c.rank, c.suit)))
|
cards,
|
||||||
|
lambda c: (c.rank in (ACE, KING) and c.deck == 1,
|
||||||
|
(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()
|
||||||
self.s.talon.dealRow()
|
self.s.talon.dealRow()
|
||||||
|
|
||||||
|
|
||||||
def fillStack(self, stack):
|
def fillStack(self, stack):
|
||||||
if not stack.cards and stack in self.s.rows and self.s.talon.cards:
|
if not stack.cards and stack in self.s.rows and self.s.talon.cards:
|
||||||
old_state = self.enterState(self.S_FILL)
|
old_state = self.enterState(self.S_FILL)
|
||||||
|
@ -652,7 +696,7 @@ class ThreePirates(Game):
|
||||||
s.talon = ThreePirates_Talon(x, y, self)
|
s.talon = ThreePirates_Talon(x, y, self)
|
||||||
l.createText(s.talon, 'n')
|
l.createText(s.talon, 'n')
|
||||||
x += l.XS
|
x += l.XS
|
||||||
for i in (0,1,2):
|
for i in (0, 1, 2):
|
||||||
stack = WasteStack(x, y, self)
|
stack = WasteStack(x, y, self)
|
||||||
s.reserves.append(stack)
|
s.reserves.append(stack)
|
||||||
l.createText(stack, 'n')
|
l.createText(stack, 'n')
|
||||||
|
@ -661,7 +705,7 @@ class ThreePirates(Game):
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
for i in (0,1,2):
|
for i in (0, 1, 2):
|
||||||
self.s.talon.dealRow(frames=0)
|
self.s.talon.dealRow(frames=0)
|
||||||
self.startDealSample()
|
self.startDealSample()
|
||||||
self.s.talon.dealRow()
|
self.s.talon.dealRow()
|
||||||
|
@ -708,17 +752,17 @@ class Frames_RowStack(UD_SS_RowStack):
|
||||||
isSameSuitSequence(cs, dir=-1)):
|
isSameSuitSequence(cs, dir=-1)):
|
||||||
return False
|
return False
|
||||||
if from_stack in self.game.s.reserves:
|
if from_stack in self.game.s.reserves:
|
||||||
if (hasattr(self.cap, 'column') and
|
if hasattr(self.cap, 'column') and \
|
||||||
self.cap.column != from_stack.cap.column):
|
self.cap.column != from_stack.cap.column:
|
||||||
return False
|
return False
|
||||||
if (hasattr(self.cap, 'row') and
|
if hasattr(self.cap, 'row') and \
|
||||||
self.cap.row != from_stack.cap.row):
|
self.cap.row != from_stack.cap.row:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Frames(Game):
|
class Frames(Game):
|
||||||
Hint_Class = Frames_Hint #CautiousDefaultHint
|
Hint_Class = Frames_Hint # CautiousDefaultHint
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
l, s = Layout(self), self.s
|
l, s = Layout(self), self.s
|
||||||
|
@ -728,29 +772,29 @@ class Frames(Game):
|
||||||
x0, y0 = l.XM+2*l.XS, l.YM
|
x0, y0 = l.XM+2*l.XS, l.YM
|
||||||
# foundations (corners)
|
# foundations (corners)
|
||||||
suit = 0
|
suit = 0
|
||||||
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 = x0+i*l.XS, y0+j*l.YS
|
x, y = x0+i*l.XS, y0+j*l.YS
|
||||||
s.foundations.append(Frames_Foundation(x, y, self,
|
s.foundations.append(Frames_Foundation(x, y, self,
|
||||||
suit=suit, dir=0, max_cards=26))
|
suit=suit, dir=0, max_cards=26))
|
||||||
suit += 1
|
suit += 1
|
||||||
# rows (frame)
|
# rows (frame)
|
||||||
for i in (1,2,3,4):
|
for i in (1, 2, 3, 4):
|
||||||
for j in (0,4):
|
for j in (0, 4):
|
||||||
x, y = x0+i*l.XS, y0+j*l.YS
|
x, y = x0+i*l.XS, y0+j*l.YS
|
||||||
stack = Frames_RowStack(x, y, self)
|
stack = Frames_RowStack(x, y, self)
|
||||||
s.rows.append(stack)
|
s.rows.append(stack)
|
||||||
stack.cap.addattr(column=i)
|
stack.cap.addattr(column=i)
|
||||||
stack.CARD_YOFFSET = 0
|
stack.CARD_YOFFSET = 0
|
||||||
for i in (0,5):
|
for i in (0, 5):
|
||||||
for j in (1,2,3):
|
for j in (1, 2, 3):
|
||||||
x, y = x0+i*l.XS, y0+j*l.YS
|
x, y = x0+i*l.XS, y0+j*l.YS
|
||||||
stack = Frames_RowStack(x, y, self)
|
stack = Frames_RowStack(x, y, self)
|
||||||
s.rows.append(stack)
|
s.rows.append(stack)
|
||||||
stack.cap.addattr(row=j)
|
stack.cap.addattr(row=j)
|
||||||
stack.CARD_YOFFSET = 0
|
stack.CARD_YOFFSET = 0
|
||||||
# reserves (picture)
|
# reserves (picture)
|
||||||
for j in (1,2,3):
|
for j in (1, 2, 3):
|
||||||
for i in (1,2,3,4):
|
for i in (1, 2, 3, 4):
|
||||||
x, y = x0+i*l.XS, y0+j*l.YS
|
x, y = x0+i*l.XS, y0+j*l.YS
|
||||||
stack = OpenStack(x, y, self)
|
stack = OpenStack(x, y, self)
|
||||||
s.reserves.append(stack)
|
s.reserves.append(stack)
|
||||||
|
@ -797,35 +841,35 @@ class RoyalRendezvous(Game):
|
||||||
y = l.YM
|
y = l.YM
|
||||||
# kings
|
# kings
|
||||||
suit = 0
|
suit = 0
|
||||||
for i in (0,1,6,7):
|
for i in (0, 1, 6, 7):
|
||||||
x = l.XM+(1.5+i)*l.XS
|
x = l.XM+(1.5+i)*l.XS
|
||||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
||||||
base_rank=KING, max_cards=1))
|
base_rank=KING, max_cards=1))
|
||||||
suit += 1
|
suit += 1
|
||||||
# aces
|
# aces
|
||||||
suit = 0
|
suit = 0
|
||||||
for i in (2,3,4,5):
|
for i in (2, 3, 4, 5):
|
||||||
x = l.XM+(1.5+i)*l.XS
|
x = l.XM+(1.5+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
|
||||||
y += l.YS
|
y += l.YS
|
||||||
# twos
|
# twos
|
||||||
suit = 0
|
suit = 0
|
||||||
for i in (0,1,6,7):
|
for i in (0, 1, 6, 7):
|
||||||
x = l.XM+(1.5+i)*l.XS
|
x = l.XM+(1.5+i)*l.XS
|
||||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
||||||
base_rank=1, dir=2, max_cards=6))
|
base_rank=1, dir=2, max_cards=6))
|
||||||
suit += 1
|
suit += 1
|
||||||
# aces
|
# aces
|
||||||
suit = 0
|
suit = 0
|
||||||
for i in (2,3,4,5):
|
for i in (2, 3, 4, 5):
|
||||||
x = l.XM+(1.5+i)*l.XS
|
x = l.XM+(1.5+i)*l.XS
|
||||||
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit,
|
||||||
dir=2, max_cards=6))
|
dir=2, max_cards=6))
|
||||||
suit += 1
|
suit += 1
|
||||||
|
|
||||||
y += 1.5*l.YS
|
y += 1.5*l.YS
|
||||||
for i in (0,1):
|
for i in (0, 1):
|
||||||
x = l.XM+1.5*l.XS
|
x = l.XM+1.5*l.XS
|
||||||
for j in range(8):
|
for j in range(8):
|
||||||
s.rows.append(OpenStack(x, y, self, max_accept=0))
|
s.rows.append(OpenStack(x, y, self, max_accept=0))
|
||||||
|
@ -841,17 +885,17 @@ class RoyalRendezvous(Game):
|
||||||
|
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
|
||||||
def _shuffleHook(self, cards):
|
def _shuffleHook(self, cards):
|
||||||
# move twos to top
|
# move twos to top
|
||||||
cards = self._shuffleHookMoveToTop(cards,
|
cards = self._shuffleHookMoveToTop(
|
||||||
lambda c: (c.rank == 1 and c.deck == 0, c.suit))
|
cards,
|
||||||
|
lambda c: (c.rank == 1 and c.deck == 0, c.suit))
|
||||||
# move aces to top
|
# move aces to top
|
||||||
cards = self._shuffleHookMoveToTop(cards,
|
cards = self._shuffleHookMoveToTop(
|
||||||
lambda c: (c.rank == ACE, (c.deck, c.suit)))
|
cards,
|
||||||
|
lambda c: (c.rank == ACE, (c.deck, c.suit)))
|
||||||
return cards
|
return cards
|
||||||
|
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
# deal aces
|
# deal aces
|
||||||
self.s.talon.dealRow(rows=self.s.foundations[4:8], frames=0)
|
self.s.talon.dealRow(rows=self.s.foundations[4:8], frames=0)
|
||||||
|
@ -863,7 +907,6 @@ class RoyalRendezvous(Game):
|
||||||
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 not stack.cards and stack in self.s.rows:
|
if not stack.cards and stack in self.s.rows:
|
||||||
if not self.s.waste.cards:
|
if not self.s.waste.cards:
|
||||||
|
@ -924,8 +967,10 @@ class ShadyLanes(Game):
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
suit = i/2
|
suit = i/2
|
||||||
color = suit/2
|
color = suit/2
|
||||||
s.foundations.append(ShadyLanes_Foundation(x, y, self,
|
s.foundations.append(
|
||||||
base_suit=suit, suit=ANY_SUIT, color=color))
|
ShadyLanes_Foundation(
|
||||||
|
x, y, self,
|
||||||
|
base_suit=suit, suit=ANY_SUIT, color=color))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
x, y = l.XM, l.YM+l.YS
|
x, y = l.XM, l.YM+l.YS
|
||||||
s.talon = WasteTalonStack(x, y, self, max_rounds=1)
|
s.talon = WasteTalonStack(x, y, self, max_rounds=1)
|
||||||
|
@ -945,7 +990,6 @@ class ShadyLanes(Game):
|
||||||
|
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
|
||||||
def fillStack(self, stack):
|
def fillStack(self, stack):
|
||||||
if not stack.cards and stack in self.s.reserves:
|
if not stack.cards and stack in self.s.reserves:
|
||||||
if not self.s.waste.cards:
|
if not self.s.waste.cards:
|
||||||
|
@ -1026,8 +1070,9 @@ class FourWinds(Game):
|
||||||
|
|
||||||
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.deck, c.suit)))
|
cards,
|
||||||
|
lambda c: (c.rank == ACE, (c.deck, c.suit)))
|
||||||
|
|
||||||
|
|
||||||
class BoxingTheCompass(FourWinds):
|
class BoxingTheCompass(FourWinds):
|
||||||
|
@ -1064,13 +1109,13 @@ class Colonel_RowStack(SS_RowStack):
|
||||||
|
|
||||||
self_index, self_row = self._getStackIndex(self)
|
self_index, self_row = self._getStackIndex(self)
|
||||||
|
|
||||||
if self_row in (1,2):
|
if self_row in (1, 2):
|
||||||
above_stack = self.game.s.rows[self_index-12]
|
above_stack = self.game.s.rows[self_index-12]
|
||||||
if not above_stack.cards:
|
if not above_stack.cards:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
below_stack = None
|
below_stack = None
|
||||||
if self_row in (0,1):
|
if self_row in (0, 1):
|
||||||
below_stack = self.game.s.rows[self_index+12]
|
below_stack = self.game.s.rows[self_index+12]
|
||||||
|
|
||||||
# from_stack is waste
|
# from_stack is waste
|
||||||
|
@ -1088,7 +1133,7 @@ class Colonel_RowStack(SS_RowStack):
|
||||||
|
|
||||||
def canMoveCards(self, cards):
|
def canMoveCards(self, cards):
|
||||||
self_index, self_row = self._getStackIndex(self)
|
self_index, self_row = self._getStackIndex(self)
|
||||||
if self_row in (0,1):
|
if self_row in (0, 1):
|
||||||
below_stack = self.game.s.rows[self_index+12]
|
below_stack = self.game.s.rows[self_index+12]
|
||||||
if below_stack.cards:
|
if below_stack.cards:
|
||||||
return False
|
return False
|
||||||
|
@ -1129,7 +1174,6 @@ class Colonel(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)
|
||||||
|
@ -1143,7 +1187,6 @@ class Colonel(Game):
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TheRedAndTheBlack_Foundation(AC_FoundationStack):
|
class TheRedAndTheBlack_Foundation(AC_FoundationStack):
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
|
if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
|
||||||
|
@ -1152,6 +1195,7 @@ class TheRedAndTheBlack_Foundation(AC_FoundationStack):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class TheRedAndTheBlack_Reserve(ReserveStack):
|
class TheRedAndTheBlack_Reserve(ReserveStack):
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if not ReserveStack.acceptsCards(self, from_stack, cards):
|
if not ReserveStack.acceptsCards(self, from_stack, cards):
|
||||||
|
@ -1204,7 +1248,8 @@ class TheRedAndTheBlack(Game):
|
||||||
|
|
||||||
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, lambda c: (c.rank == ACE, c.suit))
|
return self._shuffleHookMoveToTop(
|
||||||
|
cards, lambda c: (c.rank == ACE, c.suit))
|
||||||
|
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||||
|
|
||||||
|
@ -1218,7 +1263,7 @@ class TwilightZone_Foundation(AC_FoundationStack):
|
||||||
if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
|
if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
|
||||||
return False
|
return False
|
||||||
if from_stack is self.game.s.waste or \
|
if from_stack is self.game.s.waste or \
|
||||||
from_stack in self.game.s.reserves:
|
from_stack in self.game.s.reserves:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1284,7 +1329,6 @@ class TwilightZone(Game):
|
||||||
s.reserves.append(OpenStack(x, y, self))
|
s.reserves.append(OpenStack(x, y, self))
|
||||||
x += l.XS
|
x += l.XS
|
||||||
|
|
||||||
|
|
||||||
x, y = l.XM, l.YM+l.YS/2
|
x, y = l.XM, l.YM+l.YS/2
|
||||||
s.talon = TwilightZone_Talon(x, y, self, max_move=1, max_rounds=2)
|
s.talon = TwilightZone_Talon(x, y, self, max_move=1, max_rounds=2)
|
||||||
l.createText(s.talon, 's')
|
l.createText(s.talon, 's')
|
||||||
|
@ -1293,13 +1337,11 @@ class TwilightZone(Game):
|
||||||
s.waste = TwilightZone_Waste(x, y, self, max_accept=1)
|
s.waste = TwilightZone_Waste(x, y, self, max_accept=1)
|
||||||
l.createText(s.waste, 's')
|
l.createText(s.waste, 's')
|
||||||
|
|
||||||
|
|
||||||
# define stack-groups
|
# define stack-groups
|
||||||
l.defaultStackGroups()
|
l.defaultStackGroups()
|
||||||
self.sg.dropstacks.append(s.talon)
|
self.sg.dropstacks.append(s.talon)
|
||||||
self.sg.openstacks.append(s.waste)
|
self.sg.openstacks.append(s.waste)
|
||||||
|
|
||||||
|
|
||||||
def startGame(self):
|
def startGame(self):
|
||||||
self.startDealSample()
|
self.startDealSample()
|
||||||
self.s.talon.dealRow()
|
self.s.talon.dealRow()
|
||||||
|
@ -1328,7 +1370,6 @@ class TwilightZone(Game):
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(54, RoyalCotillion, "Royal Cotillion",
|
registerGame(GameInfo(54, RoyalCotillion, "Royal Cotillion",
|
||||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_LUCK))
|
GI.GT_2DECK_TYPE, 2, 0, GI.SL_LUCK))
|
||||||
|
@ -1342,11 +1383,11 @@ registerGame(GameInfo(97, Carpet, "Carpet",
|
||||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))
|
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))
|
||||||
registerGame(GameInfo(391, BritishConstitution, "British Constitution",
|
registerGame(GameInfo(391, BritishConstitution, "British Constitution",
|
||||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED,
|
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED,
|
||||||
ranks=range(11), # without Queens and Kings
|
ranks=range(11), # without Queens and Kings
|
||||||
altnames=("Constitution",) ))
|
altnames=("Constitution",)))
|
||||||
registerGame(GameInfo(392, NewBritishConstitution, "New British Constitution",
|
registerGame(GameInfo(392, NewBritishConstitution, "New British Constitution",
|
||||||
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_BALANCED,
|
GI.GT_2DECK_TYPE | GI.GT_ORIGINAL, 2, 0, GI.SL_BALANCED,
|
||||||
ranks=range(11) # without Queens and Kings
|
ranks=range(11) # without Queens and Kings
|
||||||
))
|
))
|
||||||
registerGame(GameInfo(443, Twenty, "Twenty",
|
registerGame(GameInfo(443, Twenty, "Twenty",
|
||||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
||||||
|
@ -1374,4 +1415,3 @@ registerGame(GameInfo(748, TwilightZone, "Twilight Zone",
|
||||||
GI.GT_2DECK_TYPE, 2, 1, GI.SL_BALANCED))
|
GI.GT_2DECK_TYPE, 2, 1, GI.SL_BALANCED))
|
||||||
registerGame(GameInfo(752, Reserves, "Reserves",
|
registerGame(GameInfo(752, Reserves, "Reserves",
|
||||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
|
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED))
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,24 @@
|
||||||
__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.stack import \
|
||||||
|
RK_RowStack, \
|
||||||
|
WasteStack, \
|
||||||
|
WasteTalonStack, \
|
||||||
|
SS_FoundationStack
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Royal East
|
# * Royal East
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class RoyalEast(Game):
|
class RoyalEast(Game):
|
||||||
Hint_Class = CautiousDefaultHint
|
Hint_Class = CautiousDefaultHint
|
||||||
|
|
||||||
|
@ -114,4 +118,3 @@ class RoyalEast(Game):
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(93, RoyalEast, "Royal East",
|
registerGame(GameInfo(93, RoyalEast, "Royal East",
|
||||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED))
|
GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED))
|
||||||
|
|
||||||
|
|
|
@ -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-py-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-ry-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." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue