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;
21 : name(""), value(0), cost(0), status(false), battle(false) {
26 bool Spell::Less(const Spell *lhs, const Spell *rhs) {
27 // TODO: find out real spell sorting order
28 return lhs->Cost() < rhs->Cost();
32 void Spell::CreateTypeDescription() {
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));
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"));
47 void Spell::Construct(void *data) {