summaryrefslogtreecommitdiff
path: root/common/action.h
blob: 4024c67f658797d518fc33fe2d8d5defafdf3415 (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
#ifndef ACTION_H
#define ACTION_H

#include <vector>
#include <boost/serialization/base_object.hpp>

class Action {
	public:
		//! Action types.
		enum Type {
			Pass,    // discard
			Discard, // draw
			Riichi,  // draw
			Chi,     // discard
			Pon,     // discard
			Kan,     // draw, discard
			Ron,     // discard
			Tsumo,   // draw
			Draw     // draw
		};
		
		//! Type of action.
		Type type;
		
		//! Target of action (if applicable).
		int target;
		
		Action();
		Action(Type ty, int ta = 0);
		
		//! Compare to another action.
		bool operator==(const Action& other);
		
		template<class Archive>
		void serialize(Archive & ar, const unsigned int version) {
			ar & type;
			ar & target;
		}
};

//! List of actions.
class Actions : public std::vector<Action> {
	public:
		//! Check if specified action is present in list.
		bool contains(Action action);
		
		//! Check whether list is empty or not.
		operator bool();
		
		template<class Archive>
		void serialize(Archive & ar, const unsigned int version) {
			ar & boost::serialization::base_object<std::vector<Action> >(*this);
		}
};

#endif