mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added King's Audience game.
This commit is contained in:
parent
e7f8944adb
commit
23894e38c6
3 changed files with 166 additions and 6 deletions
36
html-src/rules/kingsaudience.html
Normal file
36
html-src/rules/kingsaudience.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<h1>King's Audience</h1>
|
||||||
|
<p>
|
||||||
|
One-Deck game type. 1 deck. No redeal.
|
||||||
|
|
||||||
|
<h3>Object</h3>
|
||||||
|
<p>
|
||||||
|
Move all cards to the foundations.
|
||||||
|
|
||||||
|
<h3>Rules</h3>
|
||||||
|
<p>
|
||||||
|
Sixteen cards are dealt in a square, forming a tableau called
|
||||||
|
the "antechamber". No building on these tableau piles is allowed.
|
||||||
|
<p>
|
||||||
|
There are two rows of foundations. Each foundation in the top row
|
||||||
|
just receives a King and Queen of the same suit, both of which must
|
||||||
|
be played together when both cards are available (in PySol, move one
|
||||||
|
appropriate card to the other in the tableau, and they will both
|
||||||
|
automatically be moved to the correct foundation). The bottom row
|
||||||
|
of foundations is started with an ace and Jack of the same suit,
|
||||||
|
played in a similar manner, but with the Jack on top. Then, they're
|
||||||
|
built down by same suit from Jack to two.
|
||||||
|
<p>
|
||||||
|
Empty piles in the antechamber are filled from the waste pile, or
|
||||||
|
the talon if the waste is empty. Cards can be dealt from the talon
|
||||||
|
one at a time to the waste pile - no redeal is allowed. The game
|
||||||
|
is won if all cards are moved to the foundations.
|
||||||
|
|
||||||
|
<h3>Notes</h3>
|
||||||
|
<p>
|
||||||
|
The name of the game comes from the fact that the lower foundation
|
||||||
|
cards - the Jacks with their entourages - end up adjacent to the Kings
|
||||||
|
and Queens as if having an audience with them.
|
||||||
|
<p>
|
||||||
|
The game also goes by the name Queen's Foundation. In some variations,
|
||||||
|
depending on which name is used, either the King or Queen is placed on
|
||||||
|
top in the king-queen foundations.
|
|
@ -330,8 +330,7 @@ class GI:
|
||||||
# Gnome AisleRiot 2.2.0 (we have 65 out of 70 games)
|
# Gnome AisleRiot 2.2.0 (we have 65 out of 70 games)
|
||||||
# Gnome AisleRiot 3.22.7
|
# Gnome AisleRiot 3.22.7
|
||||||
# still missing:
|
# still missing:
|
||||||
# Hamilton, Isabel, King's Audience, Labyrinth, Thieves,
|
# Hamilton, Isabel, Labyrinth, Thieves, Treize, Valentine, Wall
|
||||||
# Treize, Valentine, Wall
|
|
||||||
("Gnome AisleRiot", (
|
("Gnome AisleRiot", (
|
||||||
1, 2, 8, 9, 11, 12, 13, 19, 24, 27, 29, 31, 33, 34, 35, 36,
|
1, 2, 8, 9, 11, 12, 13, 19, 24, 27, 29, 31, 33, 34, 35, 36,
|
||||||
38, 40, 41, 42, 43, 45, 48, 58, 65, 67, 89, 91, 92, 93, 94,
|
38, 40, 41, 42, 43, 45, 48, 58, 65, 67, 89, 91, 92, 93, 94,
|
||||||
|
@ -339,7 +338,7 @@ class GI:
|
||||||
146, 147, 148, 200, 201, 206, 224, 225, 229, 230, 233, 257,
|
146, 147, 148, 200, 201, 206, 224, 225, 229, 230, 233, 257,
|
||||||
258, 277, 280, 281, 282, 283, 284, 334, 384, 479, 495, 551,
|
258, 277, 280, 281, 282, 283, 284, 334, 384, 479, 495, 551,
|
||||||
552, 553, 572, 593, 674, 700, 715, 716, 737, 772, 810, 819,
|
552, 553, 572, 593, 674, 700, 715, 716, 737, 772, 810, 819,
|
||||||
824, 829, 22231,
|
824, 829, 859, 22231,
|
||||||
)),
|
)),
|
||||||
|
|
||||||
# Hoyle Card Games
|
# Hoyle Card Games
|
||||||
|
@ -544,7 +543,7 @@ class GI:
|
||||||
tuple(range(22217, 22219))),
|
tuple(range(22217, 22219))),
|
||||||
('fc-2.14', tuple(range(811, 827))),
|
('fc-2.14', tuple(range(811, 827))),
|
||||||
('fc-2.15', tuple(range(827, 855)) + tuple(range(22400, 22407))),
|
('fc-2.15', tuple(range(827, 855)) + tuple(range(22400, 22407))),
|
||||||
('dev', tuple(range(855, 859)))
|
('dev', tuple(range(855, 860)))
|
||||||
)
|
)
|
||||||
|
|
||||||
# deprecated - the correct way is to or a GI.GT_XXX flag
|
# deprecated - the correct way is to or a GI.GT_XXX flag
|
||||||
|
|
|
@ -26,6 +26,7 @@ from pysollib.gamedb import GI, GameInfo, registerGame
|
||||||
from pysollib.hint import CautiousDefaultHint
|
from pysollib.hint import CautiousDefaultHint
|
||||||
from pysollib.layout import Layout
|
from pysollib.layout import Layout
|
||||||
from pysollib.stack import \
|
from pysollib.stack import \
|
||||||
|
BasicRowStack, \
|
||||||
DealRowTalonStack, \
|
DealRowTalonStack, \
|
||||||
InitialDealTalonStack, \
|
InitialDealTalonStack, \
|
||||||
RedealTalonStack, \
|
RedealTalonStack, \
|
||||||
|
@ -33,8 +34,10 @@ from pysollib.stack import \
|
||||||
StackWrapper, \
|
StackWrapper, \
|
||||||
TalonStack, \
|
TalonStack, \
|
||||||
UD_RK_RowStack, \
|
UD_RK_RowStack, \
|
||||||
UD_SS_RowStack
|
UD_SS_RowStack, \
|
||||||
from pysollib.util import ACE, JACK, KING, NO_RANK
|
WasteStack, \
|
||||||
|
WasteTalonStack
|
||||||
|
from pysollib.util import ACE, JACK, KING, NO_RANK, QUEEN
|
||||||
|
|
||||||
|
|
||||||
class StHelena_Talon(TalonStack):
|
class StHelena_Talon(TalonStack):
|
||||||
|
@ -314,6 +317,125 @@ class RegalFamily(Game):
|
||||||
shallHighlightMatch = Game._shallHighlightMatch_SS
|
shallHighlightMatch = Game._shallHighlightMatch_SS
|
||||||
|
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
# * King's Audience
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
class KingsAudience_RowStack(BasicRowStack):
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if len(self.cards) == 0:
|
||||||
|
return from_stack == self.game.s.waste
|
||||||
|
c = self.cards[-1]
|
||||||
|
if cards[0].suit != c.suit:
|
||||||
|
return False
|
||||||
|
if ((cards[0].rank == JACK and c.rank == ACE) or
|
||||||
|
(cards[0].rank == ACE and c.rank == JACK)):
|
||||||
|
return True
|
||||||
|
if ((cards[0].rank == QUEEN and c.rank == KING) or
|
||||||
|
(cards[0].rank == KING and c.rank == QUEEN)):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class KingsAudience_Foundation(SS_FoundationStack):
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
if len(self.cards) == 0:
|
||||||
|
return False
|
||||||
|
return SS_FoundationStack.acceptsCards(self, from_stack, cards)
|
||||||
|
|
||||||
|
|
||||||
|
class KingsAudience(Game):
|
||||||
|
Hint_Class = CautiousDefaultHint
|
||||||
|
|
||||||
|
def createGame(self):
|
||||||
|
# create layout
|
||||||
|
l, s = Layout(self), self.s
|
||||||
|
|
||||||
|
# set window
|
||||||
|
w, h = 3 * l.XM + 6 * l.XS, 3 * l.YM + 6 * l.YS
|
||||||
|
self.setSize(w, h)
|
||||||
|
|
||||||
|
# create stacks
|
||||||
|
lay = (
|
||||||
|
(2, 1, 1, 0),
|
||||||
|
(2, 2, 1, 0),
|
||||||
|
(2, 3, 1, 0),
|
||||||
|
(2, 4, 1, 0),
|
||||||
|
(3, 5, 2, 1),
|
||||||
|
(3, 5, 2, 2),
|
||||||
|
(3, 5, 2, 3),
|
||||||
|
(3, 5, 2, 4),
|
||||||
|
(2, 4, 3, 5),
|
||||||
|
(2, 3, 3, 5),
|
||||||
|
(2, 2, 3, 5),
|
||||||
|
(2, 1, 3, 5),
|
||||||
|
(1, 0, 2, 1),
|
||||||
|
(1, 0, 2, 2),
|
||||||
|
(1, 0, 2, 3),
|
||||||
|
(1, 0, 2, 4),
|
||||||
|
)
|
||||||
|
for xm, xs, ym, ys in lay:
|
||||||
|
x, y = xm * l.XM + xs * l.XS, ym * l.YM + ys * l.YS
|
||||||
|
stack = KingsAudience_RowStack(x, y, self, max_move=1,
|
||||||
|
max_accept=1)
|
||||||
|
stack.CARD_XOFFSET = stack.CARD_YOFFSET = 0
|
||||||
|
s.rows.append(stack)
|
||||||
|
x, y = 2 * l.XM + l.XS, 2 * l.YM + l.YS
|
||||||
|
for i in range(4):
|
||||||
|
s.foundations.append(KingsAudience_Foundation(x, y, self, suit=i,
|
||||||
|
max_cards=2))
|
||||||
|
x = x + l.XS
|
||||||
|
x, y = 2 * l.XM + l.XS, 2 * l.YM + 4 * l.YS
|
||||||
|
for i in range(4):
|
||||||
|
s.foundations.append(KingsAudience_Foundation(x, y, self, suit=i,
|
||||||
|
max_cards=11,
|
||||||
|
dir=-1))
|
||||||
|
x = x + l.XS
|
||||||
|
|
||||||
|
tx = (2 * (l.XM + l.XS))
|
||||||
|
ty = (2 * (l.YM + l.YS))
|
||||||
|
|
||||||
|
s.talon = WasteTalonStack(tx, ty, self, max_rounds=1)
|
||||||
|
l.createText(s.talon, "s")
|
||||||
|
s.waste = WasteStack(tx + l.XS, ty, self)
|
||||||
|
l.createText(s.waste, "s")
|
||||||
|
|
||||||
|
# define stack-groups
|
||||||
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
def fillStack(self, stack):
|
||||||
|
for s in self.s.rows:
|
||||||
|
if len(s.cards) > 1:
|
||||||
|
if not self.demo:
|
||||||
|
self.playSample("droppair", priority=200)
|
||||||
|
old_state = self.enterState(self.S_FILL)
|
||||||
|
if s.cards[0].rank in (KING, QUEEN):
|
||||||
|
s.moveMove(2, self.s.foundations[s.cards[0].suit])
|
||||||
|
elif s.cards[0].rank == ACE:
|
||||||
|
s.moveMove(2, self.s.foundations[s.cards[0].suit + 4])
|
||||||
|
elif s.cards[0].rank == JACK:
|
||||||
|
s.moveMove(1, self.s.foundations[s.cards[0].suit + 4])
|
||||||
|
s.moveMove(1, self.s.foundations[s.cards[0].suit + 4])
|
||||||
|
self.leaveState(old_state)
|
||||||
|
if len(s.cards) == 0:
|
||||||
|
if len(self.s.waste.cards) == 0:
|
||||||
|
self.s.talon.dealCards()
|
||||||
|
if len(self.s.waste.cards) > 0:
|
||||||
|
self.s.waste.moveMove(1, s)
|
||||||
|
|
||||||
|
if len(stack.cards) == 0:
|
||||||
|
if stack is self.s.waste and self.s.talon.cards:
|
||||||
|
self.s.talon.dealCards()
|
||||||
|
elif stack in self.s.rows and self.s.waste.cards:
|
||||||
|
self.s.waste.moveMove(1, stack)
|
||||||
|
|
||||||
|
def startGame(self):
|
||||||
|
self._startAndDealRow()
|
||||||
|
self.s.talon.dealCards()
|
||||||
|
|
||||||
|
shallHighlightMatch = Game._shallHighlightMatch_SS
|
||||||
|
|
||||||
|
|
||||||
# register the game
|
# register the game
|
||||||
registerGame(GameInfo(302, StHelena, "St. Helena",
|
registerGame(GameInfo(302, StHelena, "St. Helena",
|
||||||
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED,
|
GI.GT_2DECK_TYPE, 2, 2, GI.SL_BALANCED,
|
||||||
|
@ -327,3 +449,6 @@ registerGame(GameInfo(620, LesQuatreCoins, "Les Quatre Coins",
|
||||||
"Corner Patience")))
|
"Corner Patience")))
|
||||||
registerGame(GameInfo(621, RegalFamily, "Regal Family",
|
registerGame(GameInfo(621, RegalFamily, "Regal Family",
|
||||||
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
||||||
|
registerGame(GameInfo(859, KingsAudience, "King's Audience",
|
||||||
|
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
|
||||||
|
altnames=("Queen's Audience")))
|
||||||
|
|
Loading…
Add table
Reference in a new issue