mirror of
https://github.com/correl/riichi.git
synced 2024-11-14 11:09:36 +00:00
Dai San Gen
This commit is contained in:
parent
fe32170412
commit
11e2a20eeb
2 changed files with 16 additions and 1 deletions
|
@ -13,7 +13,8 @@
|
|||
pinfu/2,
|
||||
chiitoitsu/2,
|
||||
kokushi_musou/2,
|
||||
ryuu_iisou/2]).
|
||||
ryuu_iisou/2,
|
||||
dai_san_gen/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.
|
||||
|
@ -92,3 +93,9 @@ 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).
|
||||
|
||||
%% @doc Returns true for a Big Three Dragons hand
|
||||
-spec dai_san_gen(game(), player()) -> boolean().
|
||||
dai_san_gen(#game{}, #player{hand=#hand{melds=Melds}}) ->
|
||||
[green, red, white] =:= lists:usort([V || #meld{type=T, tiles=[#tile{suit=dragon, value=V}|_]} <- Melds,
|
||||
lists:member(T, [pon, kan])]).
|
||||
|
|
|
@ -52,3 +52,11 @@ ryuu_iisou_test() ->
|
|||
#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})).
|
||||
|
||||
dai_san_gen_test() ->
|
||||
Hand = #hand{melds=[#meld{type=chii, tiles=[#tile{suit=sou, value=V} || V <- [2,3,4]]},
|
||||
#meld{type=pon, tiles=lists:duplicate(3, #tile{suit=dragon, value=red})},
|
||||
#meld{type=pon, tiles=lists:duplicate(3, #tile{suit=dragon, value=green})},
|
||||
#meld{type=kan, tiles=lists:duplicate(4, #tile{suit=dragon, value=white})},
|
||||
#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=pin, value=1})}]},
|
||||
?assert(yaku:dai_san_gen(#game{}, #player{hand=Hand})).
|
||||
|
|
Loading…
Reference in a new issue