summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2015-11-27 16:48:36 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-25 06:41:37 (GMT)
commite2c5a2dace10563166af06f1bf3fa46b6dd0e5a7 (patch)
tree69660d0e581d1157a0b97314777c15fc8db94d86
parentd383d05bdb61f3c93055b6caac1b4ee41a29a601 (diff)
Hand.__init__: simplify assertions around Hand.lastTile
-rw-r--r--src/hand.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/hand.py b/src/hand.py
index aa3c0c1..b307f0b 100644
--- a/src/hand.py
+++ b/src/hand.py
@@ -186,15 +186,16 @@ class Hand(object):
if len(tileStrings):
self.__rest.extend(TileList(tileStrings[0][1:]))
- if self.__lastTile:
- assert self.__lastTile.isBonus or self.__lastTile in self.tiles, \
- 'lastTile %s is not in hand %s' % (self.__lastTile, str(self))
+ last = self.__lastTile
+ if last and not last.isBonus:
+ assert last in self.tiles, \
+ 'lastTile %s is not in hand %s' % (last, str(self))
if self.__lastSource == 'k':
- assert self.tiles.count(self.__lastTile.exposed) + \
- self.tiles.count(self.__lastTile.concealed) == 1, (
+ assert self.tiles.count(last.exposed) + \
+ self.tiles.count(last.concealed) == 1, (
'Robbing kong: I cannot have '
'lastTile %s more than once in %s' % (
- self.__lastTile, ' '.join(self.tiles)))
+ last, ' '.join(self.tiles)))
@property
def arranged(self):