forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollective_attack.cpp
More file actions
43 lines (32 loc) · 1.21 KB
/
collective_attack.cpp
File metadata and controls
43 lines (32 loc) · 1.21 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
#include "stdafx.h"
#include "collective_attack.h"
#include "collective.h"
#include "creature.h"
#include "collective_name.h"
SERIALIZE_DEF(CollectiveAttack, attacker, ransom, creatures, attackerName)
SERIALIZATION_CONSTRUCTOR_IMPL(CollectiveAttack);
static string generateAttackerName(WConstCollective attacker) {
if (auto& name = attacker->getName())
return name->full;
else
return "an unnamed attacker";
}
CollectiveAttack::CollectiveAttack(WCollective att, const vector<WCreature>& c, optional<int> r)
: ransom(r), creatures(c), attacker(att), attackerName(generateAttackerName(att)) {}
CollectiveAttack::CollectiveAttack(const string& name, const vector<WCreature>& c) : creatures(c), attackerName(name) {
}
WCollective CollectiveAttack::getAttacker() const {
return attacker;
}
const string& CollectiveAttack::getAttackerName() const {
return attackerName;
}
const vector<WCreature>& CollectiveAttack::getCreatures() const {
return creatures;
}
optional<int> CollectiveAttack::getRansom() const {
return ransom;
}
bool CollectiveAttack::operator == (const CollectiveAttack& o) const {
return attacker == o.attacker && ransom == o.ransom && creatures == o.creatures && attackerName == o.attackerName;
}