Coverage Report

Created: 2026-11-14 03:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/nix/store/rr0r40cw3mzzbz0sxrnkvnrjpzb82wpc-j27cjzgh5nmq3y8k6hwa6zpi3qgcjia8-source/src/scoring/yakus/mixedtriplechi.cc
Line
Count
Source
1
#include "scoring/yakus/mixedtriplechi.h"
2
3
#include <array>
4
#include <vector>
5
6
#include "analysis/handnode.h"
7
#include "scoring/yakus.h"
8
#include "types/gamestate.h"
9
#include "types/hand.h"
10
#include "types/sets.h"
11
#include "types/yaku.h"
12
13
namespace mahjong::yaku {
14
bool isMixedTripleChi(const GameState& /* state */, const Hand& hand,
15
7
                      const std::vector<const mahjong::Node*>& branch) {
16
7
  const int k_piecesinasuit = 9;
17
7
  std::array<bool, k_piecesinasuit> bamboo_chi = {};
18
7
  std::array<bool, k_piecesinasuit> char_chi = {};
19
7
  std::array<bool, k_piecesinasuit> pin_chi = {};
20
39
  for (const auto* node : branch) {
21
39
    if (node->type() == SetType::kChi) {
22
18
      if (node->start().getSuit() == Piece::Type::kBambooSuit) {
23
8
        bamboo_chi.at(node->start().getPieceNum()) = true;
24
8
      }
25
18
      if (node->start().getSuit() == Piece::Type::kCharacterSuit) {
26
3
        char_chi.at(node->start().getPieceNum()) = true;
27
3
      }
28
18
      if (node->start().getSuit() == Piece::Type::kPinSuit) {
29
7
        pin_chi.at(node->start().getPieceNum()) = true;
30
7
      }
31
18
    }
32
39
  }
33
7
  for (const auto& meld : hand.melds_range()) {
34
0
    if (meld.type == SetType::kChi) {
35
0
      if (meld.start.getSuit() == Piece::Type::kBambooSuit) {
36
0
        bamboo_chi.at(meld.start.getPieceNum()) = true;
37
0
      }
38
0
      if (meld.start.getSuit() == Piece::Type::kCharacterSuit) {
39
0
        char_chi.at(meld.start.getPieceNum()) = true;
40
0
      }
41
0
      if (meld.start.getSuit() == Piece::Type::kPinSuit) {
42
0
        pin_chi.at(meld.start.getPieceNum()) = true;
43
0
      }
44
0
    }
45
0
  }
46
54
  for (int i = 0; i < k_piecesinasuit; i++) {
47
49
    if (bamboo_chi.at(i) && char_chi.at(i) && pin_chi.at(i)) {
48
2
      return true;
49
2
    }
50
49
  }
51
5
  return false;
52
7
}
53
54
REGISTER_YAKU({
55
    .id = "mixedtriplechi",
56
    .name = "Mixed Triple Chi",
57
    .type = Yaku::kBonusWhenClosed,
58
    .value = 1,
59
    .is_yaku_func = yaku::isMixedTripleChi,
60
});
61
}  // namespace mahjong::yaku