blob: a214f423f3ae9af0f54f184d38e53dba13674c17 (
plain)
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
|
#include <kurator/sim/HitPoints.h>
namespace kurator
{
namespace sim
{
HitPoints::HitPoints(double base_shield, double base_armour, double base_structure) :
structure {base_structure},
armour {base_armour},
shield {base_shield}
{
}
double
HitPoints::Layer::consume(double& damage)
{
if (damage <= 0.0)
return 0.0;
const double left_to_deal = damage - points;
const double actual_damage = damage * resists;
points -= damage * resists;
damage = left_to_deal;
return actual_damage;
}
double
HitPoints::deal(double damage)
{
return shield.consume(damage) + armour.consume(damage) + structure.consume(damage);
}
bool
HitPoints::is_alive() const
{
return structure.points > 0.0;
}
double
HitPoints::total() const
{
return shield.points + armour.points + structure.points;
}
} // namespace sim
} // namespace kurator
|