mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added Seven Up game.
This commit is contained in:
parent
40bd9f0093
commit
27e11a6a4f
3 changed files with 94 additions and 1 deletions
28
html-src/rules/sevenup.html
Normal file
28
html-src/rules/sevenup.html
Normal file
|
@ -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.
|
|
@ -575,7 +575,7 @@ class GI:
|
||||||
('fc-2.20', tuple(range(855, 897))),
|
('fc-2.20', tuple(range(855, 897))),
|
||||||
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
|
('fc-2.21', tuple(range(897, 900)) + tuple(range(11014, 11017)) +
|
||||||
tuple(range(13160, 13163)) + (16682,)),
|
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))),
|
tuple(range(22303, 22311)) + tuple(range(22353, 22361))),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -470,6 +470,68 @@ class Decade(PushPin):
|
||||||
return len(self.s.foundations[0].cards) == 52
|
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",
|
registerGame(GameInfo(287, PushPin, "Push Pin",
|
||||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
|
GI.GT_1DECK_TYPE, 1, 0, GI.SL_MOSTLY_LUCK,
|
||||||
altnames=('Queens')))
|
altnames=('Queens')))
|
||||||
|
@ -491,3 +553,6 @@ registerGame(GameInfo(816, Decade, "Decade",
|
||||||
altnames=('Ten Twenty Thirty')))
|
altnames=('Ten Twenty Thirty')))
|
||||||
registerGame(GameInfo(883, TwoThreeSkidoo, "23 Skidoo",
|
registerGame(GameInfo(883, TwoThreeSkidoo, "23 Skidoo",
|
||||||
GI.GT_1DECK_TYPE, 1, 0, GI.SL_SKILL))
|
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')))
|
||||||
|
|
Loading…
Add table
Reference in a new issue