Ryuu Iisou

This commit is contained in:
Correl Roush 2012-08-01 00:29:56 -04:00
parent 4524e2227b
commit fe32170412
2 changed files with 17 additions and 1 deletions

View file

@ -12,7 +12,8 @@
tanyao/2,
pinfu/2,
chiitoitsu/2,
kokushi_musou/2]).
kokushi_musou/2,
ryuu_iisou/2]).
%% @doc Counts the pons/kans of value tiles in a player's hand.
%% Value tiles include all of the dragons, plus the round wind and the player's seat wind.
@ -84,3 +85,10 @@ kokushi_musou(#game{}, #player{hand=#hand{tiles=Tiles, melds=[#meld{type=pair, t
andalso sets:size(sets:from_list([T|Tiles])) =:= 13;
kokushi_musou(#game{}, #player{}) ->
false.
%% @doc Returns true for an all-green hand.
-spec ryuu_iisou(game(), player()) -> boolean().
ryuu_iisou(#game{}, #player{hand=Hand}) ->
Greens = sets:from_list([#tile{suit=sou, value=V} || V <- [2,3,4,6,8]] ++ [#tile{suit=dragon, value=green}]),
Tiles = sets:from_list(riichi_hand:tiles(Hand)),
sets:is_subset(Tiles, Greens).

View file

@ -44,3 +44,11 @@ kokushi_musou_test() ->
Hand = #hand{tiles=?TERMINALS ++ ?HONOURS -- [#tile{suit=pin, value=1}],
melds=[#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=pin, value=1})}]},
?assertEqual(true, yaku:kokushi_musou(#game{}, #player{hand=Hand})).
ryuu_iisou_test() ->
Hand = #hand{melds=[#meld{type=chii, tiles=[#tile{suit=sou, value=V} || V <- [2,3,4]]},
#meld{type=chii, tiles=[#tile{suit=sou, value=V} || V <- [2,3,4]]},
#meld{type=pon, tiles=lists:duplicate(3, #tile{suit=sou, value=6})},
#meld{type=pon, tiles=lists:duplicate(3, #tile{suit=sou, value=8})},
#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=dragon, value=green})}]},
?assert(yaku:ryuu_iisou(#game{}, #player{hand=Hand})).