]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Spell.cpp
implemented spell sorting
[l2e.git] / src / common / Spell.cpp
index 4fce398bdaf16e534c702736b1d12d101f0362f9..33979ca9811d97a32a84a28b30bedd71db3853fc 100644 (file)
@@ -7,9 +7,12 @@
 
 #include "Spell.h"
 
+#include "TargetingMode.h"
+#include "../loader/Interpreter.h"
 #include "../loader/TypeDescription.h"
 
 using loader::FieldDescription;
+using loader::Interpreter;
 using loader::TypeDescription;
 
 namespace common {
@@ -20,23 +23,25 @@ Spell::Spell()
 }
 
 
+bool Spell::Less(const Spell *lhs, const Spell *rhs) {
+       // TODO: find out real spell sorting order
+       return lhs->Cost() < rhs->Cost();
+}
+
+
 void Spell::CreateTypeDescription() {
        Spell s;
 
-       int boolId(TypeDescription::GetTypeId("Boolean"));
-       int numberId(TypeDescription::GetTypeId("Number"));
-       int stringId(TypeDescription::GetTypeId("String"));
-       int targetsId(TypeDescription::GetTypeId("TargetingMode"));
-
-       TypeDescription &td(TypeDescription::CreateOrGet("Spell"));
+       TypeDescription &td(TypeDescription::Create(TYPE_ID, "Spell"));
+       td.SetDescription("All data about a spell (soon).");
        td.SetConstructor(&Construct);
        td.SetSize(sizeof(Spell));
 
-       td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId, true));
-       td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId, false));
-       td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId, false));
-       td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), boolId, false));
-       td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), boolId, false));
+       td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), Interpreter::STRING_ID).SetReferenced().SetDescription("the spell's name"));
+       td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("Amount of magic points needed and deducted for invocation"));
+       td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), TargetingMode::TYPE_ID).SetDescription("how target selection is to be performed"));
+       td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used at the status screen"));
+       td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), Interpreter::BOOLEAN_ID).SetDescription("if the spell can be used in battle"));
 }
 
 void Spell::Construct(void *data) {