mirror of
https://github.com/correl/riichi.git
synced 2024-11-23 11:09:56 +00:00
Toi toi
This commit is contained in:
parent
a94e1a4e8d
commit
7e0315bd29
2 changed files with 17 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
||||||
san_shoku_doujun/2,
|
san_shoku_doujun/2,
|
||||||
san_shoku_douko/2,
|
san_shoku_douko/2,
|
||||||
san_kan_tsu/2,
|
san_kan_tsu/2,
|
||||||
|
toi_toi/2,
|
||||||
kokushi_musou/2,
|
kokushi_musou/2,
|
||||||
ryuu_iisou/2,
|
ryuu_iisou/2,
|
||||||
dai_san_gen/2]).
|
dai_san_gen/2]).
|
||||||
|
@ -147,6 +148,13 @@ san_kan_tsu(#game{}, #player{hand=#hand{melds=Melds}}) ->
|
||||||
Kans = [M || M = #meld{type=kan} <- Melds],
|
Kans = [M || M = #meld{type=kan} <- Melds],
|
||||||
length(Kans) =:= 3.
|
length(Kans) =:= 3.
|
||||||
|
|
||||||
|
%% @doc Returns true for a Toi toi hand
|
||||||
|
%% Hand must contain all triplets
|
||||||
|
toi_toi(#game{}, #player{hand=#hand{melds=Melds}}) ->
|
||||||
|
Pons = [M || M = #meld{type=T} <- Melds,
|
||||||
|
lists:member(T, [pon,kan])],
|
||||||
|
length(Pons) =:= 4.
|
||||||
|
|
||||||
%% @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}})
|
||||||
|
|
|
@ -84,6 +84,15 @@ san_kan_tsu_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_kan_tsu(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=dragon, value=red}}})).
|
?assertEqual(true, yaku:san_kan_tsu(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=dragon, value=red}}})).
|
||||||
|
|
||||||
|
toi_toi_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=pon, tiles=[#tile{suit=pin, value=V} || V <- [2,2,2]]},
|
||||||
|
#meld{type=pon, tiles=[#tile{suit=pin, value=V} || V <- [8,8,8]]}]},
|
||||||
|
?assertEqual(true, yaku:toi_toi(#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