summaryrefslogtreecommitdiff
path: root/server/lobby.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/lobby.cpp')
-rw-r--r--server/lobby.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/server/lobby.cpp b/server/lobby.cpp
index 79c207b..667d68e 100644
--- a/server/lobby.cpp
+++ b/server/lobby.cpp
@@ -8,20 +8,39 @@
void Lobby::handle_connect(Connection::p connection) {
// Create player.
- Client::create(connection, boost::bind(&Lobby::handle_action, this, _1));
+ Client::create(connection, boost::bind(&Lobby::handle_login, this, _1));
// Get another connection.
server.get_connection(boost::bind(&Lobby::handle_connect, this, _1));
}
-void Lobby::handle_action(Client::p client) {
+void Lobby::handle_login(Client::p client) {
std::cout << "Client " << client->nick() << " entered the lobby." << std::endl;
- if(waiting.size() >= 3) {
- Game::create(waiting[0], waiting[1], waiting[2], client);
- waiting.clear();
- } else {
- waiting.push_back(client);
+ std::vector<std::string> game_modes;
+
+ game_modes.push_back("1p test mode");
+ game_modes.push_back("4p test mode");
+
+ client->lobby_status(game_modes, boost::bind(&Lobby::handle_action, this, client, _1));
+}
+
+void Lobby::handle_action(Client::p client, int game_mode) {
+ std::cout << "Client " << client->nick() << " joined a game." << std::endl;
+
+ switch(game_mode) {
+ case 0: {
+ Game::create(client, make_shared<ClientDumb>(), make_shared<ClientDumb>(), make_shared<ClientDumb>());
+ }
+
+ case 1: {
+ if(waiting.size() >= 3) {
+ Game::create(waiting[0], waiting[1], waiting[2], client);
+ waiting.clear();
+ } else {
+ waiting.push_back(client);
+ }
+ } break;
}
}