4 * Created on: Aug 10, 2012
10 #include "TargetingMode.h"
11 #include "../loader/Interpreter.h"
12 #include "../loader/TypeDescription.h"
14 using loader::FieldDescription;
15 using loader::Interpreter;
16 using loader::TypeDescription;
31 bool Spell::Less(const Spell *lhs, const Spell *rhs) {
32 // TODO: find out real spell sorting order
33 return lhs->Cost() < rhs->Cost();
37 void Spell::CreateTypeDescription() {
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));
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"));
53 void Spell::Construct(void *data) {