-
Notifications
You must be signed in to change notification settings - Fork 1
/
Effects.cpp
112 lines (97 loc) · 2.6 KB
/
Effects.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// --------------------------------------------------------------------------------------------------------------------------------
// DEMISERL
// Copyright 2014 Corremn
//
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
// $HeadURL: $
// --------------------------------------------------------------------------------------------------------------------------------
#include "WorldBuilder.h"
#include ".\effects.h"
Effects::Effects(void) : max_effects(7)
{
}
void Effects::AddEffect(eEffect effect, int strength)
{
if (effect < 0 || effect > max_effects)
return;
//if(effectMap[effect] < strength)
//effectMap[effect] = strength;
//test if already has effect;
if (GetEffect(effect))
{
SetEffect(effect, strength);
}
else
{
EFFECT e;
e.strength = strength;
e.type = effect;
effectList.push_back(e);
}
}
//set effects strength
int Effects::SetEffect(eEffect effect, int strength)
{
EFFECTLIST::iterator eit;
for (eit = effectList.begin(); eit != effectList.end(); eit++)
{
if (effect == eit->type) //if found return new strength
{
if (eit->strength < strength)
eit->strength = strength;
return strength;
}
}
return 0;
}
void Effects::ReduceEffect(eEffect effect, int reduce)
{
//effectMap[effect] -= reduce;
//if(effectMap[effect] < 0) //cant be les than 0
// effectMap[effect] =0;
//if(effectMap[effect] == 0)
// RemoveEffect(effect);
EFFECTLIST::iterator it;
int size = effectList.size();
int i = 0;
for (it = effectList.begin(); it != effectList.end(); it++, i++)
{
int go = i;
int t = it->type;
int s = it->strength;
if (effect == it->type)
{
it->strength -= reduce;
if (it->strength <= 0)
{
// RemoveEffect(effect);
return;;
}
}
}
}
void Effects::RemoveEffect(eEffect effect)
{
EFFECTLIST::iterator eit;
for (eit = effectList.begin(); eit != effectList.end(); eit++)
{
if (effect == eit->type)
{
effectList.erase(eit);
break;
}
}
}
int Effects::GetEffect(eEffect effect)
{
EFFECTLIST::iterator eit;
for (eit = effectList.begin(); eit != effectList.end(); eit++)
{
if (effect == eit->type)
return eit->strength;
}
return 0;
//return effectMap[effect];
}