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