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/exhaust.cc
Line
Count
Source
1
#include <array>
2
#include <memory>
3
4
#include "analysis/util.h"
5
#include "statefunctions/router.h"
6
#include "types/gamestate.h"
7
#include "types/statefunction.h"
8
9
namespace mahjong {
10
11
namespace {
12
0
std::unique_ptr<GameState> Exhaust(std::unique_ptr<GameState> state) {
13
0
  std::array<int, 4> winning_players = {};
14
0
  int total_winners = 0;
15
0
  for (int i = 0; i < 4; i++) {
16
    // TODO(#21): Implement no tenpai if you have all pieces of your wait
17
0
    if (state->hands[i].riichi || !getWaits(state->hands[i]).empty()) {
18
0
      winning_players[i] = 1;
19
0
      total_winners++;
20
0
    }
21
0
  }
22
0
  state->counters++;
23
0
  if (winning_players.at(state->roundNum % 4) == 0) {
24
0
    state->roundNum++;
25
0
  }
26
0
  if (total_winners < 4 && total_winners > 0) {
27
0
    for (int i = 0; i < 4; i++) {
28
0
      if (winning_players[i] != 0) {
29
0
        state->hands[i].score = 3000 / total_winners;
30
0
      } else {
31
0
        switch (total_winners) {
32
0
          case 1:
33
0
            state->hands[i].score = -1000;
34
0
            break;
35
0
          case 2:
36
0
            state->hands[i].score = -1500;
37
0
            break;
38
0
          case 3:
39
0
            state->hands[i].score = -3000;
40
0
            break;
41
0
          default:
42
0
            break;
43
0
        }
44
0
      }
45
0
      if (state->hands[i].riichi) {
46
0
        state->hands[i].score -= 1000;
47
0
      }
48
0
    }
49
0
  }
50
0
  state->nextState = StateFunctionType::kRoundEnd;
51
0
  return state;
52
0
}
53
}  // namespace
54
55
REGISTER_ROUTE(Exhaust, StateFunctionType::kExhaust);
56
}  // namespace mahjong