summaryrefslogtreecommitdiff
path: root/server/game.h
blob: 634ea4d9abc6f9dd09a0a064bf7a462c2397933e (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
#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;
		
		int num_player_actions;
		
		bool east_action;
		bool west_action;
		bool south_action;
		bool north_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