diff --git a/src/riichi.erl b/src/riichi.erl index ad36006..2004548 100644 --- a/src/riichi.erl +++ b/src/riichi.erl @@ -89,6 +89,10 @@ score_hand(#hand{tiles=T, sets=_S}=_H, BaseFu, Limit) -> _DaiSanGen = case sets:is_subset(sets:from_list([{3, #tile{suit=dragon, value=red}}, {3, #tile{suit=dragon, value=white}}, {3, #tile{suit=dragon, value=green}}]), sets:from_list(find_sets(T))) of true -> 13; _ -> 0 + end, + _Kokushi_Musou = case (lists:flatten([lists:duplicate(12, 1), [2]]) == lists:sort([C || {C, _T} <- find_sets(T)])) and (not lists:any(fun(#tile{value=V}) -> lists:member(V, lists:seq(2,8)) end, T)) of + true -> 13; + _ -> 0 end ], score(lists:sum(Fu), lists:sum(Han), Limit). diff --git a/test/riichi_tests.erl b/test/riichi_tests.erl index a602b65..254d2d4 100644 --- a/test/riichi_tests.erl +++ b/test/riichi_tests.erl @@ -93,3 +93,13 @@ score_hand_dai_san_gan_test() -> lists:duplicate(2, #tile{suit=wind, value=north})]) }, ?assertEqual(riichi:score_hand(Hand, 30), 8000). + +score_hand_kokushi_musou_test() -> + Hand = #hand{ + tiles = lists:flatten([ + [#tile{suit=S, value=V} || S <- [pin, sou, man], V <- [1,9]], % Terminals + [#tile{suit=wind, value=V} || V <- [east, south, west, north]], % Winds + [#tile{suit=dragon, value=V} || V <- [red, white, green]], % Dragons + [#tile{suit=pin, value=1}]]) + }, + ?assertEqual(riichi:score_hand(Hand, 30), 8000).