/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/statefunctions/gamestates/concealedkan.cc
Line | Count | Source |
1 | | #include <array> |
2 | | #include <cstdint> |
3 | | #include <iostream> |
4 | | #include <memory> |
5 | | #include <vector> |
6 | | |
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/sets.h" |
13 | | #include "types/statefunction.h" |
14 | | |
15 | | namespace mahjong { |
16 | | |
17 | | namespace { |
18 | 0 | std::unique_ptr<GameState> ConcealedKan(std::unique_ptr<GameState> state) { |
19 | 0 | AlertPlayers(*state, Event{ |
20 | 0 | .type = Event::kConcealedKan, // type |
21 | 0 | .player = state->currentPlayer, // player |
22 | 0 | .piece = static_cast<int16_t>( |
23 | 0 | state->pendingPiece.toUint8_t()), // piece |
24 | 0 | .decision = false, // decision |
25 | 0 | }); |
26 | 0 | if (RemovePieces(*state, state->currentPlayer, state->pendingPiece, |
27 | 0 | /*count=*/4) != 4) { |
28 | 0 | std::cerr << "Not Enough pieces to remove in ConcealedKan" << '\n'; |
29 | 0 | state->nextState = StateFunctionType::kError; |
30 | 0 | return state; |
31 | 0 | } |
32 | 0 | state->hands.at(state->currentPlayer) |
33 | 0 | .melds.push_back({SetType::kConcealedKan, state->pendingPiece}); |
34 | 0 | state->concealedKan = true; |
35 | 0 | state->nextState = StateFunctionType::kKanDiscard; |
36 | 0 | return state; |
37 | 0 | } |
38 | | } // namespace |
39 | | |
40 | | REGISTER_ROUTE(ConcealedKan, StateFunctionType::kConcealedKan); |
41 | | } // namespace mahjong |