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:
parent
a32fc12218
commit
e1bc790664
5 changed files with 100 additions and 62 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
# ---------------------------------------------------------------------------##
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||
|
@ -19,22 +19,31 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ---------------------------------------------------------------------------##
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
__all__ = []
|
||||
|
||||
# imports
|
||||
import sys
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mygettext import _, n_
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.gamedb import registerGame, GameInfo, GI
|
||||
from pysollib.util import *
|
||||
from pysollib.mfxutil import kwdefault
|
||||
from pysollib.stack import *
|
||||
from pysollib.game import Game
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||
|
||||
from pysollib.util import ANY_RANK, ANY_SUIT, JACK, KING, QUEEN
|
||||
|
||||
from pysollib.stack import \
|
||||
AC_RowStack, \
|
||||
AbstractFoundationStack, \
|
||||
BasicRowStack, \
|
||||
InitialDealTalonStack, \
|
||||
OpenStack, \
|
||||
Stack, \
|
||||
UD_RK_RowStack, \
|
||||
isAlternateColorSequence, \
|
||||
StackWrapper
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
# * Take Away
|
||||
|
@ -110,6 +119,7 @@ class TakeAway(Game):
|
|||
class FourStacks_RowStack(AC_RowStack):
|
||||
getBottomImage = Stack._getReserveBottomImage
|
||||
|
||||
|
||||
class FourStacks(Game):
|
||||
def createGame(self):
|
||||
# create layout
|
||||
|
@ -159,7 +169,7 @@ class Striptease_RowStack(UD_RK_RowStack):
|
|||
return True
|
||||
r1, r2 = self.cards[-1].rank, cards[0].rank
|
||||
if ((r1 == JACK and r2 == KING) or
|
||||
(r2 == JACK and r1 == KING)):
|
||||
(r2 == JACK and r1 == KING)):
|
||||
return True
|
||||
return ((r1+1) % 13 == r2 or (r2+1) % 13 == r1)
|
||||
|
||||
|
@ -224,7 +234,7 @@ class Striptease(TakeAway):
|
|||
if r1 == QUEEN or r2 == QUEEN:
|
||||
return False
|
||||
if ((r1 == JACK and r2 == KING) or
|
||||
(r2 == JACK and r1 == KING)):
|
||||
(r2 == JACK and r1 == KING)):
|
||||
return True
|
||||
return ((r1+1) % 13 == r2 or (r2+1) % 13 == r1)
|
||||
|
||||
|
@ -236,4 +246,3 @@ registerGame(GameInfo(335, FourStacks, "Four Stacks",
|
|||
GI.GT_1DECK_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(654, Striptease, "Striptease",
|
||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_SKILL))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
# ---------------------------------------------------------------------------##
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||
|
@ -19,27 +19,37 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# ---------------------------------------------------------------------------##
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
__all__ = []
|
||||
|
||||
# imports
|
||||
import sys
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mygettext import _, n_
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.gamedb import registerGame, GameInfo, GI
|
||||
from pysollib.util import *
|
||||
from pysollib.mfxutil import kwdefault
|
||||
from pysollib.stack import *
|
||||
from pysollib.game import Game
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||
from pysollib.hint import CautiousDefaultHint
|
||||
|
||||
from pysollib.util import KING, NO_RANK
|
||||
|
||||
from pysollib.stack import \
|
||||
AC_FoundationStack, \
|
||||
AC_RowStack, \
|
||||
OpenStack, \
|
||||
SS_FoundationStack, \
|
||||
Stack, \
|
||||
StackWrapper, \
|
||||
WasteStack, \
|
||||
WasteTalonStack
|
||||
|
||||
# ************************************************************************
|
||||
# *
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class Terrace_Talon(WasteTalonStack):
|
||||
def canDealCards(self):
|
||||
if self.game.getState() == 0:
|
||||
|
@ -102,12 +112,14 @@ class Terrace_RowStack(AC_RowStack):
|
|||
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
|
||||
state = self.game.getState()
|
||||
if state > 0:
|
||||
AC_RowStack.moveMove(self, ncards, to_stack, frames=frames, shadow=shadow)
|
||||
AC_RowStack.moveMove(
|
||||
self, ncards, to_stack, frames=frames, shadow=shadow)
|
||||
return
|
||||
assert to_stack in self.game.s.foundations
|
||||
assert ncards == 1
|
||||
assert not self.game.s.waste.cards
|
||||
self.game.moveMove(ncards, self, to_stack, frames=frames, shadow=shadow)
|
||||
self.game.moveMove(
|
||||
ncards, self, to_stack, frames=frames, shadow=shadow)
|
||||
for s in self.game.s.foundations:
|
||||
s.cap.base_rank = to_stack.cards[0].rank
|
||||
freerows = [s for s in self.game.s.rows if not s.cards]
|
||||
|
@ -151,7 +163,8 @@ class Terrace(Game):
|
|||
|
||||
# create stacks
|
||||
x, y = l.XM + w1, l.YM
|
||||
s.talon = self.Talon_Class(x, y, self, max_rounds=max_rounds, num_deal=num_deal)
|
||||
s.talon = self.Talon_Class(
|
||||
x, y, self, max_rounds=max_rounds, num_deal=num_deal)
|
||||
l.createText(s.talon, "sw")
|
||||
x = x + l.XS
|
||||
s.waste = WasteStack(x, y, self)
|
||||
|
@ -227,6 +240,7 @@ class Terrace(Game):
|
|||
|
||||
class QueenOfItaly(Terrace):
|
||||
Foundation_Class = StackWrapper(Terrace_AC_Foundation, max_move=1)
|
||||
|
||||
def fillStack(self, stack):
|
||||
pass
|
||||
|
||||
|
@ -277,8 +291,10 @@ class Wood_RowStack(AC_RowStack):
|
|||
return from_stack is self.game.s.waste
|
||||
return from_stack not in self.game.s.reserves
|
||||
|
||||
|
||||
class Wood(BlondesAndBrunettes):
|
||||
RowStack_Class = StackWrapper(Wood_RowStack, mod=13, max_move=1)
|
||||
|
||||
def fillStack(self, stack):
|
||||
pass
|
||||
|
||||
|
@ -298,8 +314,10 @@ class Signora(Terrace):
|
|||
|
||||
class Madame(Terrace):
|
||||
INITIAL_RESERVE_CARDS = 15
|
||||
|
||||
def createGame(self):
|
||||
Terrace.createGame(self, rows=10, playcards=20)
|
||||
|
||||
def startGame(self):
|
||||
Terrace.startGame(self, nrows=10)
|
||||
|
||||
|
@ -336,10 +354,13 @@ class MamySusan(Terrace):
|
|||
|
||||
def fillStack(self, stack):
|
||||
pass
|
||||
|
||||
def _restoreGameHook(self, game):
|
||||
pass
|
||||
|
||||
def _loadGameHook(self, p):
|
||||
pass
|
||||
|
||||
def _saveGameHook(self, p):
|
||||
pass
|
||||
|
||||
|
@ -372,7 +393,7 @@ class BastilleDay_BastilleStack(Stack):
|
|||
return 1
|
||||
|
||||
def getHelp(self):
|
||||
return '' # FIXME
|
||||
return '' # FIXME
|
||||
|
||||
|
||||
class BastilleDay(Game):
|
||||
|
@ -399,7 +420,7 @@ class BastilleDay(Game):
|
|||
|
||||
x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT
|
||||
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))
|
||||
x = x + l.XS
|
||||
x, y = l.XM, l.YM+2*l.YS+l.TEXT_HEIGHT
|
||||
for i in range(8):
|
||||
|
@ -408,17 +429,17 @@ class BastilleDay(Game):
|
|||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
# move Kings to top
|
||||
cards = self._shuffleHookMoveToTop(cards,
|
||||
lambda c: (c.rank == KING, None))
|
||||
cards = self._shuffleHookMoveToTop(
|
||||
cards,
|
||||
lambda c: (c.rank == KING, None))
|
||||
# move any 4 cards to top
|
||||
cards = cards[4:]+cards[:4]
|
||||
return cards
|
||||
|
||||
def startGame(self, nrows=4):
|
||||
for i in range(12): # deal to Bastille
|
||||
for i in range(12): # deal to Bastille
|
||||
self.s.talon.dealRow(flip=0, rows=[self.s.reserves[0]], frames=0)
|
||||
for i in range(9):
|
||||
self.s.talon.dealRow(rows=[self.s.reserves[-1]], frames=0)
|
||||
|
@ -433,14 +454,13 @@ class BastilleDay(Game):
|
|||
if self.demo:
|
||||
r = self.s.reserves[0]
|
||||
if r.canDealCards():
|
||||
##self.demo.last_deal = [] # don't check last deal
|
||||
# self.demo.last_deal = [] # don't check last deal
|
||||
return r.dealCards(sound=sound)
|
||||
return Game.dealCards(self, sound=sound)
|
||||
|
||||
shallHighlightMatch = Game._shallHighlightMatch_AC
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(135, Terrace, "Terrace",
|
||||
GI.GT_TERRACE, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
|
@ -462,4 +482,3 @@ registerGame(GameInfo(582, Wood, "Wood",
|
|||
GI.GT_TERRACE, 2, 0, GI.SL_BALANCED))
|
||||
registerGame(GameInfo(637, BastilleDay, "Bastille Day",
|
||||
GI.GT_TERRACE, 2, 0, GI.SL_BALANCED))
|
||||
|
||||
|
|
|
@ -26,23 +26,27 @@ __all__ = []
|
|||
# Imports
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mygettext import _, n_
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.gamedb import registerGame, GameInfo, GI
|
||||
from pysollib.util import *
|
||||
from pysollib.mfxutil import kwdefault
|
||||
from pysollib.stack import *
|
||||
from pysollib.game import Game
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||
from pysollib.pysoltk import MfxCanvasText
|
||||
|
||||
from golf import Golf_Waste, Golf_Hint
|
||||
|
||||
from pysollib.util import ANY_RANK
|
||||
|
||||
from pysollib.stack import \
|
||||
OpenStack, \
|
||||
StackWrapper, \
|
||||
WasteTalonStack
|
||||
|
||||
# ************************************************************************
|
||||
# * Three Peaks Row Stack
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class ThreePeaks_TalonStack(WasteTalonStack):
|
||||
|
||||
def dealCards(self, sound=False):
|
||||
|
@ -79,7 +83,8 @@ class ThreePeaks_RowStack(OpenStack):
|
|||
OpenStack.__init__(self, x, y, game, **cap)
|
||||
|
||||
def basicIsBlocked(self):
|
||||
r, step = self.game.s.rows, (3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9)
|
||||
r = self.game.s.rows
|
||||
step = (3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9)
|
||||
i = self.id
|
||||
while i < 18:
|
||||
i = i + step[i]
|
||||
|
@ -111,7 +116,6 @@ class ThreePeaks(Game):
|
|||
l, s = Layout(self), self.s
|
||||
|
||||
# set window
|
||||
decks = self.gameinfo.decks
|
||||
# compute best XOFFSET
|
||||
xoffset = int(l.XS * 8 / self.gameinfo.ncards)
|
||||
if xoffset < l.XOFFSET:
|
||||
|
@ -158,10 +162,11 @@ class ThreePeaks(Game):
|
|||
|
||||
# Create text for scores
|
||||
if self.preview <= 1:
|
||||
self.texts.info = MfxCanvasText(self.canvas,
|
||||
l.XM + l.XS * 3, h - l.YM,
|
||||
anchor="sw",
|
||||
font=self.app.getFont("canvas_default"))
|
||||
self.texts.info = MfxCanvasText(
|
||||
self.canvas,
|
||||
l.XM + l.XS * 3, h - l.YM,
|
||||
anchor="sw",
|
||||
font=self.app.getFont("canvas_default"))
|
||||
|
||||
# Define stack groups
|
||||
l.defaultStackGroups()
|
||||
|
@ -206,7 +211,7 @@ class ThreePeaks(Game):
|
|||
def getHandScore(self):
|
||||
# FIXME: bug #2937253
|
||||
score, i = self.hand_score, 1
|
||||
if 0: #self.busy:
|
||||
if 0: # self.busy:
|
||||
return score
|
||||
# First count the empty peaks
|
||||
for r in self.s.rows[:3]:
|
||||
|
@ -220,7 +225,7 @@ class ThreePeaks(Game):
|
|||
if self.sequence and len(self.s.waste.cards) - 1:
|
||||
score = score + i * 2 ** int((self.sequence - 1) / 4)
|
||||
self.hand_score = score
|
||||
#print 'getHandScore: score:', score
|
||||
# print 'getHandScore: score:', score
|
||||
return score
|
||||
|
||||
def canUndo(self):
|
||||
|
@ -260,12 +265,9 @@ class ThreePeaksNoScore(ThreePeaks):
|
|||
return True
|
||||
|
||||
|
||||
|
||||
registerGame(GameInfo(22216, ThreePeaks, "Three Peaks",
|
||||
GI.GT_PAIRING_TYPE | GI.GT_SCORE, 1, 0, GI.SL_BALANCED,
|
||||
altnames=("Tri Peaks",)
|
||||
))
|
||||
registerGame(GameInfo(22231, ThreePeaksNoScore, "Three Peaks Non-scoring",
|
||||
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_BALANCED))
|
||||
|
||||
|
||||
|
|
|
@ -24,23 +24,32 @@
|
|||
__all__ = []
|
||||
|
||||
# imports
|
||||
import sys
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mygettext import _, n_
|
||||
from pysollib.mygettext import _
|
||||
from pysollib.gamedb import registerGame, GameInfo, GI
|
||||
from pysollib.util import *
|
||||
from pysollib.mfxutil import kwdefault
|
||||
from pysollib.stack import *
|
||||
from pysollib.game import Game
|
||||
from pysollib.layout import Layout
|
||||
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
|
||||
from pysollib.hint import CautiousDefaultHint
|
||||
|
||||
from pysollib.util import ACE, JACK, KING, QUEEN
|
||||
|
||||
from pysollib.stack import \
|
||||
AC_RowStack, \
|
||||
BasicRowStack, \
|
||||
DealRowRedealTalonStack, \
|
||||
DealRowTalonStack, \
|
||||
OpenStack, \
|
||||
ReserveStack, \
|
||||
SS_RowStack, \
|
||||
Stack, \
|
||||
SS_FoundationStack
|
||||
|
||||
# ************************************************************************
|
||||
# * Tournament
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class Tournament_Talon(DealRowRedealTalonStack):
|
||||
def dealCards(self, sound=False):
|
||||
num_cards = 0
|
||||
|
@ -147,6 +156,7 @@ class LaNivernaise(Tournament):
|
|||
# * Kingsdown Eights
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class KingsdownEights_Talon(DealRowTalonStack):
|
||||
def dealCards(self, sound=False):
|
||||
if len(self.cards) == 0:
|
||||
|
@ -161,6 +171,7 @@ class KingsdownEights_Talon(DealRowTalonStack):
|
|||
self.game.stopSamples()
|
||||
return n
|
||||
|
||||
|
||||
class KingsdownEights(Game):
|
||||
|
||||
Hint_Class = CautiousDefaultHint
|
||||
|
@ -215,6 +226,7 @@ class KingsdownEights(Game):
|
|||
|
||||
class Saxony_Reserve(SS_RowStack):
|
||||
getBottomImage = Stack._getReserveBottomImage
|
||||
|
||||
def getHelp(self):
|
||||
return _('Reserve. Build down by suit.')
|
||||
|
||||
|
@ -232,11 +244,12 @@ class Saxony(Game):
|
|||
|
||||
x, y, = l.XM+1.5*l.XS, l.YM
|
||||
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))
|
||||
x += l.XS
|
||||
x, y = l.XM+1.5*l.XS, 2*l.YM+l.YS
|
||||
for i in range(8):
|
||||
s.reserves.append(BasicRowStack(x, y, self, max_move=1, max_accept=0))
|
||||
s.reserves.append(
|
||||
BasicRowStack(x, y, self, max_move=1, max_accept=0))
|
||||
x += l.XS
|
||||
x, y = l.XM, 2*l.YM+l.YS
|
||||
for i in range(4):
|
||||
|
@ -253,7 +266,6 @@ class Saxony(Game):
|
|||
|
||||
l.defaultStackGroups()
|
||||
|
||||
|
||||
def startGame(self):
|
||||
self.s.talon.dealRow(rows=self.s.reserves[8:], frames=0)
|
||||
self.s.talon.dealRow(frames=0)
|
||||
|
@ -301,7 +313,8 @@ class LadiesBattle(Game):
|
|||
l.defaultStackGroups()
|
||||
|
||||
def _shuffleHook(self, cards):
|
||||
return self._shuffleHookMoveToTop(cards,
|
||||
return self._shuffleHookMoveToTop(
|
||||
cards,
|
||||
lambda c: (c.rank in (JACK, QUEEN), (c.rank, c.suit)))
|
||||
|
||||
def startGame(self):
|
||||
|
@ -319,20 +332,15 @@ class LadiesBattle(Game):
|
|||
shallHighlightMatch = Game._shallHighlightMatch_ACW
|
||||
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(303, Tournament, "Tournament",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
|
||||
registerGame(GameInfo(304, LaNivernaise, "La Nivernaise",
|
||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
|
||||
altnames = ("Napoleon's Flank", ),))
|
||||
altnames=("Napoleon's Flank", ),))
|
||||
registerGame(GameInfo(386, KingsdownEights, "Kingsdown Eights",
|
||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
||||
registerGame(GameInfo(645, Saxony, "Saxony",
|
||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_SKILL))
|
||||
registerGame(GameInfo(652, LadiesBattle, "Ladies Battle",
|
||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
|
|||
|
||||
# my $cmd = shell_quote( 'flake8', '.' );
|
||||
my $cmd = shell_quote( 'flake8',
|
||||
grep { not($_ eq './pysollib/pysoltk.py' or $_ eq './pysollib/tile/ttk.py') } glob('./pysollib/*.py ./pysollib/[cmpuw]*/*.py ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py ./pysollib/games/[a-sy-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-ty-z]*.py') );
|
||||
|
||||
# TEST
|
||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||
|
|
Loading…
Add table
Reference in a new issue