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/honorpon.cc
Line
Count
Source
1
#include "scoring/yakus/honorpon.h"
2
3
#include <vector>
4
5
#include "analysis/handnode.h"
6
#include "scoring/yakus.h"
7
#include "statefunctions/stateutilities.h"
8
#include "types/gamestate.h"
9
#include "types/hand.h"
10
#include "types/pieces.h"
11
#include "types/piecetype.h"
12
#include "types/sets.h"
13
#include "types/winds.h"
14
#include "types/yaku.h"
15
16
namespace mahjong::yaku {
17
namespace {
18
bool findPon(const GameState& /* state */, const Hand& hand,
19
             const std::vector<const mahjong::Node*>& branch,
20
28
             const Piece& piece) {
21
122
  for (const auto* node : branch) {
22
122
    if (node->type() == SetType::kPon && node->start() == piece) {
23
13
      return true;
24
13
    }
25
122
  }
26
15
  for (const auto& meld : hand.melds_range()) {
27
0
    if (meld.type >= SetType::kPon && meld.start == piece) {
28
0
      return true;
29
0
    }
30
0
  }
31
15
  return false;
32
15
}
33
34
}  // namespace
35
36
bool isSeatWind(const GameState& state, const Hand& hand,
37
9
                const std::vector<const mahjong::Node*>& branch) {
38
9
  return findPon(state, hand, branch,
39
9
                 Piece::fromWind(GetSeat(state.roundNum, hand.id)));
40
9
}
41
42
bool isPrevalentWind(const GameState& state, const Hand& hand,
43
9
                     const std::vector<const mahjong::Node*>& branch) {
44
9
  return findPon(state, hand, branch,
45
9
                 Piece::fromWind(state.roundNum > 3 ? kSouth : kEast));
46
9
}
47
48
bool isGreenDragon(const GameState& state, const Hand& hand,
49
4
                   const std::vector<const mahjong::Node*>& branch) {
50
4
  return findPon(state, hand, branch, kGreenDragon);
51
4
}
52
53
bool isRedDragon(const GameState& state, const Hand& hand,
54
4
                 const std::vector<const mahjong::Node*>& branch) {
55
4
  return findPon(state, hand, branch, kRedDragon);
56
4
}
57
58
bool isWhiteDragon(const GameState& state, const Hand& hand,
59
2
                   const std::vector<const mahjong::Node*>& branch) {
60
2
  return findPon(state, hand, branch, kWhiteDragon);
61
2
}
62
63
REGISTER_YAKUS({
64
    {
65
        .id = "seatwind",
66
        .name = "Seat Wind Pon",
67
        .type = Yaku::kOpen,
68
        .value = 1,
69
        .is_yaku_func = yaku::isSeatWind,
70
    },
71
    {
72
        .id = "prevalentwind",
73
        .name = "Prevalent Wind Pon",
74
        .type = Yaku::kOpen,
75
        .value = 1,
76
        .is_yaku_func = yaku::isPrevalentWind,
77
    },
78
    {
79
        .id = "greendragon",
80
        .name = "Green Dragon Pon",
81
        .type = Yaku::kOpen,
82
        .value = 1,
83
        .is_yaku_func = yaku::isGreenDragon,
84
    },
85
    {
86
        .id = "reddragon",
87
        .name = "Red Dragon Pon",
88
        .type = Yaku::kOpen,
89
        .value = 1,
90
        .is_yaku_func = yaku::isRedDragon,
91
    },
92
    {
93
        .id = "whitedragon",
94
        .name = "White Dragon Pon",
95
        .type = Yaku::kOpen,
96
        .value = 1,
97
        .is_yaku_func = yaku::isWhiteDragon,
98
    },
99
});
100
}  // namespace mahjong::yaku