/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/maxbranches.cc
Line | Count | Source |
1 | | #include "scoring/yakus/maxbranches.h" |
2 | | |
3 | | #include <array> |
4 | | #include <vector> |
5 | | |
6 | | #include "analysis/handnode.h" |
7 | | #include "types/gamestate.h" |
8 | | #include "types/hand.h" |
9 | | #include "types/sets.h" |
10 | | |
11 | | namespace mahjong::yaku { |
12 | | bool isMaxBranches(const GameState& /*state*/, const Hand& hand, |
13 | 0 | const std::vector<const mahjong::Node*>& /*branch*/) { |
14 | 0 | const int start = hand.live[0].getPieceNum(); |
15 | 0 | const int suit = hand.live[0].getSuit(); |
16 | 0 | std::array<int, 6> sets = {}; |
17 | 0 | const std::array<int, 6> final = {3, 3, 2, 2, 2, 2}; |
18 | 0 | for (const auto& piece : hand.live_range()) { |
19 | 0 | if (piece.getSuit() != suit) { |
20 | 0 | return false; |
21 | 0 | } |
22 | 0 | if (piece.getPieceNum() < start || piece.getPieceNum() > start + 5) { |
23 | 0 | return false; |
24 | 0 | } |
25 | 0 | sets.at(piece.getPieceNum() - start)++; |
26 | 0 | } |
27 | 0 | for (const auto& meld : hand.melds_range()) { |
28 | 0 | if (meld.start.getSuit() != suit) { |
29 | 0 | return false; |
30 | 0 | } |
31 | 0 | if (meld.start.getPieceNum() < start || |
32 | 0 | meld.start.getPieceNum() > start + 3) { |
33 | 0 | return false; |
34 | 0 | } |
35 | 0 | if (meld.type >= SetType::kKan) { |
36 | 0 | if (meld.start.getPieceNum() != start && |
37 | 0 | meld.start.getPieceNum() != start + 1) { |
38 | 0 | return false; |
39 | 0 | } |
40 | 0 | sets.at(meld.start.getPieceNum() - start) += 3; |
41 | 0 | } |
42 | 0 | if (meld.type == SetType::kPon) { |
43 | 0 | sets.at(meld.start.getPieceNum() - start) += 3; |
44 | 0 | } |
45 | 0 | if (meld.type == SetType::kChi) { |
46 | 0 | sets.at(meld.start.getPieceNum() - start)++; |
47 | 0 | sets.at(meld.start.getPieceNum() - start + 1)++; |
48 | 0 | sets.at(meld.start.getPieceNum() - start + 2)++; |
49 | 0 | } |
50 | 0 | } |
51 | 0 | for (int i = 0; i < 6; i++) { |
52 | 0 | if (sets.at(i) != final.at(i)) { |
53 | 0 | return false; |
54 | 0 | } |
55 | 0 | } |
56 | 0 | return true; |
57 | 0 | } |
58 | | |
59 | | // REGISTER_YAKU({ |
60 | | // .id = "maxbranches", |
61 | | // .name = "Max Branches", |
62 | | // .type = Yaku::kYakuman, |
63 | | // .value = 13, |
64 | | // .is_yaku_func = yaku::isMaxBranches, |
65 | | // }); |
66 | | } // namespace mahjong::yaku |