/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-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/sets.h" |
9 | | #include "types/yaku.h" |
10 | | |
11 | | namespace mahjong::yaku { |
12 | | bool isAllPons(const GameState& state, int player, |
13 | 11 | const std::vector<const mahjong::Node*>& branch) { |
14 | 11 | int pons = 0; |
15 | 65 | for (const auto* node : branch) { |
16 | 65 | if (node->type() == SetType::kPon) { |
17 | 22 | pons++; |
18 | 22 | } |
19 | 65 | } |
20 | 11 | for (const auto& meld : state.hands.at(player).melds) { |
21 | 2 | if (meld.type == SetType::kKan || meld.type == SetType::kPon || |
22 | 2 | meld.type == SetType::kConcealedKan) { |
23 | 2 | pons++; |
24 | 2 | } |
25 | 2 | } |
26 | 11 | return pons == 4; |
27 | 11 | } |
28 | | |
29 | | REGISTER_YAKU({ |
30 | | .id = "allpons", |
31 | | .name = "All Pons", |
32 | | .type = Yaku::kOpen, |
33 | | .value = 2, |
34 | | .is_yaku_func = yaku::isAllPons, |
35 | | }); |
36 | | } // namespace mahjong::yaku |