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