/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/scoring/yakus/fourconcealedpon.cc
Line | Count | Source |
1 | | #include "scoring/yakus/fourconcealedpon.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 isFourConcealedPon(const GameState& state, int player, |
13 | 0 | const std::vector<const mahjong::Node*>& branch) { |
14 | 0 | if (state.hands.at(player).open) { |
15 | 0 | return false; |
16 | 0 | } |
17 | 0 | int concealed_pons = 0; |
18 | 0 | for (const auto* node : branch) { |
19 | 0 | if (node->type() == SetType::kPon) { |
20 | 0 | concealed_pons++; |
21 | 0 | } |
22 | 0 | } |
23 | 0 | for (const auto& meld : state.hands.at(player).melds) { |
24 | 0 | if (meld.type == SetType::kConcealedKan) { |
25 | 0 | concealed_pons++; |
26 | 0 | } |
27 | 0 | } |
28 | 0 | return concealed_pons == 4; |
29 | 0 | } |
30 | | |
31 | | REGISTER_YAKU({ |
32 | | .id = "fourconcealedpon", |
33 | | .name = "Four Concealed Pon", |
34 | | .type = Yaku::kYakuman, |
35 | | .value = 13, |
36 | | .is_yaku_func = yaku::isFourConcealedPon, |
37 | | }); |
38 | | } // namespace mahjong::yaku |