-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointSystem.h
More file actions
53 lines (44 loc) · 1.09 KB
/
Copy pathPointSystem.h
File metadata and controls
53 lines (44 loc) · 1.09 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
#pragma once
class PointSystem {
public:
// returns true if set successfully
[[nodiscard]] const unsigned int getMax() const noexcept {
return _max;
}
[[nodiscard]] const unsigned int getCurrent() const noexcept {
return _current;
}
[[nodiscard]] const bool isFull() const noexcept { return (_current == _max); }
void setMax(unsigned int new_max) noexcept {
if (new_max < 1)
_max = 1;
else
_max = new_max;
if (_current > _max)
_current = _max;
}
void reduceCurrent(unsigned int damage) noexcept {
if (damage > _current) {
_current = 0;
return;
}
_current -= damage;
}
void increaseCurrent(unsigned int amount) noexcept {
if (amount + _current > _max) {
_current = _max;
return;
}
_current += amount;
}
PointSystem() { _current = 1; _max = 1; }
PointSystem(unsigned int c, unsigned int m) {
_current = c;
_max = m;
if (_current > _max)
_current = _max;
}
private:
unsigned int _current;
unsigned int _max;
};