-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointwell.hpp
60 lines (51 loc) · 1.2 KB
/
pointwell.hpp
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
#pragma once
#include "types.hpp"
class PointWell {
private:
welltype CurrentFullness;
welltype Max;
public:
auto setMax(welltype new_max_) -> bool;
auto getMax() -> welltype;
auto getCurrent() -> welltype;
void reduceCurrent(welltype damage);
void increaseCurrent(welltype amount);
bool isFull();
PointWell();
PointWell(welltype c, welltype m) {
CurrentFullness = c;
Max = m;
if (CurrentFullness > Max) CurrentFullness = Max;
}
};
PointWell::PointWell() {
CurrentFullness = 1;
Max = 1;
}
auto PointWell::setMax(welltype new_max) -> bool {
if (new_max < 1) {
return false;
}
Max = new_max;
if (CurrentFullness > Max) {
CurrentFullness = Max;
}
return true;
}
auto PointWell::getMax() -> welltype { return Max; }
auto PointWell::getCurrent() -> welltype { return CurrentFullness; }
bool PointWell::isFull() { return CurrentFullness == Max; }
void PointWell::reduceCurrent(welltype damage) {
if (damage > CurrentFullness) {
CurrentFullness = 0;
} else {
CurrentFullness -= damage;
}
}
void PointWell::increaseCurrent(welltype amount) {
if (CurrentFullness + amount > Max) {
CurrentFullness = Max;
} else {
CurrentFullness += amount;
}
}