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/ninegates.cc
Line
Count
Source
1
#include "scoring/yakus/ninegates.h"
2
3
#include <map>
4
#include <vector>
5
6
#include "analysis/handnode.h"
7
#include "scoring/yakus.h"
8
#include "scoring/yakus/fullflush.h"
9
#include "types/gamestate.h"
10
#include "types/hand.h"
11
#include "types/yaku.h"
12
13
namespace mahjong::yaku {
14
bool isNineGates(const GameState& state, const Hand& hand,
15
1
                 const std::vector<const mahjong::Node*>& branch) {
16
1
  if (hand.open) {
17
0
    return false;
18
0
  }
19
1
  if (!isFullFlush(state, hand, branch)) {
20
1
    return false;
21
1
  }
22
0
  if (hand.open) {
23
0
    return false;
24
0
  }
25
0
  std::map<int, int> pieces;
26
0
  for (int i = 1; i < 10; i++) {
27
0
    pieces.at(i) = 0;
28
0
  }
29
0
  bool duplicate = false;
30
0
  for (const auto& piece : hand.live_range()) {
31
0
    if (pieces.contains(piece.getPieceNum())) {
32
0
      if ((pieces[piece.getPieceNum()] != 0) && !piece.isTerminal()) {
33
0
        if (duplicate) {
34
0
          return false;
35
0
        }
36
0
        duplicate = true;
37
0
      } else {
38
0
        pieces[piece.getPieceNum()]++;
39
0
      }
40
0
    }
41
0
  }
42
0
  if (!duplicate) {
43
0
    return false;
44
0
  }
45
0
  for (const auto& [piece, count] : pieces) {
46
0
    if ((piece == 1 || piece == 9)) {
47
0
      if (count != 3) {
48
0
        return false;
49
0
      }
50
0
    } else if (count != 1) {
51
0
      return false;
52
0
    }
53
0
  }
54
0
  return true;
55
0
}
56
57
REGISTER_YAKU({
58
    .id = "ninegates",
59
    .name = "Nine Gates",
60
    .type = Yaku::kYakuman,
61
    .value = 1,
62
    .is_yaku_func = yaku::isNineGates,
63
});
64
}  // namespace mahjong::yaku