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/thirteenorphans.cc
Line
Count
Source
1
#include "scoring/yakus/thirteenorphans.h"
2
3
#include <map>
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/pieces.h"
11
#include "types/piecetype.h"
12
#include "types/yaku.h"
13
14
namespace mahjong::yaku {
15
bool isThirteenOrphans(const GameState& /*state*/, const Hand& hand,
16
44
                       const std::vector<const mahjong::Node*>& /*branch*/) {
17
44
  if (hand.open) {
18
0
    return false;
19
0
  }
20
44
  std::map<Piece, bool> pieces = {
21
44
      {kOneCharacter, false}, {kNineCharacter, false}, {kOnePin, false},
22
44
      {kNinePin, false},      {kOneBamboo, false},     {kNineBamboo, false},
23
44
      {kEastWind, false},     {kSouthWind, false},     {kWestWind, false},
24
44
      {kNorthWind, false},    {kRedDragon, false},     {kWhiteDragon, false},
25
44
      {kGreenDragon, false}};
26
44
  bool duplicate = false;
27
28
583
  for (const auto& piece : hand.live_range()) {
29
583
    if (pieces.contains(piece)) {
30
195
      if (pieces[piece]) {
31
25
        duplicate = true;
32
170
      } else {
33
170
        pieces[piece] = true;
34
170
      }
35
195
    }
36
583
  }
37
44
  if (!duplicate) {
38
20
    return false;
39
20
  }
40
36
  for (const auto& [_, match] : pieces) {
41
36
    if (!match) {
42
24
      return false;
43
24
    }
44
36
  }
45
0
  return true;
46
24
}
47
48
REGISTER_YAKU({
49
    .id = "thirteenorphans",
50
    .name = "Thirteen Orphans",
51
    .type = Yaku::kYakuman,
52
    .value = 1,
53
    .is_yaku_func = yaku::isThirteenOrphans,
54
});
55
}  // namespace mahjong::yaku