X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FSpell.cpp;h=d776f8b7139b6c8847ec5999f38a6b52903f1f02;hb=092a2dd175a4001a495c84ee85211734fb928c83;hp=907034645b76373b3961340614b988cc6007bbbe;hpb=76bfe67c6f41be9c862213a3cba919e6c00955b0;p=l2e.git diff --git a/src/common/Spell.cpp b/src/common/Spell.cpp index 9070346..d776f8b 100644 --- a/src/common/Spell.cpp +++ b/src/common/Spell.cpp @@ -1,39 +1,50 @@ -/* - * Spell.cpp - * - * Created on: Aug 10, 2012 - * Author: holy - */ - #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 { Spell::Spell() -: name(""), value(0), cost(0), usability(0) { +: name("") +, value(0) +, cost(0) +, heroMask(0) +, status(false) +, battle(false) { } +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; - 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)); - // TODO: flags - int numberId(TypeDescription::GetTypeId("Number")); - int stringId(TypeDescription::GetTypeId("String")); - int targetsId(TypeDescription::GetTypeId("TargetingMode")); + 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("heroMask", FieldDescription(((char *)&s.heroMask) - ((char *)&s), Interpreter::NUMBER_ID).SetDescription("which heroes can invoke this spell")); + 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")); +} - 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)); +void Spell::Construct(void *data) { + new (data) Spell; } }