-
Notifications
You must be signed in to change notification settings - Fork 0
/
statchange.h
56 lines (53 loc) · 1.23 KB
/
statchange.h
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
#ifndef STATCHANGE_H
#define STATCHANGE_H
#include "json_macros.h"
#include "person.h"
class StatChange {
public:
QString Stat;
double Change;
double Minimum;
double Maximum;
bool ShouldSerializeMinimum()
{
return Minimum != 0.0;
}
bool ShouldSerializeMaximum()
{
return Maximum != 0.0;
}
bool WithinRange(double Value)
{
return Value >= 1.0 && (Minimum == 0.0 || Value >= Minimum) && (Maximum == 0.0 || Value <= Maximum);
}
void AdjustStat(Person *Per)
{
/*if (WithinRange(Per.GetStat(Stat)))
{
Per.AddStat(Stat, Change);
if (Minimum != 0.0 && Per.GetStat(Stat) < Minimum)
{
Per.SetStat(Stat, Minimum);
return;
}
if (Maximum != 0.0 && Per.GetStat(Stat) > Maximum)
{
Per.SetStat(Stat, Maximum);
}
}*/
}
StatChange(QJsonObject *d = NULL) {
if (d) init(d);
}
void init(QJsonObject *d)
{
for (QJsonObject::iterator it = d->begin(); it != d->end(); ++it) {
//BodyPart BodyPart
__IF_VAR_FROM_JSON_AS(it, Stat, toString);
__IF_VAR_FROM_JSON_AS(it, Change, toDouble);
__IF_VAR_FROM_JSON_AS(it, Minimum, toDouble);
__IF_VAR_FROM_JSON_AS(it, Maximum, toDouble);
}
}
};
#endif // STATCHANGE_H