/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/scoring/yakus/sevenpairs.cc
Line | Count | Source |
1 | | #include "scoring/yakus/sevenpairs.h" |
2 | | |
3 | | #include <set> |
4 | | #include <vector> |
5 | | |
6 | | #include "analysis/handnode.h" |
7 | | #include "scoring/yakus.h" |
8 | | #include "types/gamestate.h" |
9 | | #include "types/piecetype.h" |
10 | | #include "types/sets.h" |
11 | | #include "types/yaku.h" |
12 | | |
13 | | namespace mahjong::yaku { |
14 | | bool isSevenPairs(const GameState& state, int player, |
15 | 4 | const std::vector<const mahjong::Node*>& branch) { |
16 | 4 | if (state.hands[player].open) { |
17 | 1 | return false; |
18 | 1 | } |
19 | 3 | std::set<Piece> pairs; |
20 | 20 | for (const auto* node : branch) { |
21 | 20 | switch (node->type()) { |
22 | 0 | case SetType::kChi: |
23 | 1 | case SetType::kPon: |
24 | 1 | case SetType::kConcealedKan: |
25 | 1 | case SetType::kKan: |
26 | 1 | case SetType::kSingle: |
27 | 1 | return false; |
28 | 19 | case SetType::kPair: |
29 | 19 | pairs.insert(node->start()); |
30 | 20 | } |
31 | 20 | } |
32 | 2 | return pairs.size() == 7; |
33 | 3 | } |
34 | | |
35 | | REGISTER_YAKU({ |
36 | | .id = "sevenpairs", |
37 | | .name = "Seven Pairs", |
38 | | .type = Yaku::kClosed, |
39 | | .value = 2, |
40 | | .is_yaku_func = yaku::isSevenPairs, |
41 | | }); |
42 | | } // namespace mahjong::yaku |