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