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/statefunctions/gamestates/convertedkan.cc
Line
Count
Source
1
#include <algorithm>
2
#include <array>
3
#include <cstdint>
4
#include <iostream>
5
#include <memory>
6
7
#include "statefunctions/router.h"
8
#include "statefunctions/stateutilities.h"
9
#include "types/event.h"
10
#include "types/gamestate.h"
11
#include "types/hand.h"
12
#include "types/meld.h"
13
#include "types/piecetype.h"
14
#include "types/sets.h"
15
#include "types/statefunction.h"
16
17
namespace mahjong {
18
namespace {
19
0
std::unique_ptr<GameState> ConvertedKan(std::unique_ptr<GameState> state) {
20
0
  AlertPlayers(*state, Event{
21
0
                           .type = Event::kConvertedKan,    // type
22
0
                           .player = state->currentPlayer,  // player
23
0
                           .piece = static_cast<int16_t>(
24
0
                               state->pendingPiece.toUint8_t()),  // piece
25
0
                           .decision = false,                     // decision
26
0
                       });
27
0
  Hand& hand = state->hands[state->currentPlayer];
28
0
  if (RemovePieces(hand, state->pendingPiece,
29
0
                   /*count=*/1) != 1) {
30
0
    std::cerr << "Not Enough pieces to remove in ConvertedKan" << '\n';
31
0
    state->nextState = StateFunctionType::kError;
32
0
    return state;
33
0
  }
34
0
  Meld* meld = std::ranges::find(
35
0
      hand.melds, Meld{.type = SetType::kPon, .start = state->pendingPiece});
36
0
  if (meld == hand.melds.end()) {
37
0
    std::cerr << "Could Not find matching pon" << '\n';
38
0
    state->nextState = StateFunctionType::kError;
39
0
    return state;
40
0
  }
41
0
  meld->type = SetType::kKan;
42
0
  state->nextState = StateFunctionType::kKanDiscard;
43
0
  return state;
44
0
}
45
}  // namespace
46
47
REGISTER_ROUTE(ConvertedKan, StateFunctionType::kConvertedKan);
48
}  // namespace mahjong