From 4f2b28e017700a54451264a858a70667c7a7246a Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 9 Nov 2017 19:20:41 +0200 Subject: [PATCH] Extract another method. --- pysollib/game.py | 4 ++++ pysollib/games/bakersgame.py | 3 +-- pysollib/games/beleagueredcastle.py | 3 +-- pysollib/games/buffalobill.py | 3 +-- pysollib/games/calculation.py | 3 +-- pysollib/games/capricieuse.py | 3 +-- pysollib/games/curdsandwhey.py | 3 +-- pysollib/games/fan.py | 6 ++---- pysollib/games/freecell.py | 12 ++++-------- pysollib/games/golf.py | 15 +++++---------- pysollib/games/gypsy.py | 12 ++++-------- pysollib/games/katzenschwanz.py | 3 +-- pysollib/games/klondike.py | 3 +-- pysollib/games/montecarlo.py | 3 +-- pysollib/games/napoleon.py | 3 +-- pysollib/games/spider.py | 21 +++++++-------------- pysollib/games/yukon.py | 3 +-- 17 files changed, 37 insertions(+), 66 deletions(-) diff --git a/pysollib/game.py b/pysollib/game.py index c75cbe07..ea0d94c1 100644 --- a/pysollib/game.py +++ b/pysollib/game.py @@ -3404,3 +3404,7 @@ in the current implementation.''') % version) def _startDealNumRows(self, n): self._dealNumRows(n) self.startDealSample() + + def _startDealNumRowsAndDealSingleRow(self, n): + self._startDealNumRows(n) + self.s.talon.dealRow() diff --git a/pysollib/games/bakersgame.py b/pysollib/games/bakersgame.py index 2962bf26..81530ada 100644 --- a/pysollib/games/bakersgame.py +++ b/pysollib/games/bakersgame.py @@ -258,8 +258,7 @@ class Penguin(Tuxedo): self.flipMove(self.s.talon) self.moveMove(1, self.s.talon, to_stack, frames=0) # deal rows - self._startDealNumRows(6) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(6) def _restoreGameHook(self, game): self.base_card = self.cards[game.loadinfo.base_card_id] diff --git a/pysollib/games/beleagueredcastle.py b/pysollib/games/beleagueredcastle.py index e97bc3b4..474df78a 100644 --- a/pysollib/games/beleagueredcastle.py +++ b/pysollib/games/beleagueredcastle.py @@ -585,8 +585,7 @@ class Chequers(Fortress): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) def fillStack(self, stack): if self.s.talon.cards and stack in self.s.rows and not stack.cards: diff --git a/pysollib/games/buffalobill.py b/pysollib/games/buffalobill.py index 6432770c..957b70df 100644 --- a/pysollib/games/buffalobill.py +++ b/pysollib/games/buffalobill.py @@ -90,8 +90,7 @@ class BuffaloBill(Game): # def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) class LittleBillie(BuffaloBill): diff --git a/pysollib/games/calculation.py b/pysollib/games/calculation.py index 2bfaabe1..1a22ff78 100644 --- a/pysollib/games/calculation.py +++ b/pysollib/games/calculation.py @@ -409,8 +409,7 @@ class SeniorWrangler(Game): def startGame(self): self.s.talon.dealRow(rows=self.s.foundations[:8], frames=0) - self._startDealNumRows(11) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(11) # ************************************************************************ diff --git a/pysollib/games/capricieuse.py b/pysollib/games/capricieuse.py index 60d6913c..cc839e2d 100644 --- a/pysollib/games/capricieuse.py +++ b/pysollib/games/capricieuse.py @@ -152,8 +152,7 @@ class Strata(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(7) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(7) def redealCards(self): while self.s.talon.cards: diff --git a/pysollib/games/curdsandwhey.py b/pysollib/games/curdsandwhey.py index d0472582..8f20430e 100644 --- a/pysollib/games/curdsandwhey.py +++ b/pysollib/games/curdsandwhey.py @@ -115,8 +115,7 @@ class CurdsAndWhey(Game): # def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) def isGameWon(self): for s in self.s.rows: diff --git a/pysollib/games/fan.py b/pysollib/games/fan.py index b8d74286..108846d1 100644 --- a/pysollib/games/fan.py +++ b/pysollib/games/fan.py @@ -781,8 +781,7 @@ class Crescent(Game): def startGame(self): self.s.talon.dealRow(rows=self.s.foundations, frames=0) - self._startDealNumRows(5) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(5) shallHighlightMatch = Game._shallHighlightMatch_SSW @@ -930,8 +929,7 @@ class ForestGlade(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(2) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(2) shallHighlightMatch = Game._shallHighlightMatch_SS diff --git a/pysollib/games/freecell.py b/pysollib/games/freecell.py index 37aaf511..d858e678 100644 --- a/pysollib/games/freecell.py +++ b/pysollib/games/freecell.py @@ -270,8 +270,7 @@ class TripleFreecell(FreeCell): # def startGame(self): - self._startDealNumRows(11) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(11) class Cell11(TripleFreecell): @@ -291,8 +290,7 @@ class BigCell(TripleFreecell): TripleFreecell.createGame(self, rows=13, reserves=4) def startGame(self): - self._startDealNumRows(11) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(11) # ************************************************************************ @@ -572,8 +570,7 @@ class Headquarters(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(12) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(12) shallHighlightMatch = Game._shallHighlightMatch_AC @@ -637,8 +634,7 @@ class Limpopo(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(12) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(12) shallHighlightMatch = Game._shallHighlightMatch_AC diff --git a/pysollib/games/golf.py b/pysollib/games/golf.py index 7259b708..3c3902ff 100644 --- a/pysollib/games/golf.py +++ b/pysollib/games/golf.py @@ -447,8 +447,7 @@ class FourLeafClovers(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) shallHighlightMatch = Game._shallHighlightMatch_RKW @@ -495,8 +494,7 @@ class AllInARow(BlackHole): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) # ************************************************************************ @@ -691,8 +689,7 @@ class Waterfall(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) def updateText(self): if self.preview > 1: @@ -1080,8 +1077,7 @@ class Flake2Decks(Flake): Flake.createGame(self, rows=8, playcards=22) def startGame(self): - self._startDealNumRows(12) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(12) # ************************************************************************ @@ -1118,8 +1114,7 @@ class Beacon(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) def fillStack(self, stack): if stack in self.s.rows and not stack.cards: diff --git a/pysollib/games/gypsy.py b/pysollib/games/gypsy.py index c806167c..4c1074e6 100644 --- a/pysollib/games/gypsy.py +++ b/pysollib/games/gypsy.py @@ -290,8 +290,7 @@ class Nomad(MissMilligan): ReserveStack_Class = ReserveStack def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) # ************************************************************************ @@ -403,8 +402,7 @@ class PhantomBlockade(Gypsy): Gypsy.createGame(self, rows=13, playcards=24) def startGame(self): - self._startDealNumRows(2) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(2) # ************************************************************************ @@ -714,8 +712,7 @@ class Flamenco(Gypsy): def startGame(self): self.s.talon.dealRow(rows=self.s.foundations, frames=0) - self._startDealNumRows(2) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(2) # ************************************************************************ @@ -730,8 +727,7 @@ class Eclipse(Gypsy): Gypsy.createGame(self, rows=13) def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) shallHighlightMatch = Game._shallHighlightMatch_SS diff --git a/pysollib/games/katzenschwanz.py b/pysollib/games/katzenschwanz.py index eca3cef2..6924efed 100644 --- a/pysollib/games/katzenschwanz.py +++ b/pysollib/games/katzenschwanz.py @@ -388,8 +388,7 @@ class Deep(DerKatzenschwanz): return DerKatzenschwanz.createGame(self, rows=8, reserves=8) def startGame(self): - self._startDealNumRows(12) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(12) # ************************************************************************ diff --git a/pysollib/games/klondike.py b/pysollib/games/klondike.py index c655d257..cb0e4824 100644 --- a/pysollib/games/klondike.py +++ b/pysollib/games/klondike.py @@ -1256,8 +1256,7 @@ class LuckyThirteen(Game): lay.defaultStackGroups() def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) shallHighlightMatch = Game._shallHighlightMatch_RK diff --git a/pysollib/games/montecarlo.py b/pysollib/games/montecarlo.py index 0aeb97da..894847f5 100644 --- a/pysollib/games/montecarlo.py +++ b/pysollib/games/montecarlo.py @@ -633,8 +633,7 @@ class TheWishOpen(TheWish): pass def startGame(self): - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) # ************************************************************************ # * Der letzte Monarch (The last Monarch) diff --git a/pysollib/games/napoleon.py b/pysollib/games/napoleon.py index 7e21a903..1d925244 100644 --- a/pysollib/games/napoleon.py +++ b/pysollib/games/napoleon.py @@ -404,8 +404,7 @@ class BusyCards(Game): def startGame(self): self.s.talon.dealRow(rows=self.s.foundations, frames=0) - self._startDealNumRows(7) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(7) shallHighlightMatch = Game._shallHighlightMatch_SS diff --git a/pysollib/games/spider.py b/pysollib/games/spider.py index af78697c..5bf6d33f 100644 --- a/pysollib/games/spider.py +++ b/pysollib/games/spider.py @@ -235,8 +235,7 @@ class GroundsForADivorce(RelaxedSpider): RelaxedSpider.createGame(self, playcards=22) def startGame(self): - self._startDealNumRows(4) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(4) shallHighlightMatch = Game._shallHighlightMatch_RKW @@ -252,8 +251,7 @@ class GrandmothersGame(RelaxedSpider): RelaxedSpider.createGame(self, playcards=22) def startGame(self): - self._startDealNumRows(5) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(5) # ************************************************************************ @@ -538,8 +536,7 @@ class MrsMop(RelaxedSpider): RelaxedSpider.createGame(self, rows=13, playcards=24, texts=0) def startGame(self): - self._startDealNumRows(7) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(7) # ************************************************************************ @@ -598,8 +595,7 @@ class Cicely(Game): def startGame(self): self.s.talon.dealRow(rows=self.s.reserves, frames=0) - self._startDealNumRows(3) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(3) shallHighlightMatch = Game._shallHighlightMatch_SS @@ -1051,8 +1047,7 @@ class FredsSpider(Spidike): Spidike.createGame(self, rows=10, playcards=23) def startGame(self): - self._startDealNumRows(4) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(4) class FredsSpider3Decks(FredsSpider): @@ -1127,8 +1122,7 @@ class Incompatibility(Spidike): Spidike.createGame(self, rows=10) def startGame(self): - self._startDealNumRows(4) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(4) # ************************************************************************ @@ -1377,8 +1371,7 @@ class TheJollyRoger(Game): l.defaultStackGroups() def startGame(self): - self._startDealNumRows(2) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(2) def shallHighlightMatch(self, stack1, card1, stack2, card2): if card1.rank != ACE and card2.rank != ACE: diff --git a/pysollib/games/yukon.py b/pysollib/games/yukon.py index ee7a11c3..2f49af8f 100644 --- a/pysollib/games/yukon.py +++ b/pysollib/games/yukon.py @@ -657,8 +657,7 @@ class Hawaiian(Game): def startGame(self): for i in range(104-5*10): self.s.talon.dealRow(rows=self.s.reserves, frames=0) - self._startDealNumRows(4) - self.s.talon.dealRow() + self._startDealNumRowsAndDealSingleRow(4) def getHighlightPilesStacks(self): return ()