open_pql/functions/
wins_hi.rs

1use super::*;
2
3#[pqlfn(arg, rtn, eval)]
4pub fn wins_hi(
5    pid: PQLPlayer,
6    args: (PQLGame, Board, &PlayerHands, &mut BufferRatings),
7) -> PQLBoolean {
8    best_hi_rating(pid, PQLStreet::River, args)
9}
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    #[quickcheck]
16    fn test_wins_hi(hbg: HandBoardGame) {
17        let HandBoardGame {
18            hand: h1,
19            another_hand: h2,
20            board,
21            game,
22            ..
23        } = hbg;
24
25        let mut buf = BufferRatings::new(2);
26        let hands = vec![h1, h2];
27
28        let win_p1 = wins_hi(0.into(), (game, board, &hands, &mut buf));
29        let win_p2 = wins_hi(1.into(), (game, board, &hands, &mut buf));
30
31        let tie_p1 = ties_hi(0.into(), (game, board, &hands, &mut buf));
32        let tie_p2 = ties_hi(1.into(), (game, board, &hands, &mut buf));
33
34        let scp_p1 = scoops(0.into(), (game, board, &hands, &mut buf));
35        let scp_p2 = scoops(1.into(), (game, board, &hands, &mut buf));
36
37        match (win_p1, win_p2) {
38            (true, true) => {
39                assert!(tie_p1);
40                assert!(tie_p2);
41                assert!(!scp_p1);
42                assert!(!scp_p2);
43            }
44            (true, false) => {
45                assert!(!tie_p1);
46                assert!(!tie_p2);
47                assert!(scp_p1);
48                assert!(!scp_p2);
49            }
50            (false, true) => {
51                assert!(!tie_p1);
52                assert!(!tie_p2);
53                assert!(!scp_p1);
54                assert!(scp_p2);
55            }
56            _ => unreachable!(""),
57        }
58    }
59}