Skip to content

Commit

Permalink
Add Eleven Triangle game
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Jul 19, 2024
1 parent b268210 commit 77f1125
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
15 changes: 15 additions & 0 deletions html-src/rules/eleventriangle.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h1>Eleven Triangle</h1>
<p>
Pairing game type. 1 deck. No redeal.

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

<h3>Quick Description</h3>
<p>
Like <a href="triangle.html">Triangle</a>,
but cards are removed that total 11, with face cards
removed in pairs of the same rank. Also, the cards
from the talon are dealt to three waste piles (similar
to <a href="apophis.html">Apophis</a>) with no redeal.
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _callback(gi, gt=game_type):
tuple(range(13168, 13170)) + tuple(range(18000, 18005)) +
tuple(range(19000, 19012)) + tuple(range(22303, 22311)) +
tuple(range(22353, 22361))),
('dev', tuple(range(961, 969))),
('dev', tuple(range(961, 970))),
)

# deprecated - the correct way is to or a GI.GT_XXX flag
Expand Down
65 changes: 58 additions & 7 deletions pysollib/games/pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,35 +1330,47 @@ def acceptsCards(self, from_stack, cards):
class Apophis(Pharaohs):
Hint_Class = Apophis_Hint
RowStack_Class = Apophis_RowStack
Waste_Class = Pyramid_Waste
Foundation_Class = Pyramid_Foundation

PYRAMID_Y_FACTOR = 2
INVERT = False
MAX_ROUNDS = 3

def createGame(self):
# create layout
layout, s = Layout(self), self.s

# set window
w = layout.XM + 9*layout.XS
h = layout.YM + 4*layout.YS
cols = 9
if self.INVERT:
cols = 10
w = layout.XM + cols * layout.XS
h = layout.YM + 4 * layout.YS
self.setSize(w, h)

# create stacks
x, y = layout.XM+1.5*layout.XS, layout.YM
s.rows = self._createPyramid(layout, x, y, 7)
if self.INVERT:
s.rows = self._createInvertedPyramid(layout, x, y, 7)
else:
s.rows = self._createPyramid(layout, x, y, 7)

x, y = layout.XM, layout.YM
s.talon = DealReserveRedealTalonStack(x, y, self, max_rounds=3)
s.talon = DealReserveRedealTalonStack(x, y, self,
max_rounds=self.MAX_ROUNDS)
layout.createText(s.talon, 'se')
layout.createRoundText(s.talon, 'ne')
if s.talon.max_rounds > 1:
layout.createRoundText(s.talon, 'ne')

y += layout.YS
for i in range(3):
stack = Pyramid_Waste(x, y, self, max_accept=1)
stack = self.Waste_Class(x, y, self, max_accept=1)
s.reserves.append(stack)
layout.createText(stack, 'se')
y += layout.YS
x, y = self.width - layout.XS, layout.YM
s.foundations.append(Pyramid_Foundation(x, y, self,
s.foundations.append(self.Foundation_Class(x, y, self,
suit=ANY_SUIT, dir=0, base_rank=ANY_RANK,
max_move=0, max_cards=52))
layout.createText(s.foundations[0], 'nw')
Expand All @@ -1374,6 +1386,43 @@ def startGame(self):
def shallHighlightMatch(self, stack1, card1, stack2, card2):
return card1.rank + card2.rank == 11


# ************************************************************************
# * Eleven Triangle
# ************************************************************************

class ElevenTriangle_StackMethods():
def acceptsCards(self, from_stack, cards):
if self.basicIsBlocked():
return False
if from_stack is self or not self.cards or len(cards) != 1:
return False
c = self.cards[-1]
return c.face_up and cards[0].face_up and \
(cards[0].rank + c.rank == 9 or (cards[0].rank > 9 and
cards[0].rank == c.rank))

def _dropKingClickHandler(self, event):
return 0


class ElevenTriangle_RowStack(ElevenTriangle_StackMethods, Pyramid_RowStack):
pass


class ElevenTriangle_Waste(ElevenTriangle_StackMethods, Pyramid_Waste):
pass


class ElevenTriangle(Apophis):
RowStack_Class = ElevenTriangle_RowStack
Waste_Class = ElevenTriangle_Waste
Foundation_Class = PyramidDozen_Foundation

INVERT = True
MAX_ROUNDS = 1


# ************************************************************************
# * Cheops
# ************************************************************************
Expand Down Expand Up @@ -1876,3 +1925,5 @@ def fillStack(self, stack):
altnames=("Steel Wheels",)))
registerGame(GameInfo(961, Nines, "Nines",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_LUCK))
registerGame(GameInfo(969, ElevenTriangle, "Eleven Triangle",
GI.GT_PAIRING_TYPE, 1, 0, GI.SL_MOSTLY_LUCK))

0 comments on commit 77f1125

Please sign in to comment.