mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added Display game.
This commit is contained in:
parent
a95c7a1e42
commit
e54b6cc2d1
3 changed files with 124 additions and 13 deletions
29
html-src/rules/display.html
Normal file
29
html-src/rules/display.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<h1>Display</h1>
|
||||||
|
<p>
|
||||||
|
Two-Deck game type. 2 decks. 1 redeal.
|
||||||
|
|
||||||
|
<h3>Object</h3>
|
||||||
|
<p>
|
||||||
|
Move all the cards to the foundations.
|
||||||
|
|
||||||
|
<h3>Rules</h3>
|
||||||
|
<p>
|
||||||
|
At the start of the game, one card is dealt to the leftmost
|
||||||
|
of thirteen foundations.
|
||||||
|
<p>
|
||||||
|
Deal cards from the stock one at a time. You go through the talon
|
||||||
|
twice. During the first deal, each card must be played to one of
|
||||||
|
three special reserve piles. The top card from any of these can be
|
||||||
|
moved to the foundations only. When redealing, these reserve
|
||||||
|
piles are put together to form a new deck. During the second deal,
|
||||||
|
these reserve piles are unused, and cards are simply dealt to the
|
||||||
|
waste pile.
|
||||||
|
<p>
|
||||||
|
Cards from the waste pile or reserves may be moved to foundations,
|
||||||
|
which are built down by rank, wrapping down from ace to king as
|
||||||
|
necessary. A card cannot be placed in a foundation unless the foundation
|
||||||
|
to the left of it has cards in it. Each foundation starts with a card
|
||||||
|
one rank lower than the foundation to the left of it, and can hold eight
|
||||||
|
cards max.
|
||||||
|
<p>
|
||||||
|
The game is won if all cards are moved to the foundations.
|
|
@ -479,7 +479,7 @@ class GI:
|
||||||
('fc-2.12', tuple(range(774, 811)) + (16681,) +
|
('fc-2.12', tuple(range(774, 811)) + (16681,) +
|
||||||
tuple(range(22217, 22219))),
|
tuple(range(22217, 22219))),
|
||||||
('fc-2.14', tuple(range(811, 827))),
|
('fc-2.14', tuple(range(811, 827))),
|
||||||
('fc-2.16', tuple(range(827, 832)))
|
('fc-2.16', tuple(range(827, 833)))
|
||||||
)
|
)
|
||||||
|
|
||||||
# deprecated - the correct way is to or a GI.GT_XXX flag
|
# deprecated - the correct way is to or a GI.GT_XXX flag
|
||||||
|
|
|
@ -25,9 +25,11 @@ from pysollib.game import Game
|
||||||
from pysollib.gamedb import GI, GameInfo, registerGame
|
from pysollib.gamedb import GI, GameInfo, registerGame
|
||||||
from pysollib.layout import Layout
|
from pysollib.layout import Layout
|
||||||
from pysollib.stack import \
|
from pysollib.stack import \
|
||||||
|
ReserveStack, \
|
||||||
RK_FoundationStack, \
|
RK_FoundationStack, \
|
||||||
WasteStack, \
|
WasteStack, \
|
||||||
WasteTalonStack
|
WasteTalonStack
|
||||||
|
from pysollib.util import KING
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -37,36 +39,56 @@ from pysollib.stack import \
|
||||||
|
|
||||||
class Precedence_Foundation(RK_FoundationStack):
|
class Precedence_Foundation(RK_FoundationStack):
|
||||||
def acceptsCards(self, from_stack, cards):
|
def acceptsCards(self, from_stack, cards):
|
||||||
if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
|
if (not self.cards):
|
||||||
|
if (self.id > 0 and not self.game.s
|
||||||
|
.foundations[self.id - 1].cards):
|
||||||
return False
|
return False
|
||||||
if (self.id > 0 and not self.game.s.foundations[self.id - 1].cards):
|
if self.id == 0:
|
||||||
|
return cards[0].rank == KING
|
||||||
|
else:
|
||||||
|
return cards[0].rank == (self.game.s
|
||||||
|
.foundations[self.id - 1]
|
||||||
|
.cards[0].rank - 1) % 13
|
||||||
|
if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Precedence(Game):
|
class Precedence(Game):
|
||||||
|
FOUNDATIONS = 8
|
||||||
|
RESERVES = 0
|
||||||
|
NUM_ROUNDS = 3
|
||||||
|
|
||||||
|
TALON_STACK = WasteTalonStack
|
||||||
|
WASTE_STACK = WasteStack
|
||||||
|
RESERVE_STACK = ReserveStack
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
layout, s = Layout(self), self.s
|
layout, s = Layout(self), self.s
|
||||||
self.setSize(layout.XM + 8 * layout.XS, layout.YM + 2 * layout.YS)
|
self.setSize(layout.XM + self.FOUNDATIONS * layout.XS,
|
||||||
|
layout.YM + 2 * layout.YS)
|
||||||
x, y = layout.XM, layout.YM
|
x, y = layout.XM, layout.YM
|
||||||
c_rank = 12
|
for i in range(self.FOUNDATIONS):
|
||||||
for i in range(8):
|
c_max = (self.gameinfo.decks * 52) / self.FOUNDATIONS
|
||||||
s.foundations.append(Precedence_Foundation(x, y, self, dir=-1,
|
s.foundations.append(Precedence_Foundation(x, y, self, dir=-1,
|
||||||
mod=13,
|
mod=13,
|
||||||
base_rank=c_rank,
|
max_move=0,
|
||||||
max_move=0))
|
max_cards=c_max))
|
||||||
x += layout.XS
|
x += layout.XS
|
||||||
c_rank -= 1
|
|
||||||
x, y = layout.XM + (layout.XS * 3), layout.YM + layout.YS
|
x, y = layout.XM + (layout.XS * 3), layout.YM + layout.YS
|
||||||
s.talon = WasteTalonStack(x, y, self,
|
s.talon = self.TALON_STACK(x, y, self,
|
||||||
max_rounds=3, num_deal=1)
|
max_rounds=self.NUM_ROUNDS, num_deal=1)
|
||||||
layout.createText(s.talon, 'nw')
|
layout.createText(s.talon, 'nw')
|
||||||
layout.createRoundText(s.talon, 'se', dx=layout.XS)
|
layout.createRoundText(s.talon, 'se', dx=layout.XS)
|
||||||
x += layout.XS
|
x += layout.XS
|
||||||
s.waste = WasteStack(x, y, self)
|
s.waste = self.WASTE_STACK(x, y, self)
|
||||||
layout.createText(s.waste, 'ne')
|
layout.createText(s.waste, 'ne')
|
||||||
|
|
||||||
|
x += 2 * layout.XS
|
||||||
|
for i in range(self.RESERVES):
|
||||||
|
s.reserves.append(self.RESERVE_STACK(x, y, self, max_cards=104))
|
||||||
|
x += layout.XS
|
||||||
|
|
||||||
# define stack-groups
|
# define stack-groups
|
||||||
layout.defaultStackGroups()
|
layout.defaultStackGroups()
|
||||||
|
|
||||||
|
@ -96,9 +118,69 @@ class PrecedenceNoKing(Precedence):
|
||||||
self.s.talon.dealCards()
|
self.s.talon.dealCards()
|
||||||
|
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
# * Display
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
class Display_Talon(WasteTalonStack):
|
||||||
|
def _redeal(self):
|
||||||
|
game, num_cards = self.game, len(self.cards)
|
||||||
|
if len(self.waste.cards) > 0:
|
||||||
|
game.moveMove(1, self.waste, game.s.reserves[0], frames=2)
|
||||||
|
rows = list(game.s.reserves)[:]
|
||||||
|
rows.reverse()
|
||||||
|
for r in rows:
|
||||||
|
while r.cards:
|
||||||
|
num_cards = num_cards + 1
|
||||||
|
game.moveMove(1, r, self, frames=2)
|
||||||
|
if self.cards[-1].face_up:
|
||||||
|
game.flipMove(self)
|
||||||
|
assert len(self.cards) == num_cards
|
||||||
|
self.game.nextRoundMove(self)
|
||||||
|
|
||||||
|
def canDealCards(self):
|
||||||
|
return ((self.round > 1 and len(self.cards) > 0)
|
||||||
|
or (self.round == 1 and len(self.cards) == 0)
|
||||||
|
or (len(self.waste.cards) == 0))
|
||||||
|
|
||||||
|
def dealCards(self, sound=False):
|
||||||
|
if self.cards:
|
||||||
|
return WasteTalonStack.dealCards(self, sound=sound)
|
||||||
|
if sound:
|
||||||
|
self.game.startDealSample()
|
||||||
|
self._redeal()
|
||||||
|
if sound:
|
||||||
|
self.game.stopSamples()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class Display_ReserveStack(ReserveStack):
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
return self.game.s.talon.round == 1 and from_stack == self.game.s.waste
|
||||||
|
|
||||||
|
|
||||||
|
class Display(Precedence):
|
||||||
|
FOUNDATIONS = 13
|
||||||
|
RESERVES = 3
|
||||||
|
NUM_ROUNDS = 2
|
||||||
|
|
||||||
|
TALON_STACK = Display_Talon
|
||||||
|
RESERVE_STACK = Display_ReserveStack
|
||||||
|
|
||||||
|
def _shuffleHook(self, cards):
|
||||||
|
return cards
|
||||||
|
|
||||||
|
def _autoDeal(self, sound=True):
|
||||||
|
# only autodeal if there are cards in the talon.
|
||||||
|
if len(self.s.talon.cards) > 0:
|
||||||
|
return Game._autoDeal(self, sound=sound)
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(790, Precedence, "Precedence",
|
registerGame(GameInfo(790, Precedence, "Precedence",
|
||||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
|
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK,
|
||||||
altnames=("Order of Precedence")))
|
altnames=("Order of Precedence", "Succession")))
|
||||||
registerGame(GameInfo(791, PrecedenceNoKing, "Precedence (No King)",
|
registerGame(GameInfo(791, PrecedenceNoKing, "Precedence (No King)",
|
||||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
|
GI.GT_2DECK_TYPE, 2, 2, GI.SL_MOSTLY_LUCK))
|
||||||
|
registerGame(GameInfo(832, Display, "Display",
|
||||||
|
GI.GT_2DECK_TYPE, 2, 1, GI.SL_BALANCED))
|
||||||
|
|
Loading…
Add table
Reference in a new issue