From da85516a57b13963165ea0a30aacca609c125cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atle=20Hellvik=20Havs=C3=B8?= Date: Sat, 20 Nov 2010 13:56:20 +0100 Subject: Should now be possible to play a round where everyone discards. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atle Hellvik Havsø --- server/game.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'server') 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(); // 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() { -- cgit v1.2.3