/nix/store/i1aar97n7b4yf8rk94p66if25brfvvdx-gqvzl8a5pvrg3xj44q0msrndcripi8dk-source/src/statefunctions/gamestates/draw.cc
Line | Count | Source |
1 | | #include <array> |
2 | | #include <memory> |
3 | | #include <vector> |
4 | | |
5 | | #include "statefunctions/router.h" |
6 | | #include "types/gamestate.h" |
7 | | #include "types/piecetype.h" |
8 | | #include "types/statefunction.h" |
9 | | #include "types/walls.h" |
10 | | |
11 | | namespace mahjong { |
12 | | namespace { |
13 | 16 | std::unique_ptr<GameState> Draw(std::unique_ptr<GameState> state) { |
14 | 16 | state->currentPlayer = (state->currentPlayer + 1) % 4; |
15 | 16 | state->turnNum++; |
16 | 16 | state->pendingPiece = state->walls.TakePiece(); |
17 | 16 | state->hands.at(state->currentPlayer).live.push_back(state->pendingPiece); |
18 | 16 | state->hands.at(state->currentPlayer).sort(); |
19 | 16 | state->nextState = StateFunctionType::kPlayerHand; |
20 | 16 | return state; |
21 | 16 | } |
22 | | } // namespace |
23 | | |
24 | | REGISTER_ROUTE(Draw, StateFunctionType::kDraw); |
25 | | } // namespace mahjong |