forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreature_name.cpp
More file actions
93 lines (75 loc) · 1.79 KB
/
creature_name.cpp
File metadata and controls
93 lines (75 loc) · 1.79 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "stdafx.h"
#include "creature_name.h"
#include "util.h"
CreatureName::CreatureName(const string& n) : name(n), pluralName(name + "s") {
CHECK(!name.empty());
}
CreatureName::CreatureName(const char* n) : CreatureName(string(n)) {
}
CreatureName::CreatureName(const string& n, const string& p) : name(n), pluralName(p) {
CHECK(!name.empty());
CHECK(!pluralName.empty());
}
string CreatureName::bare() const {
if (fullTitle)
return title();
else
return name;
}
string CreatureName::the() const {
if (fullTitle)
return title();
else
return "the " + name;
}
string CreatureName::a() const {
if (fullTitle)
return title();
else
return addAParticle(name);
}
string CreatureName::plural() const {
return pluralName;
}
string CreatureName::multiple(int count) const {
if (count == 1)
return name;
else
return groupName + " of " + toString(count) + " " + plural();
}
string CreatureName::title() const {
if (firstName)
return *firstName + " the " + name;
else
return capitalFirst(the());
}
void CreatureName::setFirst(const string& s) {
firstName = s;
}
void CreatureName::setStack(const string& s) {
stackName = s;
}
void CreatureName::setGroup(const string& s) {
groupName = s;
}
const optional<string>& CreatureName::stackOnly() const {
return stackName;
}
const string& CreatureName::stack() const {
if (stackName)
return *stackName;
else
return name;
}
optional<string> CreatureName::first() const {
return firstName;
}
void CreatureName::useFullTitle() {
fullTitle = true;
}
template <class Archive>
void CreatureName::serialize(Archive& ar, const unsigned int version) {
ar(name, pluralName, stackName, firstName, groupName, fullTitle);
}
SERIALIZABLE(CreatureName);
SERIALIZATION_CONSTRUCTOR_IMPL(CreatureName);