4 #include "TargetingMode.h"
5 #include "../graphics/Animation.h"
6 #include "../graphics/Sprite.h"
7 #include "../loader/Interpreter.h"
8 #include "../loader/TypeDescription.h"
10 using graphics::Animation;
11 using graphics::Sprite;
12 using loader::FieldDescription;
13 using loader::Interpreter;
14 using loader::TypeDescription;
41 void Item::CreateTypeDescription() {
44 TypeDescription &td(TypeDescription::Create(TYPE_ID, "Item"));
45 td.SetDescription("All data of an item (soon).");
46 td.SetConstructor(&Construct);
47 td.SetSize(sizeof(Item));
49 td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), Interpreter::STRING_ID).SetReferenced().SetDescription("the item's name"));
50 td.AddField("menuicon", FieldDescription(((char *)&i.menuIcon) - ((char *)&i), Sprite::TYPE_ID).SetReferenced().SetDescription("icon that is displayed in menus"));
52 td.AddField("mostUseful", FieldDescription(((char *)&i.mostUseful) - ((char *)&i), Interpreter::BOOLEAN_ID));
53 td.AddField("cursed", FieldDescription(((char *)&i.cursed) - ((char *)&i), Interpreter::BOOLEAN_ID));
54 td.AddField("fruit", FieldDescription(((char *)&i.fruit) - ((char *)&i), Interpreter::BOOLEAN_ID));
55 td.AddField("scenario", FieldDescription(((char *)&i.scenario) - ((char *)&i), Interpreter::BOOLEAN_ID));
56 td.AddField("status", FieldDescription(((char *)&i.status) - ((char *)&i), Interpreter::BOOLEAN_ID));
57 td.AddField("battle", FieldDescription(((char *)&i.battle) - ((char *)&i), Interpreter::BOOLEAN_ID).SetDescription("if the item can be used in battle"));
59 td.AddField("targets", FieldDescription(((char *)&i.targettingMode) - ((char *)&i), TargetingMode::TYPE_ID).SetDescription("how target selection is to be performed"));
60 td.AddField("ikari", FieldDescription(((char *)&i.ikari) - ((char *)&i), Ikari::TYPE_ID).SetReferenced().SetDescription("ikari attack of the item (sensible only for equipment)"));
61 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"));
62 td.AddField("equipability", FieldDescription(((char *)&i.equipability) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("how this item can be equipped"));
63 td.AddField("heroMask", FieldDescription(((char *)&i.heroMask) - ((char *)&i), Interpreter::NUMBER_ID).SetDescription("which heroes may equip this item"));
66 void Item::Construct(void *data) {
71 bool Item::Less(const Item &lhs, const Item &rhs) {
72 if (lhs.IsMostUseful()) {
73 return !rhs.IsMostUseful();
75 if (lhs.IsEquipable()) {
76 if (rhs.IsMostUseful()) {
79 if (!rhs.IsEquipable()) {
82 return lhs.equipability < rhs.equipability;
85 if (rhs.IsMostUseful() || rhs.IsEquipable()) {
88 return !rhs.IsFruit();