forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy_check.cpp
44 lines (33 loc) · 929 Bytes
/
enemy_check.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
#include "stdafx.h"
#include "enemy_check.h"
EnemyCheck::EnemyCheck(double w) : weight(w){}
double EnemyCheck::getWeight() const {
return weight;
}
class AllEnemies : public EnemyCheck {
public:
AllEnemies(double weight) : EnemyCheck(weight) {}
virtual bool hasStanding(const Creature*) const override {
return true;
}
virtual double getStanding(const Creature*) const override {
return -1;
}
};
EnemyCheck* EnemyCheck::allEnemies(double weight) {
return new AllEnemies(weight);
}
class FriendlyAnimals : public EnemyCheck {
public:
FriendlyAnimals(double weight) : EnemyCheck(weight) {}
virtual bool hasStanding(const Creature* c) const override {
return c->isAnimal();
}
virtual double getStanding(const Creature* c) const override {
CHECK(c->isAnimal());
return 1;
}
};
EnemyCheck* EnemyCheck::friendlyAnimals(double weight) {
return new FriendlyAnimals(weight);
}