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

Extract a base class/trait for some games.

This commit is contained in:
Shlomi Fish 2017-11-13 21:38:34 +02:00
parent ada9778879
commit 4ad3f0f889
10 changed files with 23 additions and 35 deletions

View file

@ -3415,3 +3415,8 @@ in the current implementation.''') % version)
def _startAndDealRowAndCards(self):
self._startAndDealRow()
self.s.talon.dealCards()
class StartDealRowAndCards(object):
def startGame(self):
self._startAndDealRowAndCards()

View file

@ -28,6 +28,7 @@ from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.mfxutil import kwdefault
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, CautiousDefaultHint
@ -433,7 +434,7 @@ class SweetSixteen(TrustyTwelve):
# * Glacier
# ************************************************************************
class Glacier(Game):
class Glacier(pysollib.game.StartDealRowAndCards, Game):
def createGame(self, rows=12):
l, s = Layout(self), self.s
@ -457,9 +458,6 @@ class Glacier(Game):
l.defaultStackGroups()
def startGame(self):
self._startAndDealRowAndCards()
shallHighlightMatch = Game._shallHighlightMatch_RKW

View file

@ -26,6 +26,7 @@
# PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
# from pysollib.util import ACE
@ -52,7 +53,7 @@ class EiffelTower_RowStack(OpenStack):
return self.cards[-1].rank + cards[0].rank == 12
class EiffelTower(Game):
class EiffelTower(pysollib.game.StartDealRowAndCards, Game):
Talon_Class = WasteTalonStack
Waste_Class = WasteStack
@ -90,9 +91,6 @@ class EiffelTower(Game):
# game overrides
#
def startGame(self):
self._startAndDealRowAndCards()
def isGameWon(self):
return len(self.s.talon.cards) == 0 and len(self.s.waste.cards) == 0

View file

@ -26,6 +26,7 @@
# PySol imports
from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI
import pysollib.game
from pysollib.mfxutil import kwdefault
from pysollib.game import Game
from pysollib.layout import Layout
@ -288,9 +289,8 @@ class Elevator(RelaxedGolf):
self.s.talon.dealCards() # deal first card to WasteStack
class Escalator(Elevator):
def startGame(self):
self._startAndDealRowAndCards()
class Escalator(pysollib.game.StartDealRowAndCards, Elevator):
pass
# ************************************************************************

View file

@ -28,6 +28,7 @@ from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.mfxutil import kwdefault, Struct
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.hint import CautiousDefaultHint
from pysollib.hint import KlondikeType_Hint
@ -279,13 +280,10 @@ class Westhaven(Westcliff):
# * Pas Seul
# ************************************************************************
class PasSeul(Eastcliff):
class PasSeul(pysollib.game.StartDealRowAndCards, Eastcliff):
def createGame(self):
Klondike.createGame(self, max_rounds=1, rows=6)
def startGame(self):
self._startAndDealRowAndCards()
# ************************************************************************
# * Blind Alleys

View file

@ -26,6 +26,7 @@
# PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.util import ANY_RANK, ANY_SUIT
@ -69,7 +70,7 @@ class Simplex_RowStack(SequenceRowStack):
return isSameRankSequence(cards)
class Simplex(Game):
class Simplex(pysollib.game.StartDealRowAndCards, Game):
def createGame(self, reserves=6):
# create layout
@ -101,9 +102,6 @@ class Simplex(Game):
# define stack-groups
l.defaultStackGroups()
def startGame(self):
self._startAndDealRowAndCards()
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return card1.rank == card2.rank

View file

@ -28,6 +28,7 @@ from pysollib.mygettext import _
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.mfxutil import kwdefault
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.hint import CautiousDefaultHint
from pysollib.hint import SpiderType_Hint, YukonType_Hint
@ -315,16 +316,13 @@ class SimpleSimonII(SimpleSimon):
# * Rachel
# ************************************************************************
class Rachel(RelaxedSpider):
class Rachel(pysollib.game.StartDealRowAndCards, RelaxedSpider):
Talon_Class = StackWrapper(WasteTalonStack, max_rounds=1)
RowStack_Class = BlackWidow_RowStack
def createGame(self):
RelaxedSpider.createGame(self, waste=1, rows=6, texts=1)
def startGame(self):
self._startAndDealRowAndCards()
# ************************************************************************
# * Scorpion - move cards like in Russian Solitaire

View file

@ -27,6 +27,7 @@
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.mfxutil import kwdefault
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.hint import CautiousDefaultHint
@ -88,7 +89,7 @@ class UnionSquare_RowStack(OpenStack):
# *
# ************************************************************************
class UnionSquare(Game):
class UnionSquare(pysollib.game.StartDealRowAndCards, Game):
Hint_Class = CautiousDefaultHint
Foundation_Class = StackWrapper(UnionSquare_Foundation, max_cards=26)
RowStack_Class = UnionSquare_RowStack
@ -134,9 +135,6 @@ class UnionSquare(Game):
# game overrides
#
def startGame(self):
self._startAndDealRowAndCards()
shallHighlightMatch = Game._shallHighlightMatch_SS
def getHighlightPilesStacks(self):

View file

@ -26,6 +26,7 @@
# PySol imports
from pysollib.gamedb import registerGame, GameInfo, GI
from pysollib.game import Game
import pysollib.game
from pysollib.layout import Layout
from pysollib.hint import CautiousDefaultHint
@ -202,7 +203,7 @@ class DutchSolitaire(Windmill):
# * Napoleon's Tomb
# ************************************************************************
class NapoleonsTomb(Game):
class NapoleonsTomb(pysollib.game.StartDealRowAndCards, Game):
#
# game layout
@ -238,13 +239,6 @@ class NapoleonsTomb(Game):
# define stack-groups
l.defaultStackGroups()
#
# game overrides
#
def startGame(self):
self._startAndDealRowAndCards()
# ************************************************************************
# * Corners

View file

@ -1 +1,2 @@
let @m=':s#for \w\+ in range(\([0-9]\+\)):#self._dealNumRows(\1)# jdd'
map <F2> /^ def startGame(self):\n self\._startAndDealRowAndCards()<CR>2dd?^class<CR>:s/(/(pysollib.game.StartDealRowAndCards, /<CR>