Skip to content

Commit

Permalink
Added Seven Up game.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeraz committed Sep 14, 2023
1 parent 40bd9f0 commit 27e11a6
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
28 changes: 28 additions & 0 deletions html-src/rules/sevenup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h1>Seven Up</h1>
<p>
One-Deck game type. 1 deck. No redeal.

<h3>Object</h3>
<p>
Remove all the cards.

<h3>Rules</h3>
<p>
Cards are dealt from the stock in a sequence. Any sequence of two to four
cards with a total rank of 7, or any multiple of seven, may be removed.
Sevens can be removed singly. Jacks are valued at 11, Queens at 12, and
Kings at 13. The game is won if all cards are removed.
<p>
In PySol, a sequence is removed by selecting the first and last
card of the sequence.

<h3>Notes</h3>
<p>
The average rank of the cards in a deck is 7, and the total of all cards of
each suit is 91, which is a multiple of 7. Thus, the total of all cards in the
entire deck is 364, also a multiple of 7.
<p>
Under the original rules for this game, there was no limit to the number of
cards that could be removed at once. But in this variant, the entire deck
can always be removed in the first move, so most modern variants limit the
number of cards that can be removed at once.
2 changes: 1 addition & 1 deletion pysollib/gamedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,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, 918)) + tuple(range(11017, 11020)) +
('dev', tuple(range(906, 919)) + tuple(range(11017, 11020)) +
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
)

Expand Down
65 changes: 65 additions & 0 deletions pysollib/games/pushpin.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,68 @@ def isGameWon(self):
return len(self.s.foundations[0].cards) == 52


# ************************************************************************
# * Seven Up
# ************************************************************************


# Hint should reveal a valid move, but some intelligence should be added.
class SevenUp_Hint(AbstractHint):

def computeHints(self):
game = self.game
rows = game.s.rows
for i in range(len(rows)):
if rows[i].cards and rows[i].cards[0].rank == 6:
self.addHint(5000, 1, rows[i], self.game.s.foundations[0])
for j in range(i + 1, len(rows)):
total = 0
count = 0
for k in range(i, j):
if self.game.s.rows[k].cards:
total += self.game.s.rows[k].cards[0].rank + 1
count += 1
if total % 7 == 0 and 1 < count <= 4:
self.addHint(5000, 1, rows[i], rows[j - 1])


class SevenUp_RowStack(Decade_RowStack):

def acceptsCards(self, from_stack, cards):
if not self.cards:
return False
firstcard = min(self.id, from_stack.id)
lastcard = max(self.id, from_stack.id) + 1

total = 0
numcards = 0
for x in range(firstcard, lastcard):
total += self.game.s.rows[x].cards[0].rank + 1
numcards += 1

return numcards <= 4 and total % 7 == 0

def _dropSevenClickHandler(self, event):
if not self.cards:
return 0
c = self.cards[-1]
if c.face_up and c.rank == 6:
self.game.playSample("autodrop", priority=20)
self.playMoveMove(1, self.game.s.foundations[0], sound=False)
return 1
return 0

def clickHandler(self, event):
if self._dropSevenClickHandler(event):
return 1
return Decade_RowStack.clickHandler(self, event)


class SevenUp(Decade):
Hint_Class = SevenUp_Hint
RowStack_Class = SevenUp_RowStack


registerGame(GameInfo(287, PushPin, "Push Pin",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
altnames=('Queens')))
Expand All @@ -491,3 +553,6 @@ def isGameWon(self):
altnames=('Ten Twenty Thirty')))
registerGame(GameInfo(883, TwoThreeSkidoo, "23 Skidoo",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_SKILL))
registerGame(GameInfo(918, SevenUp, "Seven Up",
GI.GT_1DECK_TYPE, 1, 0, GI.SL_SKILL,
altnames=('Seventh Wonder', 'The Magic Seven')))

0 comments on commit 27e11a6

Please sign in to comment.