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/kan.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/hand.h"
11
#include "types/meld.h"
12
#include "types/piecetype.h"
13
#include "types/sets.h"
14
#include "types/statefunction.h"
15
16
namespace mahjong {
17
18
namespace {
19
0
std::unique_ptr<GameState> Kan(std::unique_ptr<GameState> state) {
20
0
  AlertPlayers(*state, Event{
21
0
                           .type = Event::kKan,          // type
22
0
                           .player = state->lastCaller,  // player
23
0
                           .piece = static_cast<int16_t>(
24
0
                               state->pendingPiece.toUint8_t()),  // piece
25
0
                           .decision = false,                     // decision
26
0
                       });
27
28
0
  if (Hand& hand = state->hands[state->currentPlayer];
29
0
      hand.riichi && hand.discards_count == hand.riichiPieceDiscard) {
30
0
    hand.riichiPieceDiscard++;
31
0
  }
32
33
0
  state->lastCall = state->turnNum;
34
0
  state->concealedKan = false;
35
0
  state->turnNum++;
36
0
  state->currentPlayer = state->lastCaller;
37
38
0
  Hand& hand = state->hands[state->currentPlayer];
39
0
  hand.open = true;
40
0
  if (RemovePieces(hand, state->pendingPiece,
41
0
                   /*count=*/3) != 3) {
42
0
    std::cerr << "Not Enough Pieces to remove in kan" << '\n';
43
0
    state->nextState = StateFunctionType::kError;
44
0
    return state;
45
0
  }
46
0
  hand.melds[hand.meld_count++] = Meld{
47
0
      .type = SetType::kKan,
48
0
      .start = state->pendingPiece,
49
0
  };
50
51
0
  state->nextState = StateFunctionType::kKanDiscard;
52
0
  return state;
53
0
}
54
}  // namespace
55
56
REGISTER_ROUTE(Kan, StateFunctionType::kKan);
57
}  // namespace mahjong