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