From a74bff6d8f0adc6aa1b231578adc83078527d796 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 31 Jul 2012 22:23:46 -0400 Subject: [PATCH] Wait detection --- src/riichi_hand.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/riichi_hand.erl b/src/riichi_hand.erl index 7c606e2..d47d74d 100644 --- a/src/riichi_hand.erl +++ b/src/riichi_hand.erl @@ -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)])].