mirror of
https://github.com/correl/riichi.git
synced 2024-11-23 11:09:56 +00:00
San kan tsu
This commit is contained in:
parent
5540ffe974
commit
a94e1a4e8d
2 changed files with 15 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
chiitoitsu/2,
|
chiitoitsu/2,
|
||||||
san_shoku_doujun/2,
|
san_shoku_doujun/2,
|
||||||
san_shoku_douko/2,
|
san_shoku_douko/2,
|
||||||
|
san_kan_tsu/2,
|
||||||
kokushi_musou/2,
|
kokushi_musou/2,
|
||||||
ryuu_iisou/2,
|
ryuu_iisou/2,
|
||||||
dai_san_gen/2]).
|
dai_san_gen/2]).
|
||||||
|
@ -140,6 +141,12 @@ san_shoku_douko(#game{}, #player{hand=#hand{melds=Melds}=Hand}) ->
|
||||||
Pons = [M || #meld{type=pon} = M <- Melds],
|
Pons = [M || #meld{type=pon} = M <- Melds],
|
||||||
lists:any(fun(M) -> san_shoku(M, Hand) end, Pons).
|
lists:any(fun(M) -> san_shoku(M, Hand) end, Pons).
|
||||||
|
|
||||||
|
%% @doc Returns true for a San kan tsu hand
|
||||||
|
%% Hand must contain three kans
|
||||||
|
san_kan_tsu(#game{}, #player{hand=#hand{melds=Melds}}) ->
|
||||||
|
Kans = [M || M = #meld{type=kan} <- Melds],
|
||||||
|
length(Kans) =:= 3.
|
||||||
|
|
||||||
%% @doc Returns true for a 7-pair hand.
|
%% @doc Returns true for a 7-pair hand.
|
||||||
-spec chiitoitsu(game(), player()) -> boolean().
|
-spec chiitoitsu(game(), player()) -> boolean().
|
||||||
chiitoitsu(#game{}, #player{hand=#hand{tiles=[], melds=Melds}})
|
chiitoitsu(#game{}, #player{hand=#hand{tiles=[], melds=Melds}})
|
||||||
|
|
|
@ -76,6 +76,14 @@ san_shoku_douko_test() ->
|
||||||
#meld{type=chii, tiles=[#tile{suit=man, value=V} || V <- [6,7,8]]}]},
|
#meld{type=chii, tiles=[#tile{suit=man, value=V} || V <- [6,7,8]]}]},
|
||||||
?assertEqual(true, yaku:san_shoku_douko(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=dragon, value=red}}})).
|
?assertEqual(true, yaku:san_shoku_douko(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=dragon, value=red}}})).
|
||||||
|
|
||||||
|
san_kan_tsu_test() ->
|
||||||
|
Hand = #hand{melds=[#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=sou, value=8})},
|
||||||
|
#meld{type=kan, tiles=[#tile{suit=sou, value=V} || V <- [1,1,1,1]]},
|
||||||
|
#meld{type=kan, tiles=[#tile{suit=man, value=V} || V <- [1,1,1,1]]},
|
||||||
|
#meld{type=kan, tiles=[#tile{suit=pin, value=V} || V <- [1,1,1,1]]},
|
||||||
|
#meld{type=chii, tiles=[#tile{suit=man, value=V} || V <- [6,7,8]]}]},
|
||||||
|
?assertEqual(true, yaku:san_kan_tsu(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=dragon, value=red}}})).
|
||||||
|
|
||||||
chiitoitsu_test() ->
|
chiitoitsu_test() ->
|
||||||
Hand = #hand{melds=[#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=pin, value=V})} || V <- lists:seq(1,7)]},
|
Hand = #hand{melds=[#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=pin, value=V})} || V <- lists:seq(1,7)]},
|
||||||
?assertEqual(true, yaku:chiitoitsu(#game{}, #player{hand=Hand})).
|
?assertEqual(true, yaku:chiitoitsu(#game{}, #player{hand=Hand})).
|
||||||
|
|
Loading…
Reference in a new issue