From 4f66f1bff45acb6e3060a668db99582c7e33ded1 Mon Sep 17 00:00:00 2001 From: skomoroh Date: Sun, 6 Mar 2011 07:55:32 +0000 Subject: [PATCH] + game "Hanoi Sequence" git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@268 efabe8c0-fbe8-4139-b769-b5e6d273206e --- html-src/rules/hanoisequence.html | 23 +++++++++++++++++++++++ pysollib/games/special/hanoi.py | 14 ++++++++++++++ pysollib/games/threepeaks.py | 4 +++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 html-src/rules/hanoisequence.html diff --git a/html-src/rules/hanoisequence.html b/html-src/rules/hanoisequence.html new file mode 100644 index 00000000..4b74e1ea --- /dev/null +++ b/html-src/rules/hanoisequence.html @@ -0,0 +1,23 @@ +

Hanoi Sequence

+

+Puzzle game type. 9 cards. No redeal. + +

Object

+

+Build a pile containing all 9 cards down by sequence. + +

Quick Description

+

+Like Tower of Hanoy, +but build a pile down by sequence. + +

Rules

+

+A card may only be placed onto another card that is of higher rank. +

+Only the top card may be moved, and spaces may be filled +with any single card. + +

Notes

+

+Autodrop is disabled for this game. diff --git a/pysollib/games/special/hanoi.py b/pysollib/games/special/hanoi.py index 4d15bdff..8458dec3 100644 --- a/pysollib/games/special/hanoi.py +++ b/pysollib/games/special/hanoi.py @@ -138,6 +138,17 @@ class HanoiPuzzle6(HanoiPuzzle4): pass +# ************************************************************************ +# * Hanoi Sequence +# ************************************************************************ + +class HanoiSequence(TowerOfHanoy): + def isGameWon(self): + for s in self.s.rows: + if len(s.cards) == len(self.cards) and isRankSequence(s.cards): + return 1 + return 0 + # register the game registerGame(GameInfo(124, TowerOfHanoy, "Tower of Hanoy", GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL, @@ -154,4 +165,7 @@ registerGame(GameInfo(209, HanoiPuzzle6, "Hanoi Puzzle 6", GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL, suits=(2,), ranks=range(6), rules_filename="hanoipuzzle.html")) +registerGame(GameInfo(769, HanoiSequence, "Hanoi Sequence", + GI.GT_PUZZLE_TYPE, 1, 0, GI.SL_SKILL, + suits=(2,), ranks=range(9))) diff --git a/pysollib/games/threepeaks.py b/pysollib/games/threepeaks.py index 975d4ed8..020e6bad 100644 --- a/pysollib/games/threepeaks.py +++ b/pysollib/games/threepeaks.py @@ -203,8 +203,9 @@ class ThreePeaks(Game): return False def getHandScore(self): + # FIXME: bug #2937253 score, i = self.hand_score, 1 - if self.busy: + if 0: #self.busy: return score # First count the empty peaks for r in self.s.rows[:3]: @@ -218,6 +219,7 @@ class ThreePeaks(Game): if self.sequence and len(self.s.waste.cards) - 1: score = score + i * 2 ** int((self.sequence - 1) / 4) self.hand_score = score + #print 'getHandScore: score:', score return score def canUndo(self):