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/riichi.cc
Line
Count
Source
1
#include <array>
2
#include <cstdint>
3
#include <memory>
4
#include <vector>
5
6
#include "analysis/util.h"
7
#include "statefunctions/router.h"
8
#include "statefunctions/stateutilities.h"
9
#include "types/event.h"
10
#include "types/gamestate.h"
11
#include "types/piecetype.h"
12
#include "types/statefunction.h"
13
14
namespace mahjong {
15
16
namespace {
17
0
std::unique_ptr<GameState> Riichi(std::unique_ptr<GameState> state) {
18
  // TODO(#22): Ask the players if they want to riichi
19
0
  state->pendingPiece =
20
0
      getRiichiDiscard(state->hands.at(state->currentPlayer).live)[0];
21
22
0
  AlertPlayers(*state,
23
0
               Event{
24
0
                   .type = Event::kRiichi,          // type
25
0
                   .player = state->currentPlayer,  // player
26
0
                   .piece = static_cast<int16_t>(
27
0
                       Piece(state->pendingPiece).toUint8_t()),  // piece
28
0
                   .decision = false,                            // decision
29
0
               });
30
31
0
  state->hands.at(state->currentPlayer).riichiRound = state->turnNum;
32
0
  state->hands.at(state->currentPlayer).riichiPieceDiscard =
33
0
      state->hands.at(state->currentPlayer).discards.size();
34
0
  state->hands.at(state->currentPlayer).riichi = true;
35
0
  state->riichiSticks++;
36
37
0
  state->nextState = StateFunctionType::kDiscard;
38
0
  return state;
39
0
}
40
}  // namespace
41
42
REGISTER_ROUTE(Riichi, StateFunctionType::kRiichi);
43
}  // namespace mahjong