/
LeyGroup.cpp
68 lines (56 loc) · 1.64 KB
/
LeyGroup.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "LeyGroup.h"
#include "merc.h"
const long LeyGroup::Unattuned;
const std::vector<Fount::Info> & Fount::BuildInfos()
{
static std::vector<Info> infos;
infos.push_back(Info(Always, "always", 0, 4));
infos.push_back(Info(Often, "often", 0, 3));
infos.push_back(Info(Occasionally, "occasionally", 40, 2));
infos.push_back(Info(Rarely, "rarely", 80, 1));
infos.push_back(Info(Never, "never", 101, 0));
infos.push_back(Info(Default, "default", 40, 2));
return infos;
}
const std::vector<Fount::Info> & Fount::Infos()
{
static const std::vector<Fount::Info> & infos(BuildInfos());
return infos;
}
Fount::Frequency Fount::ValueFor(const char * name)
{
for (unsigned int i(0); i < Max && i < Infos().size(); ++i)
{
if (!str_prefix(name, Infos()[i].name))
return static_cast<Frequency>(i);
}
return Default;
}
int LeyGroup::TotalOrderPower() const
{
int total(m_fount.OrderPower);
for (size_t i(0); i < m_infos.size(); ++i)
total += m_infos[i].OrderPower;
return total;
}
int LeyGroup::TotalPositivePower() const
{
int total(m_fount.PositivePower);
for (size_t i(0); i < m_infos.size(); ++i)
total += m_infos[i].PositivePower;
return total;
}
unsigned int LeyGroup::LineByID(const void * id) const
{
for (size_t i(0); i < m_infos.size(); ++i)
{
if (m_infos[i].ID == id)
return i;
}
return NotFound;
}
void LeyGroup::Remove(unsigned int index)
{
m_infos[index] = m_infos[m_infos.size() - 1];
m_infos.pop_back();
}