summaryrefslogtreecommitdiff
path: root/server/game.h
blob: 3ed97e4262457453bd1817469fe4d14ece9caf2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef GAME_H
#define GAME_H

#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>

#include <vector>

#include "wall.h"
#include "player.h"
#include "../common/action.h"

class Game : public boost::enable_shared_from_this<Game> {
	public:
		typedef boost::shared_ptr<Game> p;
		
		static p create(Player::p player_1, Player::p player_2, Player::p player_3, Player::p player_4);
		
		~Game();
		
	private:
		std::vector<Player::p> players;
		
		int waiting_players;
		
		Game(Player::p player_1, Player::p player_2, Player::p player_3, Player::p player_4);
		
		//! The wall that belongs to this game
		Wall wall;
		
		//! The current state of the game
		State::p game_state;
		
		//! Current player, used when discarding etc
		int current_player;
		
		//! Are we in draw or discard phase?
		bool draw_phase; 
		
		//! Number of players doing action
		int num_player_actions;
		
		//! Highest value action done
		Action most_value_action;
		
		//! Handle Ready message from player.
		void handle_ready();
		
		//! Start the game.
		void start();
		
		void round_start();
		void round_update();
		void handle_action(Action action);
		void round_end();
};

#endif