From 97951fe38059cc4f0757ebe83466327c556b4e2d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 4 Dec 2010 15:31:03 +0100 Subject: Fill all fields in GameState and PlayerState. --- server/game.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'server/game.cpp') diff --git a/server/game.cpp b/server/game.cpp index b0739cb..66a791c 100644 --- a/server/game.cpp +++ b/server/game.cpp @@ -44,6 +44,9 @@ void Game::start() { << players[2].client->nick() << " and " << players[3].client->nick() << "." << std::endl; + round_wind = 0; + round_num = 0; + awaiting_players = 4; std::vector pl; @@ -82,10 +85,10 @@ void Game::round_start() { // Notify players of round start. // TODO: Tell them where wall is broken. - players[0].round_start(); - players[1].round_start(); - players[2].round_start(); - players[3].round_start(); + players[0].round_start(-round_num); + players[1].round_start(-round_num + 1); + players[2].round_start(-round_num + 2); + players[3].round_start(-round_num + 3); // Draw hands. for(int i = 0; i < 13; i++) { @@ -128,9 +131,7 @@ void Game::round_update_draw() { a = possible_actions; } - GameState gstate; - gstate.dora = dora; - gstate.current_player = current_player - player; + GameState gstate = {dora, current_player - player, round_wind, round_num, 0, 0}; players[player].client->round_state(state[0], state[1], state[2], state[3], gstate, a); } while(++player); @@ -161,9 +162,7 @@ void Game::round_update_discard() { } } - GameState gstate; - gstate.dora = dora; - gstate.current_player = current_player - player; + GameState gstate = {dora, current_player - player, round_wind, round_num, 0, 0}; players[player].client->round_state(state[0], state[1], state[2], state[3], gstate, a); } while(++player); @@ -305,6 +304,14 @@ void Game::handle_action_discard(Action action, int player) { } void Game::round_end() { + // Flere runder? round_start() + + round_num++; + + if(!round_num) { + round_wind++; + } + awaiting_players = 4; players[0].client->round_end(boost::bind(&Game::handle_ready, shared_from_this())); @@ -312,6 +319,6 @@ void Game::round_end() { players[2].client->round_end(boost::bind(&Game::handle_ready, shared_from_this())); players[3].client->round_end(boost::bind(&Game::handle_ready, shared_from_this())); - // Flere runder? round_start() + // Ferdig? game_end() } -- cgit v1.2.3