mirror of
https://github.com/correl/riichi.git
synced 2024-11-23 11:09:56 +00:00
Wait detection
This commit is contained in:
parent
e8b9f10b18
commit
0382253c98
1 changed files with 10 additions and 2 deletions
|
@ -4,6 +4,9 @@
|
|||
|
||||
-compile([export_all]).
|
||||
|
||||
find(#hand{} = Hand) ->
|
||||
%find(lists:sort(Tiles), Hand#hand{tiles=[]}, []);
|
||||
find(lists:sort(tiles(Hand)));
|
||||
find(Tiles) ->
|
||||
find(lists:sort(Tiles), #hand{}, []).
|
||||
|
||||
|
@ -55,9 +58,14 @@ is_complete(#hand{tiles=[], melds=Melds}=Hand) ->
|
|||
length(Melds) =:= 5;
|
||||
7 ->
|
||||
% Must be seven *unique* pairs
|
||||
yaku:chiitoitsu(Hand);
|
||||
yaku:chiitoitsu(#game{}, #player{hand=Hand});
|
||||
_ ->
|
||||
false
|
||||
end;
|
||||
is_complete(#hand{}=Hand) ->
|
||||
yaku:kokushi_musou(Hand).
|
||||
yaku:kokushi_musou(#game{}, #player{hand=Hand}).
|
||||
|
||||
waits(#hand{}=Hand) ->
|
||||
[T || T <- ?TILES,
|
||||
0 < length([H || H <- find(tiles(Hand) ++ [T]),
|
||||
is_complete(H)])].
|
||||
|
|
Loading…
Reference in a new issue