diff options
-rw-r--r-- | server/game.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/server/game.cpp b/server/game.cpp index bd4314e..c189776 100644 --- a/server/game.cpp +++ b/server/game.cpp @@ -47,8 +47,8 @@ void Game::round_start() { game_state = make_shared<State>(); // Simulates drawing 4, 4 ,4 for each player - for (int player_num = 0; player_num < 4; player_num++) { - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { + for (int player_num = 0; player_num < 4; player_num++) { for (int y = 0; y < 4; y++) { game_state->players[player_num].hand.push_back(wall.take_one()); } @@ -69,7 +69,13 @@ void Game::round_start() { void Game::round_update() { + if ( draw_phase ) { + // Is the wall empty? Then the round is over and we have a draw + if (wall.is_done()) { + round_end(); + } + game_state->players[current_player].hand.push_back(wall.take_one()); Action discard_action; @@ -82,22 +88,17 @@ void Game::round_update() { // Add code for calculation of possible riichi, tsumo, kan and draw num_player_actions++; - - draw_phase = false; - } else { // Run if we're in the discard phase - - - + // TODO + // Add code for calculation of possible chi, pon, kan and ron. + // Update who the current player is. if ( current_player == 3) { current_player = 0; } else { current_player++; } - - draw_phase = true; } @@ -112,8 +113,10 @@ void Game::round_update() { // Kall player->get_action(handle_action) for hver spiller som har actions, om ingen kan gjøre noe så blir // det neste spiller sin tur. if(num_player_actions) { - players[0]->get_action(boost::bind(&Game::handle_action, shared_from_this(), _1)); + draw_phase = !draw_phase; + players[current_player]->get_action(boost::bind(&Game::handle_action, shared_from_this(), _1)); } else { + draw_phase = true; round_update(); } @@ -174,10 +177,12 @@ void Game::handle_action(Action action) { // Oppdater state // Evt. round_end() if (num_player_actions == 0) { + // TODO + // Add code for when someone has done a chi, pon, ron and kan. + + round_update(); } - - } void Game::round_end() { |