summaryrefslogtreecommitdiff
path: root/src/object_filter.cc
blob: 936eef7d045937b36fd63cdcda7b3be450210bbc (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
67
68
69
70
71
72
73
74
75
#include "object_filter.hpp"
#include "object1.hpp"
#include "object2.hpp"
#include "object_type.hpp"

namespace object_filter {

object_filter_t TVal(byte tval) {
	return [=](object_type const *o_ptr) -> bool {
		return o_ptr->tval == tval;
	};
}

object_filter_t SVal(byte sval) {
	return [=](object_type const *o_ptr) -> bool {
		return o_ptr->sval == sval;
	};
}

object_filter_t HasFlags(object_flag_set const &mask) {
	return [=](object_type const *o_ptr) -> bool {
		auto const flags = object_flags(o_ptr);
		return bool(flags & mask);
	};
}

object_filter_t IsArtifact() {
	return [](object_type const *o_ptr) -> bool {
		return o_ptr->name1 > 0;
	};
}

object_filter_t IsArtifactP() {
	return [](object_type const *o_ptr) -> bool {
		return artifact_p(o_ptr);
	};
}

object_filter_t IsEgo() {
	return [](object_type const *o_ptr) -> bool {
		return ego_item_p(o_ptr);
	};
}

object_filter_t IsKnown() {
	return [](object_type const *o_ptr) -> bool {
		return object_known_p(o_ptr);
	};
}

object_filter_t True() {
	return [](object_type const *o_ptr) -> bool {
		return true;
	};
}

object_filter_t Not(object_filter_t p) {
	return [=](object_type const *o_ptr) -> bool {
		return !p(o_ptr);
	};
}

object_filter_t And() {
	return [](object_type const *) -> bool {
		return true;
	};
}

object_filter_t Or() {
	return [](object_type const *) -> bool {
		return false;
	};
}

}