summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-22 18:19:28 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-25 06:43:13 (GMT)
commit13f890e8a64f3808a182ad3039139f8421b46e53 (patch)
tree45cf4ced61208c7b242d6d984f28770f336a9e94
parenta3dc66168ad2ad36584a9cd1de88a2e8107b2a6a (diff)
Blessing rules: add assertions
-rw-r--r--src/rulecode.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rulecode.py b/src/rulecode.py
index ef18219..699ab2c 100644
--- a/src/rulecode.py
+++ b/src/rulecode.py
@@ -1266,7 +1266,12 @@ class TwofoldFortune(RuleCode):
class BlessingOfHeaven(RuleCode):
def appliesToHand(hand):
- return hand.ownWind is East and hand.lastSource is TileSource.East14th
+ if hand.lastSource is not TileSource.East14th:
+ return False
+ if hand.ownWind is not East:
+ return False
+ assert hand.lastTile.isConcealed, '{}: Blessing of Heaven: last tile must be concealed'.format(hand)
+ return True
def selectable(hand):
"""for scoring game"""
@@ -1278,10 +1283,12 @@ class BlessingOfHeaven(RuleCode):
class BlessingOfEarth(RuleCode):
def appliesToHand(hand):
- result = hand.ownWind is not East and hand.lastSource is TileSource.East14th
- if result:
- assert hand.lastTile.isExposed, '{}: Blessing of Earth: last tile must be exposed'.format(hand)
- return result
+ if hand.lastSource is not TileSource.East14th:
+ return False
+ if hand.ownWind is East:
+ return False
+ assert hand.lastTile.isExposed, '{}: Blessing of Earth: last tile must be exposed'.format(hand)
+ return True
def selectable(hand):
"""for scoring game"""