summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-24 12:03:17 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-25 06:43:13 (GMT)
commit1ab4f50c58ff41cce711d586a7c8416908c81ff9 (patch)
treeba22e2934957f3ee9f0768450c659d733eded9cc
parent969267f20af4c4af8cfec32e6935c5d56283e90a (diff)
Hand.__arrange: try to correctly treat lastTile
-rw-r--r--src/hand.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/hand.py b/src/hand.py
index 91cb6fb..19ae13e 100644
--- a/src/hand.py
+++ b/src/hand.py
@@ -622,8 +622,19 @@ class Hand(object):
wonHands = []
lostHands = []
for mjRule, melds in self.__arrangements():
- _ = self.newString(chain(self.melds, melds, self.bonusMelds),
- rest=None, lastMeld=None)
+ allMelds = self.melds[:] + list(melds)
+ lastTile = self.lastTile
+ if self.lastSource and self.lastSource.isDiscarded:
+ lastTile = lastTile.exposed
+ lastMelds = sorted(
+ (x for x in allMelds if not x.isDeclared and lastTile.concealed in x),
+ key=lambda x: len(x)) # pylint: disable=unnecessary-lambda
+ if lastMelds:
+ allMelds.remove(lastMelds[0])
+ allMelds.append(lastMelds[0].exposed)
+ _ = self.newString(
+ chain(allMelds, self.bonusMelds),
+ rest=None, lastTile=lastTile, lastMeld=None)
tryHand = Hand(self.player, _, prevHand=self)
if tryHand.won:
tryHand.mjRule = mjRule