/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/threekans.cc
Line | Count | Source |
1 | | #include "scoring/yakus/threekans.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 isThreeKans(const GameState& /* state */, const Hand& hand, |
14 | 8 | const std::vector<const mahjong::Node*>& /*branch*/) { |
15 | 8 | int kans = 0; |
16 | 18 | for (const auto& meld : hand.melds_range()) { |
17 | 18 | if (meld.type >= SetType::kKan) { |
18 | 17 | kans++; |
19 | 17 | } |
20 | 18 | } |
21 | 8 | return kans >= 3; |
22 | 8 | } |
23 | | |
24 | | REGISTER_YAKU({ |
25 | | .id = "threekans", |
26 | | .name = "Three Kans", |
27 | | .type = Yaku::kOpen, |
28 | | .value = 2, |
29 | | .is_yaku_func = yaku::isThreeKans, |
30 | | }); |
31 | | } // namespace mahjong::yaku |