mirror of
https://github.com/correl/riichi.git
synced 2024-11-23 11:09:56 +00:00
Validate pinfu's open wait requirement
This commit is contained in:
parent
0382253c98
commit
fef579355b
2 changed files with 4 additions and 4 deletions
|
@ -40,15 +40,15 @@ tanyao(#game{}, #player{hand=Hand}) ->
|
||||||
end,
|
end,
|
||||||
riichi_hand:tiles(Hand)).
|
riichi_hand:tiles(Hand)).
|
||||||
|
|
||||||
pinfu(#game{round=Round}, #player{seat=Seat, hand=Hand=#hand{melds=Melds}}) ->
|
pinfu(#game{round=Round}, #player{seat=Seat, hand=Hand=#hand{melds=Melds}, drawn={_, Drawn}}) ->
|
||||||
% TODO: Verify closed, open wait, and pair not round/seat wind
|
|
||||||
Closed = lists:all(fun(T) -> T#tile.from =:= draw end, riichi_hand:tiles(Hand)),
|
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,
|
Chiis = length([M || M = #meld{type=chii} <- Melds]) =:= 4,
|
||||||
#meld{type=pair, tiles=[HeadTile,HeadTile]} = riichi_hand:head(Hand),
|
#meld{type=pair, tiles=[HeadTile,HeadTile]} = riichi_hand:head(Hand),
|
||||||
NonValuePair = HeadTile#tile.value =/= Round
|
NonValuePair = HeadTile#tile.value =/= Round
|
||||||
andalso HeadTile#tile.value =/= Seat
|
andalso HeadTile#tile.value =/= Seat
|
||||||
andalso HeadTile#tile.suit =/= dragon,
|
andalso HeadTile#tile.suit =/= dragon,
|
||||||
Closed and Chiis and NonValuePair.
|
Closed and OpenWait and Chiis and NonValuePair.
|
||||||
|
|
||||||
% 7 Pairs
|
% 7 Pairs
|
||||||
chiitoitsu(#game{}, #player{hand=#hand{tiles=[], melds=Melds}})
|
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=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]]}]},
|
#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() ->
|
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)]},
|
||||||
|
|
Loading…
Reference in a new issue