/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/fullflush.cc
Line | Count | Source |
1 | | #include "scoring/yakus/fullflush.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/yaku.h" |
10 | | |
11 | | namespace mahjong::yaku { |
12 | | bool isFullFlush(const GameState& /*state*/, const Hand& hand, |
13 | 54 | const std::vector<const mahjong::Node*>& /*branch*/) { |
14 | 54 | if (hand.live[0].isHonor()) { |
15 | 16 | return false; |
16 | 16 | } |
17 | 38 | const int suit = hand.live[0].getSuit(); |
18 | 272 | for (const auto& piece : hand.live_range()) { |
19 | 272 | if (piece.getSuit() != suit) { |
20 | 36 | return false; |
21 | 36 | } |
22 | 272 | } |
23 | 2 | for (const auto& meld : hand.melds_range()) { |
24 | 1 | if (meld.start.getSuit() != suit) { |
25 | 0 | return false; |
26 | 0 | } |
27 | 1 | } |
28 | 2 | return true; |
29 | 2 | } |
30 | | |
31 | | REGISTER_YAKU({ |
32 | | .id = "fullflush", |
33 | | .name = "Full Flush", |
34 | | .type = Yaku::kBonusWhenClosed, |
35 | | .value = 5, |
36 | | .is_yaku_func = yaku::isFullFlush, |
37 | | }); |
38 | | } // namespace mahjong::yaku |