diff --git a/pysollib/games/wavemotion.py b/pysollib/games/wavemotion.py index 30ca275f..384e9f7e 100644 --- a/pysollib/games/wavemotion.py +++ b/pysollib/games/wavemotion.py @@ -24,22 +24,27 @@ __all__ = [] # imports -import sys # PySol imports 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 + +from pysollib.stack import \ + AC_RowStack, \ + InitialDealTalonStack, \ + OpenStack, \ + isAlternateColorSequence, \ + isSameSuitSequence, \ + SS_RowStack # ************************************************************************ # * Wave Motion # ************************************************************************ + class WaveMotion(Game): RowStack_Class = SS_RowStack @@ -116,9 +121,9 @@ class Flourish(WaveMotion): shallHighlightMatch = Game._shallHighlightMatch_AC - # register the game registerGame(GameInfo(314, WaveMotion, "Wave Motion", GI.GT_1DECK_TYPE | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(753, Flourish, "Flourish", - GI.GT_1DECK_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL)) + GI.GT_1DECK_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, + GI.SL_MOSTLY_SKILL)) diff --git a/pysollib/games/windmill.py b/pysollib/games/windmill.py index cda769dc..f311819a 100644 --- a/pysollib/games/windmill.py +++ b/pysollib/games/windmill.py @@ -24,23 +24,34 @@ __all__ = [] # imports -import sys # PySol imports from pysollib.gamedb import registerGame, GameInfo, GI -from pysollib.util import * -from pysollib.stack import * from pysollib.game import Game from pysollib.layout import Layout -from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint +from pysollib.hint import CautiousDefaultHint from golf import BlackHole_Foundation +from pysollib.util import ACE, ANY_SUIT, KING, UNLIMITED_CARDS + +from pysollib.stack import \ + AC_RowStack, \ + RK_FoundationStack, \ + RK_RowStack, \ + ReserveStack, \ + SS_FoundationStack, \ + Stack, \ + UD_RK_RowStack, \ + WasteStack, \ + WasteTalonStack, \ + StackWrapper # ************************************************************************ # * # ************************************************************************ + class Windmill_Foundation(RK_FoundationStack): def getBottomImage(self): if self.cap.base_rank == ACE: @@ -69,8 +80,9 @@ class Windmill(Game): ] RowStack_Class = Windmill_RowStack - FOUNDATIONS_LAYOUT = ((1,0.6), (3,0.6), (1,3.4), (3,3.4)) - ROWS_LAYOUT = ((2,0), (2,1), (0,2), (1,2), (3,2), (4,2), (2,3), (2,4)) + FOUNDATIONS_LAYOUT = ((1, 0.6), (3, 0.6), (1, 3.4), (3, 3.4)) + ROWS_LAYOUT = ((2, 0), (2, 1), (0, 2), (1, 2), (3, 2), (4, 2), + (2, 3), (2, 4)) FILL_STACK = True # @@ -159,8 +171,8 @@ class DutchSolitaire(Windmill): ] RowStack_Class = DutchSolitaire_RowStack - FOUNDATIONS_LAYOUT = ((1,1), (3,1), (1,3), (3,3)) - ROWS_LAYOUT = ((2,0.5), (-0.5,2), (0.5,2), (3.5,2), (4.5,2), (2,3.5)) + FOUNDATIONS_LAYOUT = ((1, 1), (3, 1), (1, 3), (3, 3)) + ROWS_LAYOUT = ((2, 0.5), (-0.5, 2), (0.5, 2), (3.5, 2), (4.5, 2), (2, 3.5)) FILL_STACK = False def createGame(self): @@ -216,7 +228,7 @@ class NapoleonsTomb(Game): s.waste = WasteStack(x, y, self) l.createText(s.waste, "s") x0, y0 = x + l.XS, y - for d in ((0,1), (1,0), (1,2), (2,1)): + for d in ((0, 1), (1, 0), (1, 2), (2, 1)): x, y = x0 + d[0] * l.XS, y0 + d[1] * l.YS s.rows.append(Windmill_RowStack(x, y, self)) x, y = x0 + l.XS, y0 + l.YS @@ -230,7 +242,6 @@ class NapoleonsTomb(Game): # define stack-groups l.defaultStackGroups() - # # game overrides # @@ -266,12 +277,12 @@ class Corners(Game): l.createText(s.waste, "se") x0, y0 = l.XM, l.YM+l.YS i = 0 - for d in ((0,0), (4,0), (0,2), (4,2)): + for d in ((0, 0), (4, 0), (0, 2), (4, 2)): x, y = x0+d[0]*l.XS, y0+d[1]*l.YS s.foundations.append(SS_FoundationStack(x, y, self, suit=i, max_move=0, mod=13)) i += 1 - for d in ((2,0), (1,1), (2,1), (3,1), (2,2)): + for d in ((2, 0), (1, 1), (2, 1), (3, 1), (2, 2)): x, y = x0+d[0]*l.XS, y0+d[1]*l.YS stack = self.RowStack_Class(x, y, self) s.rows.append(stack) @@ -280,7 +291,6 @@ class Corners(Game): # define stack-groups l.defaultStackGroups() - def fillStack(self, stack): if len(stack.cards) == 0: if stack is self.s.waste and self.s.talon.cards: @@ -288,7 +298,6 @@ class Corners(Game): elif stack in self.s.rows and self.s.waste.cards: self.s.waste.moveMove(1, stack) - def _shuffleHook(self, cards): suits = [] top_cards = [] @@ -299,10 +308,9 @@ class Corners(Game): top_cards.append(c) if len(suits) == 4: break - top_cards.sort(lambda a, b: cmp(b.suit, a.suit)) + top_cards = sorted(top_cards, key=lambda x: -x.suit) return cards+top_cards - def startGame(self): self.startDealSample() self.s.talon.dealRow(rows=self.s.foundations) @@ -363,6 +371,7 @@ class FourSeasons(Czarina): def fillStack(self, stack): pass + class FlorentinePatience(FourSeasons): def createGame(self): Czarina.createGame(self, max_rounds=2) @@ -388,7 +397,8 @@ class Simplicity(Game): (l.XM, l.YM+3*l.YS), (l.XM+7*l.XS, l.YM+3*l.YS), ): - s.foundations.append(SS_FoundationStack(x, y, self, suit=i, mod=13)) + s.foundations.append( + SS_FoundationStack(x, y, self, suit=i, mod=13)) i += 1 y = l.YM+l.YS for i in range(2): @@ -408,7 +418,6 @@ class Simplicity(Game): l.defaultStackGroups() - def startGame(self): self.startDealSample() # deal base_card to Foundations, update foundations cap.base_rank @@ -420,10 +429,8 @@ class Simplicity(Game): self.s.talon.dealRow() self.s.talon.dealCards() - shallHighlightMatch = Game._shallHighlightMatch_ACW - def _restoreGameHook(self, game): self.base_card = self.cards[game.loadinfo.base_card_id] for s in self.s.foundations: @@ -453,9 +460,8 @@ registerGame(GameInfo(483, Czarina, "Czarina", rules_filename='fourseasons.html')) registerGame(GameInfo(484, FourSeasons, "Four Seasons", GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK, - altnames=('Corner Card', 'Vanishing Cross') )) + altnames=('Corner Card', 'Vanishing Cross'))) registerGame(GameInfo(561, DutchSolitaire, "Dutch Solitaire", GI.GT_2DECK_TYPE, 2, 0, GI.SL_MOSTLY_SKILL)) registerGame(GameInfo(696, FlorentinePatience, "Florentine Patience", GI.GT_1DECK_TYPE, 1, 1, GI.SL_MOSTLY_LUCK)) - diff --git a/tests/style/py-flake8.t b/tests/style/py-flake8.t index bba94c62..22a3956b 100644 --- a/tests/style/py-flake8.t +++ b/tests/style/py-flake8.t @@ -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-uy-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-wy-z]*.py') ); # TEST eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );