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/littlethreedragons.cc
Line
Count
Source
1
#include "scoring/yakus/littlethreedragons.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 isLittleThreeDragons(const GameState& state, int player,
13
10
                          const std::vector<const mahjong::Node*>& branch) {
14
10
  bool pair = false;
15
10
  int pons = 0;
16
53
  for (const auto* node : branch) {
17
53
    switch (node->start().toUint8_t()) {
18
2
      case Piece::Type::kRedDragon:
19
16
      case Piece::Type::kGreenDragon:
20
17
      case Piece::Type::kWhiteDragon:
21
17
        break;
22
36
      default:
23
36
        continue;
24
53
    }
25
17
    if (node->type() == SetType::kPon) {
26
7
      pons++;
27
7
    }
28
17
    if (node->type() == SetType::kPair) {
29
6
      pair = true;
30
6
    }
31
17
  }
32
10
  if (!pair) {
33
4
    return false;
34
4
  }
35
6
  for (const auto& meld : state.hands.at(player).melds) {
36
5
    switch (meld.start.toUint8_t()) {
37
0
      case Piece::Type::kRedDragon:
38
0
      case Piece::Type::kGreenDragon:
39
5
      case Piece::Type::kWhiteDragon:
40
5
        break;
41
0
      default:
42
0
        continue;
43
5
    }
44
5
    pons++;
45
5
  }
46
6
  return pons == 2 && pair;
47
6
}
48
49
REGISTER_YAKU({
50
    .id = "littlethreedragons",
51
    .name = "Little Three Dragons",
52
    .type = Yaku::kOpen,
53
    .value = 2,
54
    .is_yaku_func = yaku::isLittleThreeDragons,
55
});
56
}  // namespace mahjong::yaku