mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added Eight Cards game.
This commit is contained in:
parent
c8ea09c319
commit
9d3bae687d
3 changed files with 114 additions and 3 deletions
21
html-src/rules/eightcards.html
Normal file
21
html-src/rules/eightcards.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<h1>Eight Cards (Acht Karten)</h1>
|
||||||
|
<p>
|
||||||
|
Pairing game type. 1 deck. No redeal.
|
||||||
|
|
||||||
|
<h3>Object</h3>
|
||||||
|
<p>
|
||||||
|
Discard all the cards.
|
||||||
|
|
||||||
|
<h3>Rules</h3>
|
||||||
|
<p>
|
||||||
|
Eight cards are dealt to the tableau. Cards with a total rank
|
||||||
|
of 11 are removed, and replaced from the tableau. Picture cards
|
||||||
|
can be removed on their own. Up to twice during the game, you are
|
||||||
|
allowed to draw a single card from the talon as a ninth card,
|
||||||
|
which can then be paired with an appropriate tableau card.
|
||||||
|
<p>
|
||||||
|
You win when the tableau piles are all gone.
|
||||||
|
|
||||||
|
<h3>Notes</h3>
|
||||||
|
<p>
|
||||||
|
<i>Autodrop</i> is disabled for this game.
|
|
@ -587,7 +587,7 @@ class GI:
|
||||||
('fc-2.20', tuple(range(855, 897))),
|
('fc-2.20', tuple(range(855, 897))),
|
||||||
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
|
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
|
||||||
tuple(range(13160, 13163)) + (16682,)),
|
tuple(range(13160, 13163)) + (16682,)),
|
||||||
('dev', tuple(range(906, 929)) + tuple(range(11017, 11020)) +
|
('dev', tuple(range(906, 930)) + tuple(range(11017, 11020)) +
|
||||||
tuple(range(5600, 5624)) + tuple(range(18000, 18004)) +
|
tuple(range(5600, 5624)) + tuple(range(18000, 18004)) +
|
||||||
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
|
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
|
||||||
)
|
)
|
||||||
|
|
|
@ -442,6 +442,10 @@ class Thirteen(Pyramid):
|
||||||
|
|
||||||
class Thirteens(Pyramid):
|
class Thirteens(Pyramid):
|
||||||
RowStack_Class = Giza_Reserve
|
RowStack_Class = Giza_Reserve
|
||||||
|
Foundation_Class = Pyramid_Foundation
|
||||||
|
Talon_Class = AutoDealTalonStack
|
||||||
|
|
||||||
|
EXTRA_PILE = False
|
||||||
|
|
||||||
def createGame(self, rows=2, cols=5):
|
def createGame(self, rows=2, cols=5):
|
||||||
# create layout
|
# create layout
|
||||||
|
@ -460,10 +464,12 @@ class Thirteens(Pyramid):
|
||||||
x += layout.XS
|
x += layout.XS
|
||||||
y += layout.YS
|
y += layout.YS
|
||||||
x, y = layout.XM, self.height-layout.YS
|
x, y = layout.XM, self.height-layout.YS
|
||||||
s.talon = AutoDealTalonStack(x, y, self)
|
s.talon = self.Talon_Class(x, y, self)
|
||||||
|
if self.EXTRA_PILE:
|
||||||
|
s.reserves.append(self.RowStack_Class(x + layout.XS, y, self))
|
||||||
layout.createText(s.talon, 'n')
|
layout.createText(s.talon, 'n')
|
||||||
x, y = self.width-layout.XS, self.height-layout.YS
|
x, y = self.width-layout.XS, self.height-layout.YS
|
||||||
s.foundations.append(Pyramid_Foundation(x, y, self,
|
s.foundations.append(self.Foundation_Class(x, y, self,
|
||||||
suit=ANY_SUIT, dir=0, base_rank=ANY_RANK,
|
suit=ANY_SUIT, dir=0, base_rank=ANY_RANK,
|
||||||
max_move=0, max_cards=52))
|
max_move=0, max_cards=52))
|
||||||
layout.createText(s.foundations[0], 'n')
|
layout.createText(s.foundations[0], 'n')
|
||||||
|
@ -781,6 +787,87 @@ class Neptune(Thirteens):
|
||||||
return len(self.s.talon.cards) == 0
|
return len(self.s.talon.cards) == 0
|
||||||
|
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
# * Eight Cards
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
class EightCards_RowStack(Elevens_RowStack):
|
||||||
|
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if from_stack is self or not self.cards or len(cards) != 1:
|
||||||
|
return False
|
||||||
|
c = self.cards[-1]
|
||||||
|
return (c.face_up and cards[0].face_up and
|
||||||
|
(cards[0].rank + c.rank == 9))
|
||||||
|
|
||||||
|
def clickHandler(self, event):
|
||||||
|
game = self.game
|
||||||
|
if self.cards and self.cards[0].rank > 9:
|
||||||
|
game.playSample("autodrop", priority=20)
|
||||||
|
self.playMoveMove(1, game.s.foundations[0], sound=False)
|
||||||
|
self.fillStack()
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class EightCards_Foundation(AbstractFoundationStack):
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
|
||||||
|
return False
|
||||||
|
# We accept any picture cards.
|
||||||
|
return cards[0].rank > 9
|
||||||
|
|
||||||
|
|
||||||
|
class EightCards_Talon(AutoDealTalonStack):
|
||||||
|
def canDealCards(self):
|
||||||
|
return self.game.draws > 0 and len(self.game.s.reserves[0].cards) < 1
|
||||||
|
|
||||||
|
def dealCards(self, sound=False):
|
||||||
|
self.game.playSample("dealwaste")
|
||||||
|
self.flipMove()
|
||||||
|
self.moveMove(1, self.game.s.reserves[0])
|
||||||
|
old_state = self.game.enterState(self.game.S_FILL)
|
||||||
|
self.game.saveStateMove(2 | 16) # for undo
|
||||||
|
self.game.draws -= 1
|
||||||
|
self.game.saveStateMove(1 | 16) # for redo
|
||||||
|
self.game.leaveState(old_state)
|
||||||
|
|
||||||
|
|
||||||
|
class EightCards(Thirteens):
|
||||||
|
RowStack_Class = EightCards_RowStack
|
||||||
|
Foundation_Class = EightCards_Foundation
|
||||||
|
Talon_Class = EightCards_Talon
|
||||||
|
|
||||||
|
EXTRA_PILE = True
|
||||||
|
|
||||||
|
draws = 2
|
||||||
|
|
||||||
|
def createGame(self):
|
||||||
|
Thirteens.createGame(self, rows=2, cols=4)
|
||||||
|
|
||||||
|
def startGame(self):
|
||||||
|
self._startAndDealRow()
|
||||||
|
self.draws = 2
|
||||||
|
|
||||||
|
def _restoreGameHook(self, game):
|
||||||
|
self.draws = game.loadinfo.draws
|
||||||
|
|
||||||
|
def _loadGameHook(self, p):
|
||||||
|
self.loadinfo.addattr(draws=p.load())
|
||||||
|
|
||||||
|
def _saveGameHook(self, p):
|
||||||
|
p.dump(self.draws)
|
||||||
|
|
||||||
|
def setState(self, state):
|
||||||
|
# restore saved vars (from undo/redo)
|
||||||
|
self.draws = state[0]
|
||||||
|
|
||||||
|
def getState(self):
|
||||||
|
# save vars (for undo/redo)
|
||||||
|
return [self.draws]
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Triple Alliance
|
# * Triple Alliance
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -1552,3 +1639,6 @@ registerGame(GameInfo(854, Neptune, "Neptune",
|
||||||
registerGame(GameInfo(916, Tens, "Tens",
|
registerGame(GameInfo(916, Tens, "Tens",
|
||||||
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK,
|
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK,
|
||||||
altnames=('Take Ten',)))
|
altnames=('Take Ten',)))
|
||||||
|
registerGame(GameInfo(929, EightCards, "Eight Cards",
|
||||||
|
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK,
|
||||||
|
altnames=('Acht Karten',)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue