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

flake8 - games/special

This commit is contained in:
Shlomi Fish 2017-04-18 15:12:41 +03:00
parent 2505afdb68
commit 0d63e5d559
6 changed files with 157 additions and 102 deletions

View file

@ -24,20 +24,23 @@
__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 \
InitialDealTalonStack, \
isRankSequence, \
BasicRowStack
# ************************************************************************ # ************************************************************************
# * Tower of Hanoy # * Tower of Hanoy
# ************************************************************************ # ************************************************************************
class TowerOfHanoy_Hint(CautiousDefaultHint): class TowerOfHanoy_Hint(CautiousDefaultHint):
# FIXME: demo is completely clueless # FIXME: demo is completely clueless
pass pass
@ -75,7 +78,8 @@ class TowerOfHanoy(Game):
# create stacks # create stacks
for i in range(3): for i in range(3):
x, y, = l.XM + (i+1)*l.XS, l.YM x, y, = l.XM + (i+1)*l.XS, l.YM
s.rows.append(self.RowStack_Class(x, y, self, max_accept=1, max_move=1)) s.rows.append(
self.RowStack_Class(x, y, self, max_accept=1, max_move=1))
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
@ -149,6 +153,7 @@ class HanoiSequence(TowerOfHanoy):
return 1 return 1
return 0 return 0
# register the game # register the game
registerGame(GameInfo(124, TowerOfHanoy, "Tower of Hanoy", registerGame(GameInfo(124, TowerOfHanoy, "Tower of Hanoy",
GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL, GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL,
@ -168,4 +173,3 @@ registerGame(GameInfo(209, HanoiPuzzle6, "Hanoi Puzzle 6",
registerGame(GameInfo(769, HanoiSequence, "Hanoi Sequence", registerGame(GameInfo(769, HanoiSequence, "Hanoi Sequence",
GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL, GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL,
suits=(2,), ranks=range(9))) suits=(2,), ranks=range(9)))

View file

@ -24,23 +24,26 @@
__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.pysoltk import MfxCanvasText from pysollib.pysoltk import MfxCanvasText
# from pysollib.util import ANY_SUIT
from pysollib.stack import \
InitialDealTalonStack, \
InvisibleStack, \
OpenStack
# ************************************************************************ # ************************************************************************
# * # *
# ************************************************************************ # ************************************************************************
class Memory_RowStack(OpenStack): class Memory_RowStack(OpenStack):
def clickHandler(self, event): def clickHandler(self, event):
game = self.game game = self.game
@ -51,7 +54,8 @@ class Memory_RowStack(OpenStack):
self.flipMove() self.flipMove()
game.other_stack = self game.other_stack = self
else: else:
assert len(game.other_stack.cards) == 1 and game.other_stack.cards[-1].face_up assert len(game.other_stack.cards) == 1 and \
game.other_stack.cards[-1].face_up
c1, c2 = self.cards[-1], game.other_stack.cards[0] c1, c2 = self.cards[-1], game.other_stack.cards[0]
self.flipMove() self.flipMove()
if self.game.cardsMatch(c1, c2): if self.game.cardsMatch(c1, c2):
@ -83,6 +87,7 @@ class Memory_RowStack(OpenStack):
def controlclickHandler(self, event): def controlclickHandler(self, event):
return 0 return 0
def shiftclickHandler(self, event): def shiftclickHandler(self, event):
return 0 return 0
@ -115,7 +120,8 @@ class Memory24(Game):
# create text # create text
x, y = l.XM, self.ROWS*l.YS x, y = l.XM, self.ROWS*l.YS
if self.preview <= 1: if self.preview <= 1:
self.texts.score = MfxCanvasText(self.canvas, x, y, anchor="sw", self.texts.score = MfxCanvasText(
self.canvas, x, y, anchor="sw",
font=self.app.getFont("canvas_large")) font=self.app.getFont("canvas_large"))
x = self.texts.score.bbox()[1][0] + 16 x = self.texts.score.bbox()[1][0] + 16
@ -288,7 +294,8 @@ class Concentration(Memory24):
# create text # create text
x, y = l.XM, self.height - l.YM x, y = l.XM, self.height - l.YM
if self.preview <= 1: if self.preview <= 1:
self.texts.score = MfxCanvasText(self.canvas, x, y, self.texts.score = MfxCanvasText(
self.canvas, x, y,
anchor="sw", anchor="sw",
font=self.app.getFont("canvas_large")) font=self.app.getFont("canvas_large"))
@ -315,4 +322,3 @@ registerGame(GameInfo(177, Memory40, "Memory 40",
suits=(0, 2), ranks=(0, 4, 5, 6, 7, 8, 9, 10, 11, 12))) suits=(0, 2), ranks=(0, 4, 5, 6, 7, 8, 9, 10, 11, 12)))
registerGame(GameInfo(178, Concentration, "Concentration", registerGame(GameInfo(178, Concentration, "Concentration",
GI.GT_MEMORY | GI.GT_SCORE, 1, 0, GI.SL_SKILL)) GI.GT_MEMORY | GI.GT_SCORE, 1, 0, GI.SL_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,31 @@
# 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 AbstractHint
from pysollib.util import ANY_SUIT
from pysollib.stack import \
AbstractFoundationStack, \
InitialDealTalonStack, \
InvisibleStack, \
ReserveStack
# ************************************************************************ # ************************************************************************
# * # *
# ************************************************************************ # ************************************************************************
class Pegged_Hint(AbstractHint): class Pegged_Hint(AbstractHint):
# FIXME: no intelligence whatsoever is implemented here # FIXME: no intelligence whatsoever is implemented here
def computeHints(self): def computeHints(self):
@ -80,7 +86,8 @@ class Pegged_RowStack(ReserveStack):
other_stack.fillStack() other_stack.fillStack()
def _getMiddleStack(self, from_stack): def _getMiddleStack(self, from_stack):
dx, dy = from_stack.pos[0] - self.pos[0], from_stack.pos[1] - self.pos[1] dx, dy = from_stack.pos[0] - self.pos[0], \
from_stack.pos[1] - self.pos[1]
if not self.game.STEP_MAP.get((dx, dy)): if not self.game.STEP_MAP.get((dx, dy)):
return None return None
s = self.game.map.get((self.pos[0] + dx/2, self.pos[1] + dy/2)) s = self.game.map.get((self.pos[0] + dx/2, self.pos[1] + dy/2))
@ -129,11 +136,14 @@ class Pegged(Game):
x, y = l.XM + d*l.XS/2, l.YM + i*l.YS x, y = l.XM + d*l.XS/2, l.YM + i*l.YS
stack = Pegged_RowStack(x, y, self) stack = Pegged_RowStack(x, y, self)
stack.pos = (d, 2*i) stack.pos = (d, 2*i)
##print stack.id, stack.pos # print stack.id, stack.pos
s.rows.append(stack) s.rows.append(stack)
self.map[stack.pos] = stack self.map[stack.pos] = stack
x, y = self.width - l.XS, l.YM x, y = self.width - l.XS, l.YM
s.foundations.append(AbstractFoundationStack(x, y, self, ANY_SUIT, max_move=0, max_accept=0, max_cards=self.gameinfo.ncards)) s.foundations.append(
AbstractFoundationStack(
x, y, self, ANY_SUIT, max_move=0, max_accept=0,
max_cards=self.gameinfo.ncards))
l.createText(s.foundations[0], "s") l.createText(s.foundations[0], "s")
y = self.height - l.YS y = self.height - l.YS
s.talon = InitialDealTalonStack(x, y, self) s.talon = InitialDealTalonStack(x, y, self)
@ -149,7 +159,6 @@ class Pegged(Game):
# Define stack groups # Define stack groups
l.defaultStackGroups() l.defaultStackGroups()
# #
# game overrides # game overrides
# #
@ -210,13 +219,16 @@ class Pegged(Game):
class PeggedCross1(Pegged): class PeggedCross1(Pegged):
ROWS = (3, 3, 7, 7, 7, 3, 3) ROWS = (3, 3, 7, 7, 7, 3, 3)
class PeggedCross2(Pegged): class PeggedCross2(Pegged):
ROWS = (3, 3, 3, 9, 9, 9, 3, 3, 3) ROWS = (3, 3, 3, 9, 9, 9, 3, 3, 3)
class Pegged6x6(Pegged): class Pegged6x6(Pegged):
EMPTY_STACK_ID = 14 EMPTY_STACK_ID = 14
ROWS = (6, 6, 6, 6, 6, 6) ROWS = (6, 6, 6, 6, 6, 6)
class Pegged7x7(Pegged): class Pegged7x7(Pegged):
ROWS = (7, 7, 7, 7, 7, 7, 7) ROWS = (7, 7, 7, 7, 7, 7, 7)
@ -230,11 +242,11 @@ class PeggedTriangle1(Pegged):
ROWS = (1, 2, 3, 4, 5) ROWS = (1, 2, 3, 4, 5)
EMPTY_STACK_ID = 4 EMPTY_STACK_ID = 4
class PeggedTriangle2(PeggedTriangle1): class PeggedTriangle2(PeggedTriangle1):
ROWS = (1, 2, 3, 4, 5, 6) ROWS = (1, 2, 3, 4, 5, 6)
# ************************************************************************ # ************************************************************************
# * register the games # * register the games
# ************************************************************************ # ************************************************************************
@ -253,6 +265,7 @@ def r(id, gameclass, name):
registerGame(gi) registerGame(gi)
return gi return gi
r(180, Pegged, "Pegged") r(180, Pegged, "Pegged")
r(181, PeggedCross1, "Pegged Cross 1") r(181, PeggedCross1, "Pegged Cross 1")
r(182, PeggedCross2, "Pegged Cross 2") r(182, PeggedCross2, "Pegged Cross 2")

View file

@ -24,23 +24,26 @@
__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.pysoltk import MfxCanvasText from pysollib.pysoltk import MfxCanvasText
from pysollib.stack import \
InitialDealTalonStack, \
InvisibleStack, \
OpenTalonStack, \
ReserveStack, \
StackWrapper
# ************************************************************************ # ************************************************************************
# * Poker Square # * Poker Square
# ************************************************************************ # ************************************************************************
class PokerSquare_RowStack(ReserveStack): class PokerSquare_RowStack(ReserveStack):
def clickHandler(self, event): def clickHandler(self, event):
if not self.cards: if not self.cards:
@ -95,7 +98,8 @@ One Pair'''))
text="100\n75\n50\n25\n20\n15\n10\n5\n2") text="100\n75\n50\n25\n20\n15\n10\n5\n2")
self.texts.list.append(t) self.texts.list.append(t)
x = t.bbox()[1][0] + 16 x = t.bbox()[1][0] + 16
self.texts.misc = MfxCanvasText(self.canvas, x, y, anchor="nw", self.texts.misc = MfxCanvasText(
self.canvas, x, y, anchor="nw",
font=self.app.getFont("canvas_default"), font=self.app.getFont("canvas_default"),
text="0\n"*8+"0") text="0\n"*8+"0")
x = self.texts.misc.bbox()[1][0] + 32 x = self.texts.misc.bbox()[1][0] + 32
@ -127,7 +131,8 @@ One Pair'''))
t = MfxCanvasText(self.canvas, tx, ty, anchor=ta, t = MfxCanvasText(self.canvas, tx, ty, anchor=ta,
font=self.app.getFont("canvas_default")) font=self.app.getFont("canvas_default"))
self.texts.list.append(t) self.texts.list.append(t)
self.texts.score = MfxCanvasText(self.canvas, l.XM, 5*l.YS, anchor="sw", self.texts.score = MfxCanvasText(
self.canvas, l.XM, 5*l.YS, anchor="sw",
font=self.app.getFont("canvas_large")) font=self.app.getFont("canvas_large"))
# define hands for scoring # define hands for scoring
@ -155,7 +160,8 @@ One Pair'''))
self.s.talon.fillStack() self.s.talon.fillStack()
def isGameWon(self): def isGameWon(self):
return len(self.s.talon.cards) == 0 and self.getGameScore() >= self.WIN_SCORE return len(self.s.talon.cards) == 0 and \
self.getGameScore() >= self.WIN_SCORE
def getAutoStacks(self, event=None): def getAutoStacks(self, event=None):
return ((), (), ()) return ((), (), ())
@ -260,12 +266,13 @@ class PokerShuffle_RowStack(ReserveStack):
class PokerShuffle(PokerSquare): class PokerShuffle(PokerSquare):
Talon_Class = InitialDealTalonStack Talon_Class = InitialDealTalonStack
RowStack_Class = StackWrapper(PokerShuffle_RowStack, max_accept=1, max_cards=2) RowStack_Class = StackWrapper(
PokerShuffle_RowStack, max_accept=1, max_cards=2)
WIN_SCORE = 200 WIN_SCORE = 200
def createGame(self): def createGame(self):
l = PokerSquare.createGame(self) PokerSquare.createGame(self)
if self.s.talon.texts.ncards: if self.s.talon.texts.ncards:
self.s.talon.texts.ncards.text_format = "%D" self.s.talon.texts.ncards.text_format = "%D"
@ -283,6 +290,6 @@ registerGame(GameInfo(139, PokerSquare, "Poker Square",
GI.GT_POKER_TYPE | GI.GT_SCORE, 1, 0, GI.SL_MOSTLY_SKILL, GI.GT_POKER_TYPE | GI.GT_SCORE, 1, 0, GI.SL_MOSTLY_SKILL,
si={"ncards": 25})) si={"ncards": 25}))
registerGame(GameInfo(140, PokerShuffle, "Poker Shuffle", registerGame(GameInfo(140, PokerShuffle, "Poker Shuffle",
GI.GT_POKER_TYPE | GI.GT_SCORE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL, GI.GT_POKER_TYPE | GI.GT_SCORE | GI.GT_OPEN, 1, 0,
GI.SL_MOSTLY_SKILL,
si={"ncards": 25})) si={"ncards": 25}))

View file

@ -24,28 +24,38 @@
__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.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.pysoltk import MfxCanvasText from pysollib.pysoltk import MfxCanvasText
from pysollib.games.braid import Braid_Foundation, Braid_BraidStack, \ from pysollib.games.braid import Braid_Foundation, Braid_BraidStack, \
Braid_RowStack, Braid_ReserveStack, Braid Braid_RowStack, Braid_ReserveStack, Braid
from pysollib.games.bakersdozen import Cruel_Talon from pysollib.games.bakersdozen import Cruel_Talon
from pysollib.util import ANY_RANK, NO_RANK, UNLIMITED_ACCEPTS, UNLIMITED_MOVES
from pysollib.stack import \
InitialDealTalonStack, \
OpenStack, \
RK_RowStack, \
ReserveStack, \
SS_FoundationStack, \
StackWrapper, \
WasteStack, \
WasteTalonStack, \
SS_RowStack
# ************************************************************************ # ************************************************************************
# * Tarock Talon Stacks # * Tarock Talon Stacks
# ************************************************************************ # ************************************************************************
class Wicked_Talon(Cruel_Talon): class Wicked_Talon(Cruel_Talon):
pass pass
@ -101,7 +111,8 @@ class Skiz_RowStack(RK_RowStack):
return cards[0].rank == len(self.game.gameinfo.trumps) - 1 return cards[0].rank == len(self.game.gameinfo.trumps) - 1
else: else:
return cards[0].rank == len(self.game.gameinfo.ranks) - 1 return cards[0].rank == len(self.game.gameinfo.ranks) - 1
return self.cards[-1].suit == cards[0].suit and self.cards[-1].rank - 1 == cards[0].rank return self.cards[-1].suit == cards[0].suit and \
self.cards[-1].rank - 1 == cards[0].rank
class Pagat_RowStack(RK_RowStack): class Pagat_RowStack(RK_RowStack):
@ -110,7 +121,8 @@ class Pagat_RowStack(RK_RowStack):
return 0 return 0
if not self.cards: if not self.cards:
return 1 return 1
return self.cards[-1].suit == cards[0].suit and self.cards[-1].rank - 1 == cards[0].rank return self.cards[-1].suit == cards[0].suit and \
self.cards[-1].rank - 1 == cards[0].rank
class TrumpWild_RowStack(Tarock_OpenStack): class TrumpWild_RowStack(Tarock_OpenStack):
@ -232,7 +244,6 @@ class WheelOfFortune(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
self.setSize(l.XM + l.XS * 11.5, l.YM + l.YS * 5.5) self.setSize(l.XM + l.XS * 11.5, l.YM + l.YS * 5.5)
@ -306,17 +317,16 @@ class ImperialTrumps(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
self.setSize(l.XM + l.XS * 8, l.YM + l.YS * 5) self.setSize(l.XM + l.XS * 8, l.YM + l.YS * 5)
# Create foundations # Create foundations
x = l.XM + l.XS * 3 x = l.XM + l.XS * 3
y = l.YM y = l.YM
for i in range(4): for i in range(4):
s.foundations.append(ImperialTrump_Foundation(x, y, self, i, max_cards=14)) s.foundations.append(
ImperialTrump_Foundation(x, y, self, i, max_cards=14))
x = x + l.XS x = x + l.XS
s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22)) s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22))
@ -367,7 +377,6 @@ class Pagat(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
h = max(3 * l.YS, 20 * l.YOFFSET) h = max(3 * l.YS, 20 * l.YOFFSET)
@ -439,7 +448,6 @@ class Skiz(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
h = max(3 * l.YS, 20 * l.YOFFSET) h = max(3 * l.YS, 20 * l.YOFFSET)
@ -512,7 +520,6 @@ class FifteenPlus(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
h = max(5 * l.YS, 20 * l.YOFFSET) h = max(5 * l.YS, 20 * l.YOFFSET)
@ -524,7 +531,8 @@ class FifteenPlus(AbstractTarockGame):
s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22)) s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22))
y = y + l.YS y = y + l.YS
for i in range(4): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, i, max_cards=14)) s.foundations.append(
SS_FoundationStack(x, y, self, i, max_cards=14))
y = y + l.YS y = y + l.YS
# Create rows # Create rows
@ -532,7 +540,8 @@ class FifteenPlus(AbstractTarockGame):
y = l.YM y = l.YM
for j in range(2): for j in range(2):
for i in range(8): for i in range(8):
s.rows.append(Tarock_AC_RowStack(x, y, self, max_move=1, max_accept=1)) s.rows.append(
Tarock_AC_RowStack(x, y, self, max_move=1, max_accept=1))
x = x + l.XS x = x + l.XS
x = l.XM x = l.XM
y = y + l.YS * 3 y = y + l.YS * 3
@ -577,7 +586,6 @@ class Excuse(AbstractTarockGame):
def createGame(self): def createGame(self):
l, s = Layout(self), self.s l, s = Layout(self), self.s
font = self.app.getFont("canvas_default")
# Set window size # Set window size
h = max(5 * l.YS, 20 * l.YOFFSET) h = max(5 * l.YS, 20 * l.YOFFSET)
@ -589,7 +597,8 @@ class Excuse(AbstractTarockGame):
s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22)) s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22))
y = y + l.YS y = y + l.YS
for i in range(4): for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, i, max_cards=14)) s.foundations.append(
SS_FoundationStack(x, y, self, i, max_cards=14))
y = y + l.YS y = y + l.YS
# Create rows # Create rows
@ -617,7 +626,8 @@ class Excuse(AbstractTarockGame):
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
# move Kings to bottom of each stack (see Baker's Dozen) # move Kings to bottom of each stack (see Baker's Dozen)
def isKing(c): def isKing(c):
return (c.suit < 4 and c.rank == 13) or (c.suit == 4 and c.rank == 21) return ((c.suit < 4 and c.rank == 13) or
(c.suit == 4 and c.rank == 21))
i, n = 0, len(self.s.rows) i, n = 0, len(self.s.rows)
kings = [] kings = []
for c in cards: for c in cards:
@ -671,7 +681,8 @@ class Grasshopper(AbstractTarockGame):
# Create talon # Create talon
x = l.XM x = l.XM
y = l.YM y = l.YM
s.talon = WasteTalonStack(x, y, self, num_deal=1, max_rounds=self.MAX_ROUNDS) s.talon = WasteTalonStack(
x, y, self, num_deal=1, max_rounds=self.MAX_ROUNDS)
l.createText(s.talon, "s") l.createText(s.talon, "s")
x = x + l.XS x = x + l.XS
s.waste = WasteStack(x, y, self) s.waste = WasteStack(x, y, self)
@ -681,10 +692,12 @@ class Grasshopper(AbstractTarockGame):
x = x + l.XM + l.XS x = x + l.XM + l.XS
for j in range(4): for j in range(4):
for i in range(decks): for i in range(decks):
s.foundations.append(SS_FoundationStack(x, y, self, j, max_cards=14)) s.foundations.append(
SS_FoundationStack(x, y, self, j, max_cards=14))
x = x + l.XS x = x + l.XS
for i in range(decks): for i in range(decks):
s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22)) s.foundations.append(
SS_FoundationStack(x, y, self, 4, max_cards=22))
x = x + l.XS x = x + l.XS
# Create reserve # Create reserve
@ -753,7 +766,8 @@ class Ponytail(Tarock_GameMethods, Braid):
l, s = Layout(self), self.s l, s = Layout(self), self.s
# set window # set window
# (piles up to 20 cards are playable - needed for Ponytail_PonytailStack) # (piles up to 20 cards are playable -
# needed for Ponytail_PonytailStack)
h = max(5*l.YS + l.TEXT_HEIGHT, l.YS+(self.BRAID_CARDS-1)*l.YOFFSET) h = max(5*l.YS + l.TEXT_HEIGHT, l.YS+(self.BRAID_CARDS-1)*l.YOFFSET)
self.setSize(10*l.XS+l.XM, l.YM + h) self.setSize(10*l.XS+l.XM, l.YM + h)
@ -785,7 +799,8 @@ class Ponytail(Tarock_GameMethods, Braid):
y = l.YM + 2*l.YS y = l.YM + 2*l.YS
s.talon = WasteTalonStack(x, y, self, max_rounds=3) s.talon = WasteTalonStack(x, y, self, max_rounds=3)
l.createText(s.talon, "s") l.createText(s.talon, "s")
s.talon.texts.rounds = MfxCanvasText(self.canvas, s.talon.texts.rounds = MfxCanvasText(
self.canvas,
x + l.CW / 2, y - l.YM, x + l.CW / 2, y - l.YM,
anchor="s", anchor="s",
font=self.app.getFont("canvas_default")) font=self.app.getFont("canvas_default"))
@ -795,13 +810,19 @@ class Ponytail(Tarock_GameMethods, Braid):
x = l.XM + 8 * l.XS x = l.XM + 8 * l.XS
y = l.YM y = l.YM
for i in range(4): for i in range(4):
s.foundations.append(Ponytail_Foundation(x, y, self, i, mod=14, max_cards=14)) s.foundations.append(
s.foundations.append(Ponytail_Foundation(x + l.XS, y, self, i, mod=14, max_cards=14)) Ponytail_Foundation(x, y, self, i, mod=14, max_cards=14))
s.foundations.append(
Ponytail_Foundation(
x + l.XS, y, self, i, mod=14, max_cards=14))
y = y + l.YS y = y + l.YS
s.foundations.append(Ponytail_Foundation(x, y, self, 4, mod=22, max_cards=22)) s.foundations.append(
s.foundations.append(Ponytail_Foundation(x + l.XS, y, self, 4, mod=22, max_cards=22)) Ponytail_Foundation(x, y, self, 4, mod=22, max_cards=22))
s.foundations.append(
Ponytail_Foundation(x + l.XS, y, self, 4, mod=22, max_cards=22))
# ??? # ???
self.texts.info = MfxCanvasText(self.canvas, self.texts.info = MfxCanvasText(
self.canvas,
x + l.CW + l.XM / 2, y + l.YS, x + l.CW + l.XM / 2, y + l.YS,
anchor="n", anchor="n",
font=self.app.getFont("canvas_default")) font=self.app.getFont("canvas_default"))
@ -852,7 +873,6 @@ class Cavalier(AbstractTarockGame):
# Define stack groups # Define stack groups
l.defaultAll() l.defaultAll()
# #
# Game over rides # Game over rides
# #
@ -878,7 +898,8 @@ class Cavalier(AbstractTarockGame):
class FiveAces(Cavalier): class FiveAces(Cavalier):
def _shuffleHook(self, cards): def _shuffleHook(self, cards):
return self._shuffleHookMoveToBottom(cards, lambda c: (c.rank == 0, c.suit)) return self._shuffleHookMoveToBottom(
cards, lambda c: (c.rank == 0, c.suit))
def startGame(self): def startGame(self):
Cavalier.startGame(self, foundations=1) Cavalier.startGame(self, foundations=1)
@ -886,7 +907,8 @@ class FiveAces(Cavalier):
class Wicked(FiveAces): class Wicked(FiveAces):
Talon_Class = StackWrapper(Wicked_Talon, max_rounds=-1) Talon_Class = StackWrapper(Wicked_Talon, max_rounds=-1)
RowStack_Class = StackWrapper(SS_RowStack, max_move=1, max_accept=1, base_rank=NO_RANK) RowStack_Class = StackWrapper(
SS_RowStack, max_move=1, max_accept=1, base_rank=NO_RANK)
Hint_Class = CautiousDefaultHint Hint_Class = CautiousDefaultHint
def startGame(self): def startGame(self):
@ -899,7 +921,8 @@ class Wicked(FiveAces):
class Nasty(Wicked): class Nasty(Wicked):
RowStack_Class = StackWrapper(Nasty_RowStack, max_move=1, max_accept=1, base_rank=ANY_RANK) RowStack_Class = StackWrapper(
Nasty_RowStack, max_move=1, max_accept=1, base_rank=ANY_RANK)
# ************************************************************************ # ************************************************************************
@ -913,6 +936,7 @@ def r(id, gameclass, name, game_type, decks, redeals, skill_level):
registerGame(gi) registerGame(gi)
return gi return gi
r(157, WheelOfFortune, "Wheel of Fortune", GI.GT_TAROCK, 1, 0, GI.SL_BALANCED) r(157, WheelOfFortune, "Wheel of Fortune", GI.GT_TAROCK, 1, 0, GI.SL_BALANCED)
r(158, ImperialTrumps, "Imperial Trumps", GI.GT_TAROCK, 1, -1, GI.SL_BALANCED) r(158, ImperialTrumps, "Imperial Trumps", GI.GT_TAROCK, 1, -1, GI.SL_BALANCED)
r(159, Pagat, "Pagat", GI.GT_TAROCK | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL) r(159, Pagat, "Pagat", GI.GT_TAROCK | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)
@ -920,7 +944,8 @@ r(160, Skiz, "Skiz", GI.GT_TAROCK | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)
r(161, FifteenPlus, "Fifteen plus", GI.GT_TAROCK, 1, 0, GI.SL_BALANCED) r(161, FifteenPlus, "Fifteen plus", GI.GT_TAROCK, 1, 0, GI.SL_BALANCED)
r(162, Excuse, "Excuse", GI.GT_TAROCK | GI.GT_OPEN, 1, 0, GI.SL_BALANCED) r(162, Excuse, "Excuse", GI.GT_TAROCK | GI.GT_OPEN, 1, 0, GI.SL_BALANCED)
r(163, Grasshopper, "Grasshopper", GI.GT_TAROCK, 1, 1, GI.SL_MOSTLY_SKILL) r(163, Grasshopper, "Grasshopper", GI.GT_TAROCK, 1, 1, GI.SL_MOSTLY_SKILL)
r(164, DoubleGrasshopper, "Double Grasshopper", GI.GT_TAROCK, 2, 1, GI.SL_MOSTLY_SKILL) r(164, DoubleGrasshopper, "Double Grasshopper", GI.GT_TAROCK, 2, 1,
GI.SL_MOSTLY_SKILL)
r(179, Ponytail, "Ponytail", GI.GT_TAROCK, 2, 2, GI.SL_MOSTLY_SKILL) r(179, Ponytail, "Ponytail", GI.GT_TAROCK, 2, 2, GI.SL_MOSTLY_SKILL)
r(202, Cavalier, "Cavalier", GI.GT_TAROCK, 1, 0, GI.SL_MOSTLY_SKILL) r(202, Cavalier, "Cavalier", GI.GT_TAROCK, 1, 0, GI.SL_MOSTLY_SKILL)
r(203, FiveAces, "Five Aces", GI.GT_TAROCK, 1, 0, GI.SL_MOSTLY_SKILL) r(203, FiveAces, "Five Aces", GI.GT_TAROCK, 1, 0, GI.SL_MOSTLY_SKILL)
@ -928,4 +953,3 @@ r(204, Wicked, "Wicked", GI.GT_TAROCK | GI.GT_OPEN, 1, -1, GI.SL_BALANCED)
r(205, Nasty, "Nasty", GI.GT_TAROCK | GI.GT_OPEN, 1, -1, GI.SL_BALANCED) r(205, Nasty, "Nasty", GI.GT_TAROCK | GI.GT_OPEN, 1, -1, GI.SL_BALANCED)
del r del r

View file

@ -17,6 +17,7 @@ my %skip =
./pysollib/games/mahjongg/mahjongg1.py ./pysollib/games/mahjongg/mahjongg1.py
./pysollib/games/mahjongg/mahjongg2.py ./pysollib/games/mahjongg/mahjongg2.py
./pysollib/games/mahjongg/mahjongg3.py ./pysollib/games/mahjongg/mahjongg3.py
./pysollib/games/special/__init__.py
./pysollib/games/ultra/__init__.py ./pysollib/games/ultra/__init__.py
./pysollib/pysoltk.py ./pysollib/pysoltk.py
./pysollib/tile/ttk.py ./pysollib/tile/ttk.py
@ -25,7 +26,7 @@ my %skip =
# my $cmd = shell_quote( 'flake8', '.' ); # my $cmd = shell_quote( 'flake8', '.' );
my $cmd = shell_quote( 'flake8', my $cmd = shell_quote( 'flake8',
grep { not exists $skip{$_} } glob('./pysollib/*.py ./pysollib/[cmpuw]*/*.py ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py ./pysollib/games/*.py ./pysollib/games/[mu]*/*.py') ); grep { not exists $skip{$_} } glob('./pysollib/*.py ./pysollib/[cmpuw]*/*.py ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py ./pysollib/games/*.py ./pysollib/games/*/*.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." );