From b3e9ace28566e0572885b04924e2183c587369e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atle=20Hellvik=20Havs=C3=B8?= Date: Sat, 20 Nov 2010 12:07:08 +0100 Subject: Added a wall to Game and started handing out tiles to the players in the start of a game. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atle Hellvik Havsø --- server/game.cpp | 21 ++++++++++++++++++++- server/game.h | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/server/game.cpp b/server/game.cpp index 346251e..3f34d07 100644 --- a/server/game.cpp +++ b/server/game.cpp @@ -40,13 +40,32 @@ void Game::round_start() { players[3]->round_start(); // Sett opp runden + 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 y = 0; y < 4; y++) { + game_state->players[player_num].hand.push_back(wall.take_one()); + } + } + } + + // Simulates the second part of drawing with only 1 tile + for (int player_num = 0; player_num < 4; player_num++) { + game_state->players[player_num].hand.push_back(wall.take_one()); + } + + // Gives an extra tile to the first player (east) + game_state->players[0].hand.push_back(wall.take_one()); + + round_update(); } void Game::round_update() { // Send RoundState, inkl. liste av mulige actions. - State::p game_state = make_shared(); players[0]->round_state(game_state); players[1]->round_state(game_state); diff --git a/server/game.h b/server/game.h index 39e02f8..dc3a9ff 100644 --- a/server/game.h +++ b/server/game.h @@ -6,6 +6,7 @@ #include +#include "wall.h" #include "player.h" #include "../common/action.h" @@ -24,6 +25,12 @@ class Game : public boost::enable_shared_from_this { Game(Player::p player_1, Player::p player_2, Player::p player_3, Player::p player_4); + //! The wall that belongs to this game + Wall wall; + + //! The current state of the game + State::p game_state; + //! Handle Ready message from player. void handle_ready(); -- cgit v1.2.3