summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/game.cpp29
-rw-r--r--server/game.h7
-rw-r--r--server/player.cpp8
3 files changed, 29 insertions, 15 deletions
diff --git a/server/game.cpp b/server/game.cpp
index b0739cb..66a791c 100644
--- a/server/game.cpp
+++ b/server/game.cpp
@@ -44,6 +44,9 @@ void Game::start() {
<< players[2].client->nick() << " and "
<< players[3].client->nick() << "." << std::endl;
+ round_wind = 0;
+ round_num = 0;
+
awaiting_players = 4;
std::vector<std::string> pl;
@@ -82,10 +85,10 @@ void Game::round_start() {
// Notify players of round start.
// TODO: Tell them where wall is broken.
- players[0].round_start();
- players[1].round_start();
- players[2].round_start();
- players[3].round_start();
+ players[0].round_start(-round_num);
+ players[1].round_start(-round_num + 1);
+ players[2].round_start(-round_num + 2);
+ players[3].round_start(-round_num + 3);
// Draw hands.
for(int i = 0; i < 13; i++) {
@@ -128,9 +131,7 @@ void Game::round_update_draw() {
a = possible_actions;
}
- GameState gstate;
- gstate.dora = dora;
- gstate.current_player = current_player - player;
+ GameState gstate = {dora, current_player - player, round_wind, round_num, 0, 0};
players[player].client->round_state(state[0], state[1], state[2], state[3], gstate, a);
} while(++player);
@@ -161,9 +162,7 @@ void Game::round_update_discard() {
}
}
- GameState gstate;
- gstate.dora = dora;
- gstate.current_player = current_player - player;
+ GameState gstate = {dora, current_player - player, round_wind, round_num, 0, 0};
players[player].client->round_state(state[0], state[1], state[2], state[3], gstate, a);
} while(++player);
@@ -305,6 +304,14 @@ void Game::handle_action_discard(Action action, int player) {
}
void Game::round_end() {
+ // Flere runder? round_start()
+
+ round_num++;
+
+ if(!round_num) {
+ round_wind++;
+ }
+
awaiting_players = 4;
players[0].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
@@ -312,6 +319,6 @@ void Game::round_end() {
players[2].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
players[3].client->round_end(boost::bind(&Game::handle_ready, shared_from_this()));
- // Flere runder? round_start()
+
// Ferdig? game_end()
}
diff --git a/server/game.h b/server/game.h
index b0ec4a2..c347a6b 100644
--- a/server/game.h
+++ b/server/game.h
@@ -31,9 +31,11 @@ class Game : public boost::enable_shared_from_this<Game> {
Tilegroups open;
Tiles pond;
bool riichi;
+ int score;
+ int wind;
//! Prepare for a new round.
- void round_start();
+ void round_start(int w);
//! Get a state snapshot.
PlayerState get_state();
@@ -102,6 +104,9 @@ class Game : public boost::enable_shared_from_this<Game> {
PlayerNum current_player;
+ PlayerNum round_wind;
+ PlayerNum round_num;
+
int awaiting_players;
Action preceding_action;
diff --git a/server/player.cpp b/server/player.cpp
index 6673937..8397c48 100644
--- a/server/player.cpp
+++ b/server/player.cpp
@@ -2,12 +2,14 @@
#include "hand.h"
-void Game::Player::round_start() {
+void Game::Player::round_start(int w) {
// Reset contents.
hand.clear();
open.clear();
pond.clear();
riichi = false;
+ score = 25000;
+ wind = w;
// Notify client of round start.
client->round_start();
@@ -17,7 +19,7 @@ PlayerState Game::Player::get_state() {
Tilegroups h = open;
h.insert(h.begin(), hand);
- PlayerState state = {h, pond};
+ PlayerState state = {h, pond, riichi, score, wind};
return state;
}
@@ -25,7 +27,7 @@ PlayerState Game::Player::get_state_filtered() {
Tilegroups h = open;
h.insert(h.begin(), hand);
- PlayerState state = {h, pond};
+ PlayerState state = {h, pond, riichi, score, wind};
return state;
}