]> git.localhorst.tv Git - l2e.git/blob - src/common/Spell.cpp
added textual type/field descriptions and wiki mode
[l2e.git] / src / common / Spell.cpp
1 /*
2  * Spell.cpp
3  *
4  *  Created on: Aug 10, 2012
5  *      Author: holy
6  */
7
8 #include "Spell.h"
9
10 #include "../loader/TypeDescription.h"
11
12 using loader::FieldDescription;
13 using loader::TypeDescription;
14
15 namespace common {
16
17 Spell::Spell()
18 : name(""), value(0), cost(0), status(false), battle(false) {
19
20 }
21
22
23 void Spell::CreateTypeDescription() {
24         Spell s;
25
26         int boolId(TypeDescription::GetTypeId("Boolean"));
27         int numberId(TypeDescription::GetTypeId("Number"));
28         int stringId(TypeDescription::GetTypeId("String"));
29         int targetsId(TypeDescription::GetTypeId("TargetingMode"));
30
31         TypeDescription &td(TypeDescription::CreateOrGet("Spell"));
32         td.SetDescription("All data about a spell (soon).");
33         td.SetConstructor(&Construct);
34         td.SetSize(sizeof(Spell));
35
36         td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId).SetReferenced().SetDescription("the spell's name"));
37         td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId).SetDescription("Amount of magic points needed and deducted for invocation"));
38         td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId).SetDescription("how target selection is to be performed"));
39         td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), boolId).SetDescription("if the spell can be used at the status screen"));
40         td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), boolId).SetDescription("if the spell can be used in battle"));
41 }
42
43 void Spell::Construct(void *data) {
44         new (data) Spell;
45 }
46
47 }