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

#include "list.h"

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
		};
		
		//! Action target type.
		enum TargetType {
			//! Action is targetless.
			None,
			//! Target is index in first group (concealed hand).
			Index,
			//! Target is index of group.
			Group
		};
		
		//! Type of action.
		Type type;
		
		//! Target of action (if applicable).
		TargetType target_type;
		int target_offset;
		
		Action();
		Action(Type ty, TargetType tt = None, int to = 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_type;
			ar & target_offset;
		}
};

//! List of actions.
typedef List<Action> Actions;

#endif