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