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