mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added Aces and Kings game.
This commit is contained in:
parent
4ea2c1aa95
commit
040d546174
4 changed files with 133 additions and 1 deletions
27
html-src/rules/acesandkings.html
Normal file
27
html-src/rules/acesandkings.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<h1>Aces and Kings</h1>
|
||||||
|
<p>
|
||||||
|
Two-Deck game type. 2 decks. No redeal.
|
||||||
|
|
||||||
|
<h3>Object</h3>
|
||||||
|
<p>
|
||||||
|
Move all the cards to the foundations.
|
||||||
|
|
||||||
|
<h3>Rules</h3>
|
||||||
|
<p>
|
||||||
|
The four leftmost foundations are built up from ace to king,
|
||||||
|
while the four foundations on the right are built down from
|
||||||
|
king to ace.
|
||||||
|
<p>
|
||||||
|
There are two thirteen card reserves, along with four talon piles.
|
||||||
|
The topmost card of the reserve may be moved to any appropriate
|
||||||
|
foundation, as may any of the talon cards. No building is allowed
|
||||||
|
on the talon, and if a talon card is moved, it is replaced from
|
||||||
|
the top of the stock.
|
||||||
|
<p>
|
||||||
|
Cards are dealt from the stock one at a time. No redeal is allowed.
|
||||||
|
When the stock is empty, any card can be moved to an empty tableau
|
||||||
|
pile.
|
||||||
|
|
||||||
|
<h3>Strategy</h3>
|
||||||
|
Note that you are allowed to move cards from one foundation to
|
||||||
|
another. In fact, it's pretty much necessary to win.
|
|
@ -327,7 +327,7 @@ class GI:
|
||||||
("Bill Taylor", (349,)),
|
("Bill Taylor", (349,)),
|
||||||
("Thomas Warfield", (189, 264, 300, 320, 336, 337, 359,
|
("Thomas Warfield", (189, 264, 300, 320, 336, 337, 359,
|
||||||
415, 427, 458, 495, 496, 497, 508,
|
415, 427, 458, 495, 496, 497, 508,
|
||||||
786, 787)),
|
786, 787, 800)),
|
||||||
)
|
)
|
||||||
|
|
||||||
GAMES_BY_PYSOL_VERSION = (
|
GAMES_BY_PYSOL_VERSION = (
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------##
|
||||||
|
from . import acesandkings # noqa: F401
|
||||||
from . import acesup # noqa: F401
|
from . import acesup # noqa: F401
|
||||||
from . import algerian # noqa: F401
|
from . import algerian # noqa: F401
|
||||||
from . import auldlangsyne # noqa: F401
|
from . import auldlangsyne # noqa: F401
|
||||||
|
|
104
pysollib/games/acesandkings.py
Normal file
104
pysollib/games/acesandkings.py
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||||
|
# Copyright (C) 2005-2009 Skomoroh
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from pysollib.game import Game
|
||||||
|
from pysollib.gamedb import GI, GameInfo, registerGame
|
||||||
|
from pysollib.layout import Layout
|
||||||
|
from pysollib.stack import \
|
||||||
|
BasicRowStack, \
|
||||||
|
OpenStack, \
|
||||||
|
RK_FoundationStack, \
|
||||||
|
WasteStack, \
|
||||||
|
WasteTalonStack
|
||||||
|
from pysollib.util import KING, ACE
|
||||||
|
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
# * Aces and Kings
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
class AcesAndKings_RowStack(BasicRowStack):
|
||||||
|
def acceptsCards(self, from_stack, cards):
|
||||||
|
return len(cards) == 1 and len(self.cards) == 0
|
||||||
|
|
||||||
|
|
||||||
|
class AcesAndKings(Game):
|
||||||
|
#
|
||||||
|
# game layout
|
||||||
|
#
|
||||||
|
def createGame(self, rows=4, max_rounds=1, num_deal=1):
|
||||||
|
# create layout
|
||||||
|
l, s = Layout(self), self.s
|
||||||
|
|
||||||
|
# set window
|
||||||
|
self.setSize(l.XM + (8.5 * l.XS), l.YM + (3 * l.YS))
|
||||||
|
|
||||||
|
# create stacks
|
||||||
|
x, y = l.XM, l.YM
|
||||||
|
for i in range(2):
|
||||||
|
stack = OpenStack(x, y, self)
|
||||||
|
stack.CARD_XOFFSET = l.XOFFSET
|
||||||
|
l.createText(stack, "sw")
|
||||||
|
s.reserves.append(stack)
|
||||||
|
x += 4.5 * l.XS
|
||||||
|
|
||||||
|
x, y = l.XM, y + l.YS
|
||||||
|
for i in range(4):
|
||||||
|
s.foundations.append(RK_FoundationStack(x, y, self, suit=i,
|
||||||
|
base_rank=ACE, dir=1))
|
||||||
|
x = x + l.XS
|
||||||
|
x = x + (l.XS / 2)
|
||||||
|
for i in range(4):
|
||||||
|
s.foundations.append(RK_FoundationStack(x, y, self, suit=i,
|
||||||
|
base_rank=KING, dir=-1))
|
||||||
|
x = x + l.XS
|
||||||
|
x, y = l.XM + l.XS, y + l.YS
|
||||||
|
s.talon = WasteTalonStack(
|
||||||
|
x, y, self, max_rounds=max_rounds, num_deal=num_deal)
|
||||||
|
l.createText(s.talon, "sw")
|
||||||
|
x = x + l.XS
|
||||||
|
s.waste = WasteStack(x, y, self)
|
||||||
|
l.createText(s.waste, "se", text_format="%D")
|
||||||
|
x += 2.5 * l.XS
|
||||||
|
for i in range(rows):
|
||||||
|
s.rows.append(AcesAndKings_RowStack(x, y, self, max_accept=1))
|
||||||
|
x = x + l.XS
|
||||||
|
|
||||||
|
# define stack-groups
|
||||||
|
l.defaultStackGroups()
|
||||||
|
|
||||||
|
def startGame(self):
|
||||||
|
self.startDealSample()
|
||||||
|
for i in range(13):
|
||||||
|
self.s.talon.dealRow(rows=self.s.reserves, frames=0)
|
||||||
|
self.s.talon.dealRow(rows=self.s.rows)
|
||||||
|
self.s.talon.dealCards()
|
||||||
|
|
||||||
|
def fillStack(self, stack):
|
||||||
|
if not stack.cards and stack in self.s.rows and self.s.talon.cards:
|
||||||
|
self.s.talon.moveMove(1, stack)
|
||||||
|
|
||||||
|
|
||||||
|
# register the game
|
||||||
|
registerGame(GameInfo(800, AcesAndKings, "Aces and Kings",
|
||||||
|
GI.GT_2DECK_TYPE, 2, 0, GI.SL_BALANCED))
|
Loading…
Add table
Reference in a new issue