From 96a071fca0128077f7dbacca55ca02af5e9c8395 Mon Sep 17 00:00:00 2001 From: Joe R Date: Tue, 19 Mar 2024 21:37:33 -0400 Subject: [PATCH] Added Fool's Up game. --- html-src/rules/acesup.html | 5 ++++ html-src/rules/foolsup.html | 31 +++++++++++++++++++++ pysollib/gamedb.py | 5 ++-- pysollib/games/special/tarock1.py | 46 ++++++++++++++++++++++++++++++- 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 html-src/rules/foolsup.html diff --git a/html-src/rules/acesup.html b/html-src/rules/acesup.html index 1e44dbb62d..eb8ac9510e 100644 --- a/html-src/rules/acesup.html +++ b/html-src/rules/acesup.html @@ -8,6 +8,7 @@

Object

Rules

+A card is dealt to each of four piles. Any top card that is of lower rank and of the same suit of another top card may be dropped to the foundation. Aces rank high.

@@ -16,6 +17,10 @@

Rules

When no more moves are possible, click on the talon. One card will be added to each of the playing piles. +

+The game is won if all cards have been moved to the foundations, +except the four aces and the fool, which are to be moved to the +separate piles.

Notes

diff --git a/html-src/rules/foolsup.html b/html-src/rules/foolsup.html new file mode 100644 index 0000000000..7aec1b736a --- /dev/null +++ b/html-src/rules/foolsup.html @@ -0,0 +1,31 @@ +

Fool's Up

+

+Tarock type. 1 deck. No redeal. + +

Object

+

+Move all cards except the four Aces and the Fool to the single +foundation. + +

Rules

+

+A card is dealt to each of five piles. +Any top card that is of lower rank and of the same suit of another +top card may be dropped to the foundation. Aces rank high. For +the trumps, the skiz, or the fool, is the highest rank. +

+There is no building on the tableau, except that an empty pile +may be filled with any card. +

+When no more moves are possible, click on the talon. One card will be +added to each of the playing piles. +

+The game is won if all cards have been moved to the foundations, +except the four aces and the fool, which are to be moved to the +separate piles. + +

Notes

+

+Autodrop is disabled for this game. + +This is a tarock deck variant of Aces Up. diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index 42de65be82..b0220a68a1 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -600,8 +600,9 @@ def _callback(gi, gt=game_type): tuple(range(13160, 13163)) + (16682,)), ('dev', tuple(range(906, 959)) + tuple(range(5415, 5419)) + tuple(range(5600, 5624)) + tuple(range(11017, 11020)) + - tuple(range(18000, 18005)) + tuple(range(19000, 19012)) + - tuple(range(22303, 22311)) + tuple(range(22353, 22361))), + tuple(range(13168, 13169)) + tuple(range(18000, 18005)) + + tuple(range(19000, 19012)) + tuple(range(22303, 22311)) + + tuple(range(22353, 22361))), ) # deprecated - the correct way is to or a GI.GT_XXX flag diff --git a/pysollib/games/special/tarock1.py b/pysollib/games/special/tarock1.py index 33a9f70da6..42c1c355de 100644 --- a/pysollib/games/special/tarock1.py +++ b/pysollib/games/special/tarock1.py @@ -22,17 +22,20 @@ # ---------------------------------------------------------------------------## from pysollib.gamedb import GI, GameInfo, registerGame +from pysollib.games.acesup import AcesUp from pysollib.games.special.tarock import AbstractTarockGame, Grasshopper from pysollib.games.threepeaks import Golf_Waste, ThreePeaksNoScore from pysollib.layout import Layout from pysollib.mfxutil import kwdefault from pysollib.stack import \ + AbstractFoundationStack, \ InitialDealTalonStack, \ OpenStack, \ ReserveStack, \ SS_FoundationStack, \ StackWrapper -from pysollib.util import ANY_RANK, NO_RANK, UNLIMITED_ACCEPTS, UNLIMITED_MOVES +from pysollib.util import ACE, ANY_RANK, NO_RANK,\ + UNLIMITED_ACCEPTS, UNLIMITED_MOVES class Tarock_OpenStack(OpenStack): @@ -273,6 +276,46 @@ def shallHighlightMatch(self, stack1, card1, stack2, card2): return False +# ************************************************************************ +# * Fool's Up +# ************************************************************************ + +class FoolsUp_Foundation(AbstractFoundationStack): + def acceptsCards(self, from_stack, cards): + if not AbstractFoundationStack.acceptsCards(self, from_stack, cards): + return False + c = cards[0] + for s in self.game.s.rows: + if s is not from_stack and s.cards and s.cards[-1].suit == c.suit: + if c.suit == 4: + if s.cards[-1].rank > c.rank: + return True + else: + if s.cards[-1].rank > c.rank or s.cards[-1].rank == ACE: + # found a higher rank or an Ace on the row stacks + return c.rank != ACE + return False + + +class FoolsUp(AcesUp): + Foundation_Class = StackWrapper(FoolsUp_Foundation, max_cards=73) + + def createGame(self): + AcesUp.createGame(self, rows=5) + + def isGameWon(self): + if len(self.s.foundations[0].cards) != 73: + return False + for s in self.s.rows: + if len(s.cards) != 1: + return False + if s.cards[0].suit == 4 and s.cards[0].rank != 21: + return False + if s.cards[0].suit < 4 and s.cards[0].rank != ACE: + return False + return True + + # ************************************************************************ # * register the games # ************************************************************************ @@ -294,4 +337,5 @@ def r(id, gameclass, name, game_type, decks, redeals, skill_level): GI.SL_MOSTLY_SKILL) r(13167, Rambling, 'Rambling', GI.GT_TAROCK | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL) +r(13168, FoolsUp, "Fool's Up", GI.GT_TAROCK, 1, 0, GI.SL_LUCK) r(22232, LeGrandeTeton, 'Le Grande Teton', GI.GT_TAROCK, 1, 0, GI.SL_BALANCED)