summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-12-01 14:07:20 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-12-01 14:07:20 +0100
commitab6a569afd9dffc45fac0d0ef92063d6b55904df (patch)
tree4c9b24196e8f43967c58189775d0dfadb71db1e7
parentd8f9d6c3baaaf6bd1b6615bd38201c5bcf2fee57 (diff)
Added game mode selection, with 1p and 4p testing modes.
-rw-r--r--server/lobby.cpp33
-rw-r--r--server/lobby.h5
2 files changed, 30 insertions, 8 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;
}
}
diff --git a/server/lobby.h b/server/lobby.h
index 0e25975..fa0e5fe 100644
--- a/server/lobby.h
+++ b/server/lobby.h
@@ -18,8 +18,11 @@ class Lobby {
//! Handle new connection.
void handle_connect(Connection::p connection);
+ //! Handle login.
+ void handle_login(Client::p client);
+
//! Handle action.
- void handle_action(Client::p client);
+ void handle_action(Client::p client, int game_mode);
public:
Lobby();