diff --git a/src/riichi.erl b/src/riichi.erl index ca6a461..f9a54b0 100644 --- a/src/riichi.erl +++ b/src/riichi.erl @@ -103,6 +103,17 @@ score_hand(#hand{}=Hand, BaseFu, Limit) -> _ -> 0 end end, + _Ryuu_Ii_Sou = fun(#hand{}=H) -> + Set = sets:from_list(H#hand.tiles), + Greens = sets:from_list(lists:flatten([ + [#tile{suit=sou, value=V} || V <- [2,3,4,6,8]], + [#tile{suit=dragon, value=green}] + ])), + case sets:is_subset(Set, Greens) of + true -> 13; + _ -> 0 + end + end, _Kokushi_Musou = fun(#hand{}=H) -> Sets = find_sets(H#hand.tiles), Terminals = not lists:any(fun(#tile{value=V}) -> lists:member(V, lists:seq(2,8)) end, H#hand.tiles), diff --git a/test/riichi_tests.erl b/test/riichi_tests.erl index 03c11d0..54e42bc 100644 --- a/test/riichi_tests.erl +++ b/test/riichi_tests.erl @@ -115,3 +115,14 @@ score_hand_kokushi_musou_test() -> [#tile{suit=pin, value=1}]]) }, ?assertEqual(riichi:score_hand(Hand, 30), 8000). + +score_hand_ryuu_ii_sou_test() -> + Hand = #hand{ + tiles = lists:flatten([ + [#tile{suit=sou, value=V} || V <- [2,3,4]], + [#tile{suit=sou, value=V} || V <- [2,3,4]], + lists:duplicate(3, #tile{suit=sou, value=6}), + lists:duplicate(3, #tile{suit=sou, value=8}), + lists:duplicate(2, #tile{suit=dragon, value=green})]) + }, + ?assertEqual(riichi:score_hand(Hand, 30), 8000).