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/pinfu.cc
Line
Count
Source
1
#include "scoring/yakus/pinfu.h"
2
3
#include <algorithm>
4
#include <vector>
5
6
#include "analysis/handnode.h"
7
#include "analysis/util.h"
8
#include "scoring/yakus.h"
9
#include "statefunctions/stateutilities.h"
10
#include "types/gamestate.h"
11
#include "types/pieces.h"
12
#include "types/sets.h"
13
#include "types/yaku.h"
14
15
namespace mahjong::yaku {
16
bool isPinfu(const GameState& state, int player,
17
6
             const std::vector<const mahjong::Node*>& branch) {
18
6
  if (state.hands.at(player).open) {
19
1
    return false;
20
1
  }
21
26
  for (const auto* node : branch) {
22
26
    switch (node->type()) {
23
1
      case SetType::kPon:
24
1
      case SetType::kConcealedKan:
25
1
      case SetType::kKan:
26
2
      case SetType::kSingle:
27
2
        return false;
28
29
18
      case SetType::kChi:
30
24
      case SetType::kPair: {
31
24
        if (node->start() == kRedDragon || node->start() == kWhiteDragon ||
32
24
            node->start() == kGreenDragon) {
33
0
          return false;
34
0
        }
35
24
        if (node->start() == kSouthWind && state.roundNum > 3) {
36
0
          return false;
37
0
        }
38
24
        if (node->start() == kEastWind && state.roundNum < 4) {
39
0
          return false;
40
0
        }
41
24
        if (node->start() == Piece::fromWind(GetSeat(state.roundNum, player))) {
42
0
          return false;
43
0
        }
44
24
      }
45
26
    }
46
26
  }
47
3
  std::vector<Piece> hand = state.hands.at(player).live;
48
3
  hand.erase(std::find(hand.begin(), hand.end(), state.pendingPiece));
49
3
  return isInTenpai13Pieces(hand, /*allWaits=*/true).size() > 1;
50
5
}
51
52
REGISTER_YAKU({
53
    .id = "pinfu",
54
    .name = "Pinfu",
55
    .type = Yaku::kClosed,
56
    .value = 1,
57
    .is_yaku_func = yaku::isPinfu,
58
});
59
}  // namespace mahjong::yaku