Skip to content

Commit

Permalink
Added Fool's Up game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Mar 20, 2024
1 parent de50c45 commit 96a071f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
5 changes: 5 additions & 0 deletions html-src/rules/acesup.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h3>Object</h3>

<h3>Rules</h3>
<p>
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.
<p>
Expand All @@ -16,6 +17,10 @@ <h3>Rules</h3>
<p>
When no more moves are possible, click on the talon. One card will be
added to each of the playing piles.
<p>
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.

<h3>Notes</h3>
<p>
Expand Down
31 changes: 31 additions & 0 deletions html-src/rules/foolsup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h1>Fool's Up</h1>
<p>
Tarock type. 1 deck. No redeal.

<h3>Object</h3>
<p>
Move all cards except the four Aces and the Fool to the single
foundation.

<h3>Rules</h3>
<p>
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.
<p>
There is no building on the tableau, except that an empty pile
may be filled with any card.
<p>
When no more moves are possible, click on the talon. One card will be
added to each of the playing piles.
<p>
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.

<h3>Notes</h3>
<p>
<i>Autodrop</i> is disabled for this game.

This is a tarock deck variant of <a href="acesup.html">Aces Up</a>.
5 changes: 3 additions & 2 deletions pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 45 additions & 1 deletion pysollib/games/special/tarock1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
# ************************************************************************
Expand All @@ -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)

0 comments on commit 96a071f

Please sign in to comment.