]> git.localhorst.tv Git - l2e.git/blob - src/common/Stats.cpp
c15ca1ac5d4913cefe8458d1e74f2dd4cbd8c7a2
[l2e.git] / src / common / Stats.cpp
1 #include "Stats.h"
2
3 #include "../loader/Interpreter.h"
4 #include "../loader/TypeDescription.h"
5
6 using loader::FieldDescription;
7 using loader::Interpreter;
8 using loader::TypeDescription;
9
10 namespace common {
11
12 Stats::Stats()
13 : attack(0)
14 , defense(0)
15 , strength(0)
16 , agility(0)
17 , intelligence(0)
18 , magicResistance(0)
19 , gut(0) {
20
21 }
22
23 Stats::Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance)
24 : attack(attack)
25 , defense(defense)
26 , strength(strength)
27 , agility(agility)
28 , intelligence(intelligence)
29 , magicResistance(magicResistance)
30 , gut(gut) {
31
32 }
33
34
35 void Stats::CreateTypeDescription() {
36         Stats s;
37
38         TypeDescription &td(TypeDescription::Create(TYPE_ID, "Stats"));
39         td.SetDescription("Attributes of a battle's participant.");
40         td.SetConstructor(&Construct);
41         td.SetSize(sizeof(Stats));
42
43         td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("attack points"));
44         td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("defense points"));
45         td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("strength"));
46         td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("agility"));
47         td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("intelligence"));
48         td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("gut (ikari factor)"));
49         td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("magic resistance"));
50 }
51
52 void Stats::Construct(void *data) {
53         new (data) Stats;
54 }
55
56 }