]> git.localhorst.tv Git - l2e.git/blob - src/battle/Stats.cpp
more Vector operations
[l2e.git] / src / battle / Stats.cpp
1 /*
2  * Stats.cpp
3  *
4  *  Created on: Aug 19, 2012
5  *      Author: holy
6  */
7
8 #include "Stats.h"
9
10 #include "../loader/TypeDescription.h"
11
12 using loader::FieldDescription;
13 using loader::TypeDescription;
14
15 namespace battle {
16
17 Stats::Stats()
18 : attack(0)
19 , defense(0)
20 , strength(0)
21 , agility(0)
22 , intelligence(0)
23 , magicResistance(0)
24 , gut(0) {
25
26 }
27
28 Stats::Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance)
29 : attack(attack)
30 , defense(defense)
31 , strength(strength)
32 , agility(agility)
33 , intelligence(intelligence)
34 , magicResistance(magicResistance)
35 , gut(gut) {
36
37 }
38
39
40 void Stats::CreateTypeDescription() {
41         Stats s;
42
43         int numberId(TypeDescription::GetTypeId("Number"));
44
45         TypeDescription &td(TypeDescription::CreateOrGet("Stats"));
46         td.SetConstructor(&Construct);
47         td.SetSize(sizeof(Stats));
48
49         td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), numberId, false));
50         td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), numberId, false));
51         td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), numberId, false));
52         td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), numberId, false));
53         td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), numberId, false));
54         td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), numberId, false));
55         td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), numberId, false));
56 }
57
58 void Stats::Construct(void *data) {
59         new (data) Stats;
60 }
61
62 }