mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added Aces Square game.
This commit is contained in:
parent
71638129e5
commit
ac06c9157d
3 changed files with 61 additions and 1 deletions
22
html-src/rules/acessquare.html
Normal file
22
html-src/rules/acessquare.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<h1>Aces Square</h1>
|
||||
<p>
|
||||
One-Deck game type. 1 deck. No redeal.
|
||||
|
||||
<h3>Object</h3>
|
||||
<p>
|
||||
Move all cards except the four Aces to the single foundation.
|
||||
|
||||
<h3>Rules</h3>
|
||||
<p>
|
||||
Cards are dealt to a square of four rows of four cards each.
|
||||
You can remove pairs of cards of the same suit that are in the
|
||||
same row or column, and do not contain aces. Empty spaces are
|
||||
immediately filled from the talon, and can no longer be filled
|
||||
when they're empty.
|
||||
<p>
|
||||
The game is won when all cards are removed in this way except
|
||||
for the four aces.
|
||||
|
||||
<h3>Notes</h3>
|
||||
<p>
|
||||
<i>Autodrop</i> is disabled for this game.
|
|
@ -559,7 +559,7 @@ class GI:
|
|||
('fc-2.14', tuple(range(811, 827))),
|
||||
('fc-2.15', tuple(range(827, 855)) + tuple(range(22400, 22407))),
|
||||
('fc-2.20', tuple(range(855, 897))),
|
||||
('dev', tuple(range(897, 898)) + tuple(range(13160, 13163)))
|
||||
('dev', tuple(range(897, 899)) + tuple(range(13160, 13163)))
|
||||
)
|
||||
|
||||
# deprecated - the correct way is to or a GI.GT_XXX flag
|
||||
|
|
|
@ -993,6 +993,42 @@ class RightAndLeft(Game):
|
|||
self._startAndDealRow()
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
# * Aces Square
|
||||
# ************************************************************************
|
||||
|
||||
class AcesSquare_RowStack(MonteCarlo_RowStack):
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
if not OpenStack.acceptsCards(self, from_stack, cards):
|
||||
return False
|
||||
if self.cards[-1].rank == 0 or cards[0].rank == 0:
|
||||
return False
|
||||
|
||||
return (self.game.isNeighbour(from_stack, self)
|
||||
and self.cards[-1].suit == cards[0].suit)
|
||||
|
||||
|
||||
class AcesSquare(MonteCarlo):
|
||||
Talon_Class = AutoDealTalonStack
|
||||
RowStack_Class = AcesSquare_RowStack
|
||||
|
||||
def createGame(self):
|
||||
MonteCarlo.createGame(self, rows=4, cols=4)
|
||||
|
||||
def isGameWon(self):
|
||||
return len(self.s.foundations[0].cards) == 48
|
||||
|
||||
def fillStack(self, stack):
|
||||
if stack in self.s.rows:
|
||||
if len(stack.cards) == 0 and len(self.s.talon.cards) > 0:
|
||||
self.flipMove(self.s.talon)
|
||||
self.moveMove(1, self.s.talon, stack)
|
||||
|
||||
def isNeighbour(self, stack1, stack2):
|
||||
return (stack1.id // 4 == stack2.id // 4 or
|
||||
stack1.id % 4 == stack2.id % 4)
|
||||
|
||||
|
||||
# register the game
|
||||
registerGame(GameInfo(89, MonteCarlo, "Monte Carlo",
|
||||
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
|
||||
|
@ -1057,3 +1093,5 @@ registerGame(GameInfo(874, PatientPairs, "Patient Pairs",
|
|||
registerGame(GameInfo(875, PatientPairsOpen, "Patient Pairs (Open)",
|
||||
GI.GT_PAIRING_TYPE | GI.GT_OPEN, 1, 0,
|
||||
GI.SL_MOSTLY_SKILL, rules_filename="patientpairs.html"))
|
||||
registerGame(GameInfo(898, AcesSquare, "Aces Square",
|
||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_BALANCED))
|
||||
|
|
Loading…
Add table
Reference in a new issue