summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2015-11-18 15:38:28 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-25 06:43:14 (GMT)
commitd7e7930d4a56a33e155eec0e2d117cc2e1f283b5 (patch)
tree6884b2327607d9ad6c4bf7d2cd032efb3e6784bf
parentb6fd5ea085087db08a8acb7926a1c86d9fe85ee6 (diff)
NineGates gets its own appliesToHand. No change in behaviour.
-rw-r--r--src/predefined.py4
-rw-r--r--src/rulecode.py22
2 files changed, 18 insertions, 8 deletions
diff --git a/src/predefined.py b/src/predefined.py
index 411ed31..e80dc5c 100644
--- a/src/predefined.py
+++ b/src/predefined.py
@@ -391,7 +391,7 @@ class ClassicalChineseBMJA(ClassicalChinese):
description=originalCall.description)
del self.mjRules['NineGates']
self.mjRules.createRule(
- 'Gates of Heaven', 'FGatesOfHeaven||OBMJA', limits=1,
+ 'Gates of Heaven', 'FGatesOfHeaven', limits=1,
description=m18n('All tiles concealed of same color: Values 1112345678999'
' with one pair from 2 to 8 (last tile from wall or discarded)'))
self.mjRules.createRule(
@@ -458,7 +458,7 @@ class ClassicalChineseBMJA(ClassicalChinese):
'FCallingHand||Ohand=TripleKnitting',
limits=0.2)
self.loserRules.createRule(
- 'Calling for Gates of Heaven', 'FCallingHand||Ohand=GatesofHeaven||OBMJA',
+ 'Calling for Gates of Heaven', 'FCallingHand||Ohand=GatesofHeaven',
limits=0.4)
self.loserRules.createRule(
'Calling for Knitting',
diff --git a/src/rulecode.py b/src/rulecode.py
index b3a98c2..6dda217 100644
--- a/src/rulecode.py
+++ b/src/rulecode.py
@@ -1049,11 +1049,7 @@ class GatesOfHeaven(StandardMahJongg):
if len(values) != 1:
return False
surplus = values[0]
- if 'BMJA' in cls.options:
- return 1 < surplus < 9
- else:
- return hand.lastTile and surplus == hand.lastTile.value
- return True
+ return 1 < surplus < 9
def winningTileCandidates(cls, hand):
result = set()
@@ -1100,7 +1096,21 @@ class GatesOfHeaven(StandardMahJongg):
class NineGates(GatesOfHeaven):
"""as used for Classical Chinese DMJL"""
- pass
+ def appliesToHand(cls, hand):
+ if not cls.maybeCallingOrWon(hand):
+ return False
+ values = hand.values
+ if len(set(values)) < 9 or values.count(1) != 3 or values.count(9) != 3:
+ return False
+ values = list(values[3:-3])
+ for value in Tile.minors:
+ if value in values:
+ values.remove(value)
+ if len(values) != 1:
+ return False
+ surplus = values[0]
+ return hand.lastTile and surplus == hand.lastTile.value
+
class ThirteenOrphans(MJRule):