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/littlefourwinds.cc
Line
Count
Source
1
#include "scoring/yakus/littlefourwinds.h"
2
3
#include <vector>
4
5
#include "analysis/handnode.h"
6
#include "scoring/yakus.h"
7
#include "types/gamestate.h"
8
#include "types/sets.h"
9
#include "types/yaku.h"
10
11
namespace mahjong::yaku {
12
bool isLittleFourWinds(const GameState& state, int player,
13
0
                       const std::vector<const mahjong::Node*>& branch) {
14
0
  bool pair = false;
15
0
  int pons = 0;
16
0
  for (const auto* node : branch) {
17
0
    switch (node->start().toUint8_t()) {
18
0
      case Piece::Type::kEastWind:
19
0
      case Piece::Type::kSouthWind:
20
0
      case Piece::Type::kWestWind:
21
0
      case Piece::Type::kNorthWind:
22
0
        break;
23
0
      default:
24
0
        continue;
25
0
    }
26
0
    if (node->type() != SetType::kPair) {
27
0
      pons++;
28
0
    } else {
29
0
      if (pair) {
30
0
        return false;
31
0
      }
32
0
      pair = true;
33
0
    }
34
0
  }
35
0
  if (!pair) {
36
0
    return false;
37
0
  }
38
0
  for (const auto& meld : state.hands.at(player).melds) {
39
0
    switch (meld.start.toUint8_t()) {
40
0
      case Piece::Type::kEastWind:
41
0
      case Piece::Type::kSouthWind:
42
0
      case Piece::Type::kWestWind:
43
0
      case Piece::Type::kNorthWind:
44
0
        break;
45
0
      default:
46
0
        continue;
47
0
    }
48
0
    pons++;
49
0
  }
50
0
  return pons == 3 && pair;
51
0
}
52
53
REGISTER_YAKU({
54
    .id = "littlefourwinds",
55
    .name = "Little Four Winds",
56
    .type = Yaku::kYakuman,
57
    .value = 13,
58
    .is_yaku_func = yaku::isLittleFourWinds,
59
});
60
}  // namespace mahjong::yaku