Skip to content

Commit

Permalink
Added Obstruction game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Mar 29, 2024
1 parent 71e06d4 commit 9f78391
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
23 changes: 23 additions & 0 deletions html-src/rules/obstruction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1>Obstruction</h1>
<p>
FreeCell type. 1 joker deck. No redeal.

<h3>Object</h3>
<p>
Move all cards to the foundations.

<h3>Quick Description</h3>
<p>
Like <a href="freecell.html">FreeCell</a>,
but with two jokers. The jokers are obstacles - they can
only be moved to the free cells, and any cards behind them
are blocked until you do. Once there, the jokers can only be
moved to the joker foundation, and only once all other cards
have been moved to the foundations.

<h3>Notes</h3>
<p>
Obstruction is an original game by PySol developer Joe R. It
is designed as a more strategic version of Michael Keller's
Ephemeral FreeCell, requiring the player to block two of the
free cells as the game progresses.
3 changes: 2 additions & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def _callback(gi, gt=game_type):
845)),
("Toby Ord", (788,)),
("David Parlett", (64, 98, 294, 338, 654, 796, 812, 844)),
("Joe R.", (938, 960,)),
("Randy Rasa", (187, 188, 190, 191, 192,)),
("Gregg Seelhoff", (347,)),
("Adam Selene", (366,)),
Expand Down Expand Up @@ -598,7 +599,7 @@ def _callback(gi, gt=game_type):
('fc-2.20', tuple(range(855, 897))),
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
tuple(range(13160, 13163)) + (16682,)),
('dev', tuple(range(906, 960)) + tuple(range(5415, 5419)) +
('dev', tuple(range(906, 961)) + tuple(range(5415, 5419)) +
tuple(range(5600, 5624)) + tuple(range(11017, 11020)) +
tuple(range(13168, 13170)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
Expand Down
42 changes: 42 additions & 0 deletions pysollib/games/freecell.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,45 @@ def startGame(self):
self.s.talon.dealRow(rows=self.s.reserves)


# ************************************************************************
# * Obstruction
# ************************************************************************

class Obstruction_RowStack(SuperMoveAC_RowStack):
def acceptsCards(self, from_stack, cards):
if not self.basicAcceptsCards(from_stack, cards):
return 0
if cards[0].suit == 4:
return 0
stackcards = self.cards
if stackcards:
if stackcards[-1].suit == 4:
return 0
return AC_RowStack.acceptsCards(self, from_stack, cards)


class Obstruction_Foundation(SS_FoundationStack):
def acceptsCards(self, from_stack, cards):
if self.cap.suit == 4 and cards[0].suit == 4:
for s in self.game.s.foundations[:3]:
if len(s.cards) != 13:
return 0
return 1
return SS_FoundationStack.acceptsCards(self, from_stack, cards)


class Obstruction(FreeCell):
Foundation_Class = Obstruction_Foundation
RowStack_Class = Obstruction_RowStack
Solver_Class = None

def startGame(self):
self._startDealNumRows(5)
self.s.talon.dealRow()
r = self.s.rows
self.s.talon.dealRow(rows=r[:6])


# ************************************************************************
# * Petal
# ************************************************************************
Expand Down Expand Up @@ -762,3 +801,6 @@ def createGame(self):
GI.GT_FREECELL | GI.GT_OPEN, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(953, Petal, "Petal",
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(960, Obstruction, "Obstruction",
GI.GT_FREECELL | GI.GT_OPEN, 1, 0, GI.SL_MOSTLY_SKILL,
subcategory=GI.GS_JOKER_DECK, trumps=list(range(2))))

0 comments on commit 9f78391

Please sign in to comment.