diff options
Diffstat (limited to 'server/lobby.cpp')
-rw-r--r-- | server/lobby.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/server/lobby.cpp b/server/lobby.cpp index a3b50d7..b31183b 100644 --- a/server/lobby.cpp +++ b/server/lobby.cpp @@ -4,6 +4,8 @@ #include <iostream> +#include "game.h" + void Lobby::handle_connect(Connection::p connection) { // Create player. Player::create(connection, boost::bind(&Lobby::handle_action, this, _1)); @@ -14,6 +16,13 @@ void Lobby::handle_connect(Connection::p connection) { void Lobby::handle_action(Player::p player) { std::cout << "Player " << player->nick() << " entered the lobby." << std::endl; + + if(waiting.size() >= 3) { + new Game(waiting[0], waiting[1], waiting[2], player); + waiting.clear(); + } else { + waiting.push_back(player); + } } Lobby::Lobby() : server(io_service) { |