/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/allpons.cc
Line | Count | Source |
1 | | #include "scoring/yakus/allpons.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 isAllPons(const GameState& /* state */, const Hand& hand, |
14 | 12 | const std::vector<const mahjong::Node*>& branch) { |
15 | 12 | int pons = 0; |
16 | 70 | for (const auto* node : branch) { |
17 | 70 | if (node->type() == SetType::kPon) { |
18 | 22 | pons++; |
19 | 22 | } |
20 | 70 | } |
21 | 12 | for (const auto& meld : hand.melds_range()) { |
22 | 2 | if (meld.type == SetType::kKan || meld.type == SetType::kPon || |
23 | 2 | meld.type == SetType::kConcealedKan) { |
24 | 2 | pons++; |
25 | 2 | } |
26 | 2 | } |
27 | 12 | return pons == 4; |
28 | 12 | } |
29 | | |
30 | | REGISTER_YAKU({ |
31 | | .id = "allpons", |
32 | | .name = "All Pons", |
33 | | .type = Yaku::kOpen, |
34 | | .value = 2, |
35 | | .is_yaku_func = yaku::isAllPons, |
36 | | }); |
37 | | } // namespace mahjong::yaku |