diff --git a/html-src/rules/sevenup.html b/html-src/rules/sevenup.html new file mode 100644 index 000000000..8bcaac025 --- /dev/null +++ b/html-src/rules/sevenup.html @@ -0,0 +1,28 @@ +

Seven Up

+

+One-Deck game type. 1 deck. No redeal. + +

Object

+

+Remove all the cards. + +

Rules

+

+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. +

+In PySol, a sequence is removed by selecting the first and last +card of the sequence. + +

Notes

+

+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. +

+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. diff --git a/pysollib/gamedb.py b/pysollib/gamedb.py index d03f6db39..c66f14521 100644 --- a/pysollib/gamedb.py +++ b/pysollib/gamedb.py @@ -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))), ) diff --git a/pysollib/games/pushpin.py b/pysollib/games/pushpin.py index 699e4fcc8..b813738f6 100644 --- a/pysollib/games/pushpin.py +++ b/pysollib/games/pushpin.py @@ -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'))) @@ -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')))