mirror of
https://github.com/correl/riichi.git
synced 2024-11-27 11:09:56 +00:00
Validate pinfu's open wait requirement
This commit is contained in:
parent
a74bff6d8f
commit
0e7c551723
2 changed files with 4 additions and 4 deletions
|
@ -40,15 +40,15 @@ tanyao(#game{}, #player{hand=Hand}) ->
|
|||
end,
|
||||
riichi_hand:tiles(Hand)).
|
||||
|
||||
pinfu(#game{round=Round}, #player{seat=Seat, hand=Hand=#hand{melds=Melds}}) ->
|
||||
% TODO: Verify closed, open wait, and pair not round/seat wind
|
||||
pinfu(#game{round=Round}, #player{seat=Seat, hand=Hand=#hand{melds=Melds}, drawn={_, Drawn}}) ->
|
||||
Closed = lists:all(fun(T) -> T#tile.from =:= draw end, riichi_hand:tiles(Hand)),
|
||||
OpenWait = length(riichi_hand:waits(#hand{tiles=riichi_hand:tiles(Hand) -- [Drawn]})) > 1,
|
||||
Chiis = length([M || M = #meld{type=chii} <- Melds]) =:= 4,
|
||||
#meld{type=pair, tiles=[HeadTile,HeadTile]} = riichi_hand:head(Hand),
|
||||
NonValuePair = HeadTile#tile.value =/= Round
|
||||
andalso HeadTile#tile.value =/= Seat
|
||||
andalso HeadTile#tile.suit =/= dragon,
|
||||
Closed and Chiis and NonValuePair.
|
||||
Closed and OpenWait and Chiis and NonValuePair.
|
||||
|
||||
% 7 Pairs
|
||||
chiitoitsu(#game{}, #player{hand=#hand{tiles=[], melds=Melds}})
|
||||
|
|
|
@ -34,7 +34,7 @@ pinfu_test() ->
|
|||
#meld{type=chii, tiles=[#tile{suit=sou, value=V} || V <- [4,5,6]]},
|
||||
#meld{type=chii, tiles=[#tile{suit=sou, value=V} || V <- [4,5,6]]},
|
||||
#meld{type=chii, tiles=[#tile{suit=man, value=V} || V <- [6,7,8]]}]},
|
||||
?assertEqual(true, yaku:pinfu(#game{}, #player{hand=Hand})).
|
||||
?assertEqual(true, yaku:pinfu(#game{}, #player{hand=Hand, drawn={tsumo, #tile{suit=sou, value=6}}})).
|
||||
|
||||
chiitoitsu_test() ->
|
||||
Hand = #hand{melds=[#meld{type=pair, tiles=lists:duplicate(2, #tile{suit=pin, value=V})} || V <- lists:seq(1,7)]},
|
||||
|
|
Loading…
Reference in a new issue