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