summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2015-11-26 14:05:09 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-06 07:39:24 (GMT)
commit2b4f513371492414294243a22f5df7016fcb704b (patch)
tree53b1be4390f81016d9fb622ce245b1594ee1145d
parent568e651740a0d08ab0a108bc76738587221be250 (diff)
NineGates.rearrange is new
-rw-r--r--src/rulecode.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/rulecode.py b/src/rulecode.py
index b9c98b5..65f4dda 100644
--- a/src/rulecode.py
+++ b/src/rulecode.py
@@ -1063,6 +1063,26 @@ class GatesOfHeaven(StandardMahJongg):
result = Tile.numbers
return {Tile(list(hand.suits)[0], x) for x in result}
+ def rearrange(hand, rest):
+ melds = []
+ for suit in hand.suits:
+ for value in Tile.numbers:
+ tile = Tile(suit, value).concealed
+ if rest.count(tile) == 3 and tile.isTerminal:
+ melds.append(tile.pung)
+ rest.remove(tile)
+ rest.remove(tile)
+ rest.remove(tile)
+ elif rest.count(tile) == 2:
+ melds.append(tile.pair)
+ rest.remove(tile)
+ rest.remove(tile)
+ elif rest.count(tile) == 1:
+ melds.append(tile.single)
+ rest.remove(tile)
+ break
+ yield tuple(melds), tuple(rest)
+
class ThirteenOrphans(RuleCode):