]> git.localhorst.tv Git - l2e.git/blob - src/common/Spell.cpp
1b4142b006822f7fb8dd8023d773084eb64b6a25
[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 "TargetingMode.h"
11 #include "../loader/Interpreter.h"
12 #include "../loader/TypeDescription.h"
13
14 using loader::FieldDescription;
15 using loader::Interpreter;
16 using loader::TypeDescription;
17
18 namespace common {
19
20 Spell::Spell()
21 : name("")
22 , value(0)
23 , cost(0)
24 , heroMask(0)
25 , status(false)
26 , battle(false) {
27
28 }
29
30
31 bool Spell::Less(const Spell *lhs, const Spell *rhs) {
32         // TODO: find out real spell sorting order
33         return lhs->Cost() < rhs->Cost();
34 }
35
36
37 void Spell::CreateTypeDescription() {
38         Spell s;
39
40         TypeDescription &td(TypeDescription::Create(TYPE_ID, "Spell"));
41         td.SetDescription("All data about a spell (soon).");
42         td.SetConstructor(&Construct);
43         td.SetSize(sizeof(Spell));
44
45         td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), Interpreter::STRING_ID).SetReferenced().SetDescription("the spell's name"));
46         td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("amount of magic points needed and deducted for invocation"));
47         td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), TargetingMode::TYPE_ID).SetDescription("how target selection is to be performed"));
48         td.AddField("heroMask", FieldDescription(((char *)&s.heroMask) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("which heroes can invoke this spell"));
49         td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used at the status screen"));
50         td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used in battle"));
51 }
52
53 void Spell::Construct(void *data) {
54         new (data) Spell;
55 }
56
57 }