/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/threeconcealedpons.cc
Line | Count | Source |
1 | | #include "scoring/yakus/threeconcealedpons.h" |
2 | | |
3 | | #include <vector> |
4 | | |
5 | | #include "analysis/handnode.h" |
6 | | #include "scoring/yakus.h" |
7 | | #include "types/gamestate.h" |
8 | | #include "types/hand.h" |
9 | | #include "types/sets.h" |
10 | | #include "types/yaku.h" |
11 | | |
12 | | namespace mahjong::yaku { |
13 | | bool isThreeConcealedPons(const GameState& /* state */, const Hand& hand, |
14 | 12 | const std::vector<const mahjong::Node*>& branch) { |
15 | 12 | int concealed_pons = 0; |
16 | 62 | for (const auto* node : branch) { |
17 | 62 | if (node->type() == SetType::kPon) { |
18 | 18 | concealed_pons++; |
19 | 18 | } |
20 | 62 | } |
21 | 12 | for (const auto& meld : hand.melds_range()) { |
22 | 6 | if (meld.type == SetType::kConcealedKan) { |
23 | 0 | concealed_pons++; |
24 | 0 | } |
25 | 6 | } |
26 | 12 | return concealed_pons >= 3; |
27 | 12 | } |
28 | | |
29 | | REGISTER_YAKU({ |
30 | | .id = "threeconcealedpons", |
31 | | .name = "Three Concealed Pons", |
32 | | .type = Yaku::kOpen, |
33 | | .value = 2, |
34 | | .is_yaku_func = yaku::isThreeConcealedPons, |
35 | | }); |
36 | | } // namespace mahjong::yaku |