-
Notifications
You must be signed in to change notification settings - Fork 26
/
Rule.cpp
45 lines (36 loc) · 1.11 KB
/
Rule.cpp
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
#include "Rule.h"
bool Rule::Evaluate(Unit* pItem) {
for (auto& condition : m_Conditions) {
if (!condition->Evaluate(pItem)) {
return false;
}
}
return true;
}
void Rule::EvaluateActionResult(ActionResult& actionResult, Unit* pItem) const {
actionResult.bContinue = false;
for (auto& action : m_Actions) {
action->SetResult(actionResult, pItem);
}
}
uint32_t Rule::GetLineNumber() const {
return m_LineNumber;
}
const std::vector<std::unique_ptr<Condition>>& Rule::GetConditions() {
return m_Conditions;
}
const std::vector<std::unique_ptr<Action>>& Rule::GetActions() {
return m_Actions;
}
void Rule::AddAction(std::unique_ptr<Action> action) {
m_Actions.push_back(std::move(action));
}
void Rule::AddActions(std::vector<std::unique_ptr<Action>> actions) {
std::move(actions.begin(), actions.end(), std::back_inserter(m_Actions));
}
void Rule::AddCondition(std::unique_ptr<Condition> condition) {
m_Conditions.push_back(std::move(condition));
}
void Rule::AddConditions(std::vector<std::unique_ptr<Condition>> conditions) {
std::move(conditions.begin(), conditions.end(), std::back_inserter(m_Conditions));
}