4 * Created on: Aug 9, 2012
11 #include "TargetingMode.h"
12 #include "../graphics/Animation.h"
13 #include "../graphics/Sprite.h"
14 #include "../loader/Interpreter.h"
15 #include "../loader/TypeDescription.h"
17 using graphics::Animation;
18 using graphics::Sprite;
19 using loader::FieldDescription;
20 using loader::Interpreter;
21 using loader::TypeDescription;
48 void Item::CreateTypeDescription() {
51 TypeDescription &td(TypeDescription::Create(TYPE_ID, "Item"));
52 td.SetDescription("All data of an item (soon).");
53 td.SetConstructor(&Construct);
54 td.SetSize(sizeof(Item));
56 td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), Interpreter::STRING_ID).SetReferenced().SetDescription("the item's name"));
57 td.AddField("menuicon", FieldDescription(((char *)&i.menuIcon) - ((char *)&i), Sprite::TYPE_ID).SetReferenced().SetDescription("icon that is displayed in menus"));
59 td.AddField("mostUseful", FieldDescription(((char *)&i.mostUseful) - ((char *)&i), Interpreter::BOOLEAN_ID));
60 td.AddField("cursed", FieldDescription(((char *)&i.cursed) - ((char *)&i), Interpreter::BOOLEAN_ID));
61 td.AddField("fruit", FieldDescription(((char *)&i.fruit) - ((char *)&i), Interpreter::BOOLEAN_ID));
62 td.AddField("scenario", FieldDescription(((char *)&i.scenario) - ((char *)&i), Interpreter::BOOLEAN_ID));
63 td.AddField("status", FieldDescription(((char *)&i.status) - ((char *)&i), Interpreter::BOOLEAN_ID));
64 td.AddField("battle", FieldDescription(((char *)&i.battle) - ((char *)&i), Interpreter::BOOLEAN_ID).SetDescription("if the item can be used in battle"));
66 td.AddField("targets", FieldDescription(((char *)&i.targettingMode) - ((char *)&i), TargetingMode::TYPE_ID).SetDescription("how target selection is to be performed"));
67 td.AddField("ikari", FieldDescription(((char *)&i.ikari) - ((char *)&i), Ikari::TYPE_ID).SetReferenced().SetDescription("ikari attack of the item (sensible only for equipment)"));
68 td.AddField("attackanimation", FieldDescription(((char *)&i.attackAnimation) - ((char *)&i), Animation::TYPE_ID).SetReferenced().SetDescription("animation that is run when the item is used for attacking"));
69 td.AddField("equipability", FieldDescription(((char *)&i.equipability) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("how this item can be equipped"));
70 td.AddField("heroMask", FieldDescription(((char *)&i.heroMask) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("which heroes may equip this item"));
73 void Item::Construct(void *data) {
78 bool Item::Less(const Item &lhs, const Item &rhs) {
79 if (lhs.IsMostUseful()) {
80 return !rhs.IsMostUseful();
82 if (lhs.IsEquipable()) {
83 if (rhs.IsMostUseful()) {
86 if (!rhs.IsEquipable()) {
89 return lhs.equipability < rhs.equipability;
92 if (rhs.IsMostUseful() || rhs.IsEquipable()) {
95 return !rhs.IsFruit();