-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEffect.cpp
More file actions
37 lines (28 loc) · 750 Bytes
/
Copy pathEffect.cpp
File metadata and controls
37 lines (28 loc) · 750 Bytes
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
#define _WINDOWS
#include "Effect.h"
Effect::Effect(std::function<void()> onCreate, std::function<void()> onDestruct, int duration) {
this->onCreate = onCreate;
this->onDestruct = onDestruct;
this->expires = getTickCount() + duration;
this->onCreate();
};
Effect::~Effect() {
this->onDestruct();
};
bool Effect::expired(int now) {
return now > this->expires;
}
IncreaseEffect::IncreaseEffect(Unit* unit, double coef, int duration) :
Effect(
[unit, coef]() { unit->increase(coef); },
[unit, coef]() { unit->decrease(coef); },
duration
) {
}
DecreaseEffect::DecreaseEffect(Unit* unit, double coef, int duration) :
Effect(
[unit, coef]() { unit->decrease(coef); },
[unit, coef]() { unit->increase(coef); },
duration
) {
}