summaryrefslogtreecommitdiff
path: root/server/game.h
blob: 0c47917b6388d338831440eb7f026028d793099f (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
59
60
61
62
63
64
65
66
#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"

class Game : public boost::enable_shared_from_this<Game> {
	public:
		typedef boost::shared_ptr<Game> p;
		
		static p create(ClientBase::p player_1, ClientBase::p player_2, ClientBase::p player_3, ClientBase::p player_4);
		
		~Game();
		
	private:
		Player players[4];
		
		Wall wall;
		
		Tiles dora;
		
		bool kan_dora_pending;
		
		PlayerNum current_player;
		
		PlayerNum round_wind;
		PlayerNum round_num;
		
		int awaiting_players;
		
		Action preceding_action;
		int preceding_action_owner;
		
		Game(ClientBase::p player_1, ClientBase::p player_2, ClientBase::p player_3, ClientBase::p player_4);
		
		//! Handle Ready message from player.
		void handle_ready();
		
		//! Start the game.
		void start();
		
		//! Start a new round.
		void round_start();
		
		//! Send update after a tile is drawn.
		void round_update_draw();
		
		//! Send update after a tile is discarded.
		void round_update_discard();
		
		//! Handle action after draw.
		void handle_action_draw(Action action);
		
		//! Handle actions after discard.
		void handle_action_discard(Action action, int player);
		
		//! End the game.
		void round_end();
};

#endif