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