Coverage Report

Created: 2025-09-03 03:49

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