/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/scoring/yakus/bigthreedragons.cc
Line | Count | Source |
1 | | #include "scoring/yakus/bigthreedragons.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 isBigThreeDragons(const GameState& state, int player, |
13 | 0 | const std::vector<const mahjong::Node*>& branch) { |
14 | 0 | int pons = 0; |
15 | 0 | for (const auto* node : branch) { |
16 | 0 | switch (node->start().toUint8_t()) { |
17 | 0 | case Piece::Type::kRedDragon: |
18 | 0 | case Piece::Type::kGreenDragon: |
19 | 0 | case Piece::Type::kWhiteDragon: |
20 | 0 | break; |
21 | 0 | default: |
22 | 0 | continue; |
23 | 0 | } |
24 | 0 | if (node->type() == SetType::kPair) { |
25 | 0 | return false; |
26 | 0 | } |
27 | 0 | pons++; |
28 | 0 | } |
29 | 0 | for (const auto& meld : state.hands.at(player).melds) { |
30 | 0 | switch (meld.start.toUint8_t()) { |
31 | 0 | case Piece::Type::kRedDragon: |
32 | 0 | case Piece::Type::kGreenDragon: |
33 | 0 | case Piece::Type::kWhiteDragon: |
34 | 0 | break; |
35 | 0 | default: |
36 | 0 | continue; |
37 | 0 | } |
38 | 0 | pons++; |
39 | 0 | } |
40 | 0 | return pons == 3; |
41 | 0 | } |
42 | | |
43 | | REGISTER_YAKU({ |
44 | | .id = "bigthreedragons", |
45 | | .name = "Big Three Dragons", |
46 | | .type = Yaku::kYakuman, |
47 | | .value = 1, |
48 | | .is_yaku_func = yaku::isBigThreeDragons, |
49 | | }); |
50 | | } // namespace mahjong::yaku |