summaryrefslogtreecommitdiff
path: root/server/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/game.cpp')
-rw-r--r--server/game.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/server/game.cpp b/server/game.cpp
index e9b1369..4816490 100644
--- a/server/game.cpp
+++ b/server/game.cpp
@@ -326,12 +326,6 @@ void Game::handle_action_discard(Action action, int player) {
}
void Game::round_end(Endcondition end) {
-
- round_num++;
-
- if(!round_num) {
- round_wind++;
- }
Message::RoundEnd::p msg[4] = make_shared<Message::RoundEnd>();
@@ -409,12 +403,40 @@ void Game::round_end(Endcondition end) {
msg[count_player]->game_end = false;
if(count_player == 3) break;
}
- awaiting_players = 4;
- players[0].client->round_end(msg[0], boost::bind(&Game::handle_ready, shared_from_this()));
- players[1].client->round_end(msg[1], boost::bind(&Game::handle_ready, shared_from_this()));
- players[2].client->round_end(msg[2], boost::bind(&Game::handle_ready, shared_from_this()));
- players[3].client->round_end(msg[3], boost::bind(&Game::handle_ready, shared_from_this()));
+ round_num++;
+
+ if(!round_num) {
+ round_wind++;
+ //Do a 4-round game for now
+ for(int i = 0; i < 4; ++i) {
+ msg[i]->game_end = true;
+ players[i].client->round_end(msg[i], 0);
+ }
+ game_end();
+ } else {
+ awaiting_players = 4;
+ players[0].client->round_end(msg[0], boost::bind(&Game::handle_ready, shared_from_this()));
+ players[1].client->round_end(msg[1], boost::bind(&Game::handle_ready, shared_from_this()));
+ players[2].client->round_end(msg[2], boost::bind(&Game::handle_ready, shared_from_this()));
+ players[3].client->round_end(msg[3], boost::bind(&Game::handle_ready, shared_from_this()));
+ }
// Ferdig? game_end()
}
+
+void Game::game_end() {
+ Message::GameEnd::p msg = make_shared<Message::GameEnd>();
+ for(int i = 0; i < 4; i++) {
+ msg->scores[i].score = players[i].score;
+ msg->scores[i].won = players[i].score - 25000;
+ }
+
+ awaiting_players = 4;
+ players[0].client->game_end(msg, boost::bind(&Game::handle_ready, shared_from_this()));
+ players[1].client->game_end(msg, boost::bind(&Game::handle_ready, shared_from_this()));
+ players[2].client->game_end(msg, boost::bind(&Game::handle_ready, shared_from_this()));
+ players[3].client->game_end(msg, boost::bind(&Game::handle_ready, shared_from_this()));
+
+
+}